Changeset 416
- Timestamp:
- 11/01/11 11:39:31 (7 months ago)
- Location:
- cafu/trunk
- Files:
-
- 5 modified
-
CaWE/GuiEditor/Commands/ModifyWindow.cpp (modified) (3 diffs)
-
CaWE/GuiEditor/Windows/EditorModelWindow.cpp (modified) (4 diffs)
-
Libs/GuiSys/WindowModel.cpp (modified) (12 diffs)
-
Libs/GuiSys/WindowModel.hpp (modified) (3 diffs)
-
Libs/Models/AnimPose.hpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
cafu/trunk/CaWE/GuiEditor/Commands/ModifyWindow.cpp
r415 r416 28 28 #include "MaterialSystem/Renderer.hpp" 29 29 #include "MaterialSystem/MaterialManager.hpp" 30 #include " Fonts/FontTT.hpp"30 #include "Models/Model_cmdl.hpp" 31 31 32 32 … … 126 126 else if (m_PropertyName=="Model") 127 127 { 128 std::string ErrorMsg; 128 129 cf::GuiSys::ModelWindowT* ModelWindow=dynamic_cast<cf::GuiSys::ModelWindowT*>(m_Window); 129 130 wxASSERT(ModelWindow!=NULL); 130 131 131 ModelProxyT& Model=ModelWindow->GetModel(); 132 133 m_OldString=Model.GetFileName(); 134 135 Model=ModelProxyT(m_NewString); 132 m_OldString=ModelWindow->GetModel()->GetFileName(); 133 134 ModelWindow->SetModel(m_NewString, ErrorMsg); 136 135 } 137 136 else … … 195 194 else if (m_PropertyName=="Model") 196 195 { 196 std::string ErrorMsg; 197 197 cf::GuiSys::ModelWindowT* ModelWindow=dynamic_cast<cf::GuiSys::ModelWindowT*>(m_Window); 198 198 wxASSERT(ModelWindow!=NULL); 199 199 200 ModelWindow-> GetModel()=ModelProxyT(m_OldString);200 ModelWindow->SetModel(m_OldString, ErrorMsg); 201 201 } 202 202 else -
cafu/trunk/CaWE/GuiEditor/Windows/EditorModelWindow.cpp
r367 r416 27 27 #include "GuiSys/WindowModel.hpp" 28 28 #include "GuiSys/WindowCreateParams.hpp" 29 #include "Models/Model_cmdl.hpp" 29 30 30 31 #include "wx/propgrid/manager.h" … … 45 46 EditorWindowT::FillInPG(PropMan); 46 47 47 PropMan->Append(new wxStringProperty("Model", wxPG_LABEL, m_ModelWindow->GetModel() .GetFileName()));48 PropMan->Append(new wxStringProperty("Model", wxPG_LABEL, m_ModelWindow->GetModel()->GetFileName())); 48 49 49 50 PropMan->Append(new wxIntProperty("ModelSequNr", wxPG_LABEL, m_ModelWindow->GetModelSequNr())); … … 74 75 wxString PropName=Property->GetName(); 75 76 76 if (PropName=="Model") Property->SetValueFromString(m_ModelWindow->GetModel() .GetFileName());77 if (PropName=="Model") Property->SetValueFromString(m_ModelWindow->GetModel()->GetFileName()); 77 78 else if (PropName=="ModelSequNr") Property->SetValue(m_ModelWindow->GetModelSequNr()); 78 79 else if (PropName=="ModelPos.x") Property->SetValue(m_ModelWindow->GetModelPos().x); … … 181 182 cf::GuiSys::ModelWindowT Default(Params); 182 183 183 if (m_ModelWindow->GetModel() .GetFileName()!=Default.GetModel().GetFileName())184 OutFile << " self:SetModel(\"" << m_ModelWindow->GetModel() .GetFileName() << "\");\n";184 if (m_ModelWindow->GetModel()->GetFileName()!=Default.GetModel()->GetFileName()) 185 OutFile << " self:SetModel(\"" << m_ModelWindow->GetModel()->GetFileName() << "\");\n"; 185 186 186 187 if (m_ModelWindow->GetModelSequNr()!=Default.GetModelSequNr()) -
cafu/trunk/Libs/GuiSys/WindowModel.cpp
r285 r416 25 25 #include "MaterialSystem/Renderer.hpp" 26 26 #include "Math3D/Matrix.hpp" 27 #include "Models/AnimPose.hpp" 28 #include "Models/Model_cmdl.hpp" 27 29 28 30 extern "C" … … 64 66 ModelWindowT::ModelWindowT(const cf::GuiSys::WindowCreateParamsT& Params) 65 67 : WindowT(Params), 66 Model(""), 67 ModelSequNr(0), 68 ModelFrameNr(0.0f), 68 m_Model(NULL), 69 m_Pose(NULL), 69 70 ModelPos(0, 0, 0), 70 71 ModelScale(1.0f), … … 72 73 CameraPos(0, -200.0f, 0) 73 74 { 75 std::string ErrorMsg; 76 77 SetModel("dummy", ErrorMsg); 74 78 FillMemberVars(); 75 79 } … … 78 82 ModelWindowT::ModelWindowT(const ModelWindowT& Window, bool Recursive) 79 83 : WindowT(Window, Recursive), 80 Model(Window.Model), 81 ModelSequNr(Window.ModelSequNr), 82 ModelFrameNr(Window.ModelFrameNr), 84 m_Model(NULL), 85 m_Pose(NULL), 83 86 ModelPos(Window.ModelPos), 84 87 ModelScale(Window.ModelScale), … … 86 89 CameraPos(Window.CameraPos) 87 90 { 91 std::string ErrorMsg; 92 93 SetModel(Window.m_Model->GetFileName(), ErrorMsg); 88 94 FillMemberVars(); 89 95 } … … 98 104 ModelWindowT::~ModelWindowT() 99 105 { 106 delete m_Pose; 107 } 108 109 110 void ModelWindowT::SetModel(const std::string& FileName, std::string& ErrorMsg) 111 { 112 const CafuModelT* PrevModel=m_Model; 113 114 m_Model=m_Gui.GetGuiResources().GetModel(FileName, ErrorMsg); 115 116 if (m_Pose==NULL || PrevModel!=m_Model) 117 { 118 delete m_Pose; 119 m_Pose=new AnimPoseT(*m_Model, 0, 0.0f); 120 } 121 } 122 123 124 int ModelWindowT::GetModelSequNr() const 125 { 126 return m_Pose->GetSequNr(); 100 127 } 101 128 … … 128 155 MatSys::Renderer->SetCurrentEyePosition(CameraPos.x, CameraPos.y, CameraPos.z); // Required in some ambient shaders. 129 156 130 Model.Draw(ModelSequNr, ModelFrameNr, 0.0f, NULL);157 m_Pose->Draw(-1 /*default skin*/, 0.0f); 131 158 132 159 MatSys::Renderer->PopMatrix(MatSys::RendererI::PROJECTION ); … … 138 165 bool ModelWindowT::OnClockTickEvent(float t) 139 166 { 140 ModelFrameNr=Model.AdvanceFrameNr(ModelSequNr, ModelFrameNr,t, true);167 m_Pose->Advance(t, true); 141 168 142 169 return WindowT::OnClockTickEvent(t); … … 148 175 WindowT::FillMemberVars(); 149 176 150 MemberVars["modelSequNr"]=MemberVarT(ModelSequNr);151 MemberVars["modelFrameNr"]=MemberVarT(ModelFrameNr);152 177 MemberVars["modelPos.x"]=MemberVarT(ModelPos.x); 153 178 MemberVars["modelPos.y"]=MemberVarT(ModelPos.y); … … 165 190 int ModelWindowT::SetModel(lua_State* LuaState) 166 191 { 167 ModelWindowT* ModelWin=(ModelWindowT*)cf::GuiSys::GuiImplT::GetCheckedObjectParam(LuaState, 1, TypeInfo); 168 169 ModelWin->Model=ModelProxyT(luaL_checkstring(LuaState, 2)); 192 std::string ErrorMsg; 193 ModelWindowT* ModelWin=(ModelWindowT*)cf::GuiSys::GuiImplT::GetCheckedObjectParam(LuaState, 1, TypeInfo); 194 195 ModelWin->SetModel(luaL_checkstring(LuaState, 2), ErrorMsg); 196 197 if (ErrorMsg!="") return luaL_error(LuaState, "%s", ErrorMsg.c_str()); 170 198 return 0; 171 199 } … … 176 204 ModelWindowT* ModelWin=(ModelWindowT*)cf::GuiSys::GuiImplT::GetCheckedObjectParam(LuaState, 1, TypeInfo); 177 205 178 lua_pushinteger(LuaState, ModelWin-> Model.GetNrOfSequences());206 lua_pushinteger(LuaState, ModelWin->m_Model->GetAnims().Size()); 179 207 return 1; 180 208 } … … 185 213 ModelWindowT* ModelWin=(ModelWindowT*)cf::GuiSys::GuiImplT::GetCheckedObjectParam(LuaState, 1, TypeInfo); 186 214 187 ModelWin-> ModelSequNr=luaL_checkinteger(LuaState, 2);215 ModelWin->m_Pose->SetSequNr(luaL_checkinteger(LuaState, 2)); 188 216 return 0; 189 217 } -
cafu/trunk/Libs/GuiSys/WindowModel.hpp
r367 r416 24 24 25 25 #include "Window.hpp" 26 #include "Models/Model_proxy.hpp" 26 #include "Math3D/Vector3.hpp" 27 28 29 class CafuModelT; 30 class AnimPoseT; 27 31 28 32 … … 47 51 ~ModelWindowT(); 48 52 49 /// Returns the model this window shows. 50 ModelProxyT& GetModel() { return Model; } 51 52 int GetModelSequNr() const { return ModelSequNr; } ///< Returns the animation sequence number that is used for the model. 53 // float GetModelFrameNr() const { return ModelFrameNr; } ///< Returns the frame number of the sequence. The only variable that is not set by script, but advanced automatically. 53 const CafuModelT* GetModel() const { return m_Model; } 54 void SetModel(const std::string& FileName, std::string& ErrorMsg); 55 int GetModelSequNr() const; 54 56 const Vector3fT& GetModelPos() const { return ModelPos; } ///< Returns the position of the model in world space. 55 57 float GetModelScale() const { return ModelScale; } ///< Returns the scale factor applied to the model coordinates when converted to world space. … … 76 78 private: 77 79 78 ModelProxyT Model; ///< The model instance rendered by this window. 79 int ModelSequNr; ///< The animation sequence number that is used for the model. 80 float ModelFrameNr; ///< The frame number of the sequence. The only variable that is not set by script, but advanced automatically. 81 Vector3fT ModelPos; ///< The position of the model in world space. 82 float ModelScale; ///< The scale factor applied to the model coordinates when converted to world space. 83 Vector3fT ModelAngles; ///< The angles around the axes that determine the orientation of the model in world space. 84 Vector3fT CameraPos; ///< The position of the camera in world space. 80 const CafuModelT* m_Model; ///< The model instance rendered by this window. 81 AnimPoseT* m_Pose; ///< The pose of the model. 82 Vector3fT ModelPos; ///< The position of the model in world space. 83 float ModelScale; ///< The scale factor applied to the model coordinates when converted to world space. 84 Vector3fT ModelAngles; ///< The angles around the axes that determine the orientation of the model in world space. 85 Vector3fT CameraPos; ///< The position of the camera in world space. 85 86 86 87 -
cafu/trunk/Libs/Models/AnimPose.hpp
r415 r416 105 105 ~AnimPoseT(); 106 106 107 int GetSequNr() const { return m_SequNr; } 108 107 109 /// @param SequNr The number of the animation sequence to use, -1 for the bind pose. 108 110 void SetSequNr(int SequNr);
