Changeset 414
- Timestamp:
- 10/28/11 13:58:10 (7 months ago)
- Location:
- cafu/trunk
- Files:
-
- 2 added
- 12 modified
-
CaWE/DialogInsp-PrimitiveProps.cpp (modified) (2 diffs)
-
CaWE/GameConfig.cpp (modified) (1 diff)
-
CaWE/GameConfig.hpp (modified) (3 diffs)
-
CaWE/LoadSave_cmap.cpp (modified) (2 diffs)
-
CaWE/MapCommands/ModifyModel.cpp (modified) (2 diffs)
-
CaWE/MapHelperModel.cpp (modified) (8 diffs)
-
CaWE/MapHelperModel.hpp (modified) (3 diffs)
-
CaWE/MapModel.cpp (modified) (7 diffs)
-
CaWE/MapModel.hpp (modified) (3 diffs)
-
Libs/Models/ModelManager.cpp (added)
-
Libs/Models/ModelManager.hpp (added)
-
Libs/Models/Model_cmdl.cpp (modified) (1 diff)
-
Libs/Models/Model_cmdl.hpp (modified) (1 diff)
-
Libs/SConscript (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
cafu/trunk/CaWE/DialogInsp-PrimitiveProps.cpp
r285 r414 39 39 #include "wx/propgrid/advprops.h" 40 40 41 #include "Models/Model_cmdl.hpp" 41 42 #include "TypeSys.hpp" 42 43 … … 270 271 MapModelT* Model=(MapModelT*)SelectedPrimitives[i]; 271 272 272 PropMan->AppendIn(Cat, new GameFilePropertyT("Model", wxPG_LABEL, Model->m_Model .GetFileName(), MapDoc, "All Files (*.*)|*.*|Model files (*.mdl)|*.mdl|Model Files (*.ase)|*.ase|Model Files (*.dlod)|*.dlod", "/Models/"))->SetClientData(Model);273 PropMan->AppendIn(Cat, new GameFilePropertyT("Model", wxPG_LABEL, Model->m_Model->GetFileName(), MapDoc, "All Files (*.*)|*.*|Model files (*.mdl)|*.mdl|Model Files (*.ase)|*.ase|Model Files (*.dlod)|*.dlod", "/Models/"))->SetClientData(Model); 273 274 PropMan->AppendIn(Cat, new GameFilePropertyT("Collision Model", wxPG_LABEL, Model->m_CollModelFileName, MapDoc, "Collision Model (*.cmap)|*.cmap|All Files (*.*)|*.*", "/Models/"))->SetClientData(Model); 274 275 PropMan->AppendIn(Cat, new wxStringProperty ("Label", wxPG_LABEL, Model->m_Label))->SetClientData(Model); -
cafu/trunk/CaWE/GameConfig.cpp
r285 r414 250 250 251 251 252 const CafuModelT* GameConfigT::GetModel(const wxString& FileName, wxString* ErrorMsg) const 253 { 254 std::string Msg; 255 const CafuModelT* Model=m_ModelMan.GetModel(std::string(ModDir + "/" + FileName), Msg); 256 257 if (ErrorMsg) 258 *ErrorMsg=Msg; 259 260 return Model; 261 } 262 263 252 264 BoundingBox3fT GameConfigT::GetMaxMapBB() const 253 265 { -
cafu/trunk/CaWE/GameConfig.hpp
r285 r414 25 25 #include "EditorMaterialManager.hpp" 26 26 #include "Math3D/BoundingBox.hpp" 27 #include "Models/ModelManager.hpp" 27 28 #include "Templates/Array.hpp" 28 29 #include "wx/wx.h" … … 59 60 const EditorMatManT& GetMatMan() const { return m_MatMan; } 60 61 62 /// Returns the model for the given FileName that is relative to ModDir. 63 const CafuModelT* GetModel(const wxString& FileName, wxString* ErrorMsg=NULL) const; 64 61 65 int GetMaxMapCoord() const { return m_MaxMapCoord; } 62 66 int GetMinMapCoord() const { return -m_MaxMapCoord; } … … 84 88 void operator = (const GameConfigT&); ///< Use of the Assignment Operator is not allowed. 85 89 86 87 90 ArrayT<cf::FileSys::FileSystemT*> m_MountedFileSystems; ///< The file systems that have been mounted for this game config. 88 91 ArrayT<const EntityClassT*> m_EntityClasses; ///< The entity classes as obtained from the EntityClassDefs.lua script. 89 EditorMatManT m_MatMan; ///< This material manager of this game config. 92 EditorMatManT m_MatMan; ///< The material manager for this game config. 93 ModelManagerT m_ModelMan; ///< The model manager for this game config. 90 94 int m_MaxMapCoord; 91 95 }; -
cafu/trunk/CaWE/LoadSave_cmap.cpp
r285 r414 505 505 506 506 m_ModelFileName =TP.GetNextToken(); 507 m_Model =M odelProxyT(std::string(MapDoc.GetGameConfig()->ModDir+"/"+m_ModelFileName));507 m_Model =MapDoc.GetGameConfig()->GetModel(m_ModelFileName); 508 508 m_CollModelFileName=TP.GetNextToken(); 509 509 … … 690 690 { 691 691 // A model definition. 692 MapModelT* Model=new MapModelT( );692 MapModelT* Model=new MapModelT(MapDoc, "dummy", Vector3fT()); 693 693 694 694 Model->Load_cmap(TP, MapDoc); -
cafu/trunk/CaWE/MapCommands/ModifyModel.cpp
r285 r414 66 66 67 67 m_Model->m_ModelFileName =m_NewModelFileName; 68 m_Model->m_Model = ModelProxyT(std::string(m_MapDoc.GetGameConfig()->ModDir+"/"+m_NewModelFileName));68 m_Model->m_Model =m_MapDoc.GetGameConfig()->GetModel(m_NewModelFileName); 69 69 m_Model->m_CollModelFileName=m_NewCollModelFileName; 70 70 m_Model->m_Label =m_NewLabel; … … 96 96 97 97 m_Model->m_ModelFileName =m_OldModelFileName; 98 m_Model->m_Model = ModelProxyT(std::string(m_MapDoc.GetGameConfig()->ModDir+"/"+m_OldModelFileName));98 m_Model->m_Model =m_MapDoc.GetGameConfig()->GetModel(m_OldModelFileName); 99 99 m_Model->m_CollModelFileName=m_OldCollModelFileName; 100 100 m_Model->m_Label =m_OldLabel; -
cafu/trunk/CaWE/MapHelperModel.cpp
r408 r414 34 34 #include "Math3D/BoundingBox.hpp" 35 35 #include "Math3D/Matrix3x3.hpp" 36 #include "Models/Model_cmdl.hpp" 36 37 #include "EditorMaterialManager.hpp" 37 38 #include "MaterialSystem/Renderer.hpp" 38 39 #include "TypeSys.hpp" 39 40 40 #include "wx/wx.h"41 #include "wx/sstream.h"42 #include "wx/txtstrm.h"43 44 41 45 42 /*** Begin of TypeSys related definitions for this class. ***/ … … 58 55 : MapHelperT(ParentEntity), 59 56 m_HelperInfo(HelperInfo), 60 m_Model Proxy(),57 m_Model(NULL), 61 58 m_ModelFrameNr(0.0f), 62 59 m_Timer() … … 68 65 : MapHelperT(Model), 69 66 m_HelperInfo(Model.m_HelperInfo), 70 m_Model Proxy(Model.m_ModelProxy),67 m_Model(Model.m_Model), 71 68 m_ModelFrameNr(0.0f), 72 69 m_Timer(Model.m_Timer) … … 93 90 m_ParentEntity=Model->m_ParentEntity; 94 91 m_HelperInfo =Model->m_HelperInfo; 95 m_Model Proxy =Model->m_ModelProxy;92 m_Model =Model->m_Model; 96 93 m_ModelFrameNr=Model->m_ModelFrameNr; 97 94 m_Timer =Model->m_Timer; … … 110 107 // The 3D bounds are the bounds of the oriented model's first sequence, so that frustum culling works properly in the 3D view. 111 108 Vector3fT VerticesBB[8]; 112 m_Model Proxy.GetBB(GetSequenceNr(), 0.0f).GetCornerVertices(VerticesBB);109 m_Model->GetSharedPose(GetSequenceNr(), 0.0f)->GetBB().GetCornerVertices(VerticesBB); 113 110 114 111 // Rotate all eight vertices. … … 146 143 const Vector3fT ViewPoint=Renderer.GetViewWin3D().GetCamera().Pos; 147 144 const float ModelDist=length(Origin-ViewPoint); 145 AnimPoseT* Pose =m_Model->GetSharedPose(SequenceNr, m_ModelFrameNr); 148 146 149 147 if (Options.view3d.AnimateModels) 150 m_ModelFrameNr=m_ModelProxy.AdvanceFrameNr(SequenceNr, m_ModelFrameNr, float(m_Timer.GetSecondsSinceLastCall())); 148 { 149 Pose->Advance(float(m_Timer.GetSecondsSinceLastCall())); 150 151 m_ModelFrameNr=Pose->GetFrameNr(); 152 } 151 153 152 154 if (ModelDist < float(Options.view3d.ModelDistance)) … … 163 165 MatSys::Renderer->RotateX (MatSys::RendererI::MODEL_TO_WORLD, Angles[ROLL ]); 164 166 165 m_ModelProxy.Draw(SequenceNr, m_ModelFrameNr, CAFU_ENG_SCALE*ModelDist, NULL);167 Pose->Draw(-1 /*default skin*/, CAFU_ENG_SCALE*ModelDist); 166 168 167 169 MatSys::Renderer->PopMatrix(MatSys::RendererI::MODEL_TO_WORLD); … … 180 182 void MapHelperModelT::UpdateModelCache() const 181 183 { 182 const wxString* ModelName=m_HelperInfo->Parameters.Size()>0 ? &m_HelperInfo->Parameters[0] : NULL; 183 184 // If we weren't passed a model name as an argument, get it from our parent entity's "model" property. 185 if (ModelName==NULL) 186 { 184 wxString ModelName=""; 185 wxString ErrorMsg =""; 186 187 if (m_HelperInfo->Parameters.Size() > 0) 188 { 189 ModelName=m_HelperInfo->Parameters[0]; 190 } 191 else 192 { 193 // If we weren't passed a model name as an argument, get it from our parent entity's "model" property. 187 194 // Calling FindProperty() each render frame is not particularly efficient... 188 195 const EntPropertyT* ModelProp=m_ParentEntity->FindProperty("model"); 189 196 190 if (ModelProp) ModelName= &ModelProp->Value;191 } 192 193 // If the helper info has no argument and the parent has no "model" property, we shouldn't have gotten here.194 if (ModelName==NULL) return; 195 196 const wxString FullName=m_ParentEntity->GetClass()->GetGameConfig().ModDir+"/"+(*ModelName);197 198 if (m_ModelProxy.GetFileName()==FullName) return; 199 200 wxLogDebug("MapHelperModelT::UpdateModelCache(): Updating model from %s to %s.", m_ModelProxy.GetFileName(), FullName); 201 202 m_ModelProxy=ModelProxyT(std::string(FullName));203 m_ModelFrameNr=0.0f;197 if (ModelProp) ModelName=ModelProp->Value; 198 } 199 200 const CafuModelT* Model=m_ParentEntity->GetClass()->GetGameConfig().GetModel(ModelName, &ErrorMsg); 201 202 if (m_Model!=Model) 203 { 204 const std::string PrevFileName=m_Model ? m_Model->GetFileName() : "<none>"; 205 206 wxLogDebug("MapHelperModelT::UpdateModelCache(): Updating model from %s to %s. %s", PrevFileName, Model->GetFileName(), ErrorMsg); 207 208 m_Model =Model; 209 m_ModelFrameNr=0.0f; 210 } 204 211 } 205 212 -
cafu/trunk/CaWE/MapHelperModel.hpp
r285 r414 24 24 25 25 #include "MapHelper.hpp" 26 #include "Models/Model_proxy.hpp"27 26 #include "Util/Util.hpp" 28 27 … … 32 31 class Renderer2DT; 33 32 class Renderer3DT; 33 34 class CafuModelT; 34 35 namespace cf { namespace TypeSys { class TypeInfoT; } } 35 36 namespace cf { namespace TypeSys { class TypeInfoManT; } } … … 70 71 int GetSequenceNr() const; 71 72 72 const HelperInfoT* m_HelperInfo;///< The HelperInfoT instance that caused the instantiation of this helper.73 mutable ModelProxyT m_ModelProxy; ///< Our model (proxy).74 mutable float m_ModelFrameNr;///< The frame number of the sequence to render this model in.75 mutable TimerT m_Timer;73 const HelperInfoT* m_HelperInfo; ///< The HelperInfoT instance that caused the instantiation of this helper. 74 mutable const CafuModelT* m_Model; ///< Our model (obtained from the game config's model manager). 75 mutable float m_ModelFrameNr; ///< The frame number of the sequence to render this model in. 76 mutable TimerT m_Timer; 76 77 }; 77 78 -
cafu/trunk/CaWE/MapModel.cpp
r408 r414 32 32 33 33 #include "MaterialSystem/Renderer.hpp" 34 #include "MaterialSystem/Mesh.hpp"35 34 #include "Math3D/Matrix3x3.hpp" 35 #include "Models/Model_cmdl.hpp" 36 36 37 37 #include "wx/wx.h" … … 48 48 49 49 /*** End of TypeSys related definitions for this class. ***/ 50 51 52 MapModelT::MapModelT()53 : MapPrimitiveT(wxColour(150 + (rand() % 106), 150 + (rand() % 106), 0)),54 m_ModelFileName(""),55 m_Model(),56 m_CollModelFileName(""),57 m_Label(""),58 m_Angles(),59 m_Scale(1.0f),60 m_SeqNumber(0),61 m_FrameOffset(0.0f),62 m_FrameTimeScale(1.0f),63 m_FrameNumber(0.0f),64 m_Animated(false),65 m_Timer()66 {67 }68 50 69 51 … … 71 53 : MapPrimitiveT(wxColour(150 + (rand() % 106), 150 + (rand() % 106), 0)), 72 54 m_ModelFileName(ModelFileName), 73 m_Model( std::string(MapDoc.GetGameConfig()->ModDir+"/"+ModelFileName)),55 m_Model(MapDoc.GetGameConfig()->GetModel(m_ModelFileName)), 74 56 m_Origin(Position), 75 57 m_CollModelFileName(""), … … 90 72 : MapPrimitiveT(wxColour(150 + (rand() % 106), 150 + (rand() % 106), 0)), 91 73 m_ModelFileName(ModelFileName), 92 m_Model( std::string(MapDoc.GetGameConfig()->ModDir+"/"+m_ModelFileName)),74 m_Model(MapDoc.GetGameConfig()->GetModel(m_ModelFileName)), 93 75 m_Origin(Position), 94 76 m_CollModelFileName(CollisionModelFileName), … … 160 142 // The 3D bounds are the bounds of the oriented model's first sequence, so that frustum culling works properly in the 3D view. 161 143 Vector3fT VerticesBB[8]; 162 m_Model .GetBB(m_SeqNumber, 0.0f).GetCornerVertices(VerticesBB);144 m_Model->GetSharedPose(m_SeqNumber, 0.0f)->GetBB().GetCornerVertices(VerticesBB); 163 145 164 146 // Rotate all eight vertices. … … 205 187 const Vector3fT ViewPoint=Renderer.GetViewWin3D().GetCamera().Pos; 206 188 const float ModelDist=length(m_Origin-ViewPoint); 189 AnimPoseT* Pose =m_Model->GetSharedPose(m_SeqNumber, m_FrameNumber); 207 190 208 191 if (Options.view3d.AnimateModels && m_Animated) 209 m_FrameNumber=m_Model.AdvanceFrameNr(m_SeqNumber, m_FrameNumber, float(m_Timer.GetSecondsSinceLastCall())*m_FrameTimeScale); 192 { 193 Pose->Advance(float(m_Timer.GetSecondsSinceLastCall())*m_FrameTimeScale); 194 195 m_FrameNumber=Pose->GetFrameNr(); 196 } 210 197 211 198 if (ModelDist<float(Options.view3d.ModelDistance)) … … 222 209 MatSys::Renderer->Scale (MatSys::RendererI::MODEL_TO_WORLD, m_Scale); 223 210 224 m_Model.Draw(m_SeqNumber, m_FrameNumber, CAFU_ENG_SCALE*ModelDist, NULL);211 Pose->Draw(-1 /*default skin*/, CAFU_ENG_SCALE*ModelDist); 225 212 226 213 MatSys::Renderer->PopMatrix(MatSys::RendererI::MODEL_TO_WORLD); -
cafu/trunk/CaWE/MapModel.hpp
r285 r414 24 24 25 25 #include "MapPrimitive.hpp" 26 27 #include "Models/Model_proxy.hpp"28 26 #include "Util/Util.hpp" 29 27 30 28 31 29 class MapDocumentT; 30 class CafuModelT; 32 31 33 32 … … 36 35 public: 37 36 38 MapModelT();39 40 37 MapModelT(MapDocumentT& MapDoc, const wxString& ModelFileName, const Vector3fT& Position); 41 42 38 MapModelT(MapDocumentT& MapDoc, const wxString& ModelFileName, const wxString& CollisionModelFileName, const wxString& Label, const Vector3fT& Position, const Vector3fT& Angles, float Scale, int Sequence, float FrameOffset, float FrameTimeScale, bool Animated); 43 39 … … 83 79 84 80 wxString m_ModelFileName; 85 ModelProxyTm_Model;81 const CafuModelT* m_Model; 86 82 Vector3fT m_Origin; 87 83 wxString m_CollModelFileName; -
cafu/trunk/Libs/Models/Model_cmdl.cpp
r406 r414 353 353 return IsMeshNrOK(GF, PointNr) && 354 354 GF.Points[PointNr].VertexNr < m_Meshes[GF.Points[PointNr].MeshNr].Vertices.Size(); 355 } 356 357 358 AnimPoseT* CafuModelT::GetSharedPose(int SequNr, float FrameNr) const 359 { 360 m_TEMP_Pose->SetSequNr(SequNr); 361 m_TEMP_Pose->SetFrameNr(FrameNr); 362 363 return m_TEMP_Pose; 355 364 } 356 365 -
cafu/trunk/Libs/Models/Model_cmdl.hpp
r412 r414 275 275 bool IsVertexNrOK(const GuiFixtureT& GF, unsigned int PointNr) const; 276 276 277 /// This method is strictly for backwards-compatibility only, do not use in new code! 278 AnimPoseT* GetSharedPose(int SequNr, float FrameNr) const; 279 277 280 // The ModelT interface. 278 281 const std::string& GetFileName() const; // TODO: Remove!?! -
cafu/trunk/Libs/SConscript
r410 r414 15 15 Models/Loader.cpp Models/Loader_ase.cpp Models/Loader_cmdl.cpp Models/Loader_dlod.cpp Models/Loader_dummy.cpp Models/Loader_lwo.cpp Models/Loader_md5.cpp 16 16 Models/Loader_mdl.cpp Models/AnimPose.cpp 17 Models/Model_cmdl.cpp Models/Model_proxy.cpp 17 Models/Model_cmdl.cpp Models/Model_proxy.cpp Models/ModelManager.cpp 18 18 Network/Network.cpp ParticleEngine/ParticleEngineMS.cpp PlatformAux.cpp Terrain/Terrain.cpp 19 19 TextParser/TextParser.cpp
