Changeset 469
- Timestamp:
- 01/19/12 11:44:44 (4 months ago)
- Location:
- cafu/trunk
- Files:
-
- 32 modified
-
CaWE/DialogInsp-PrimitiveProps.cpp (modified) (2 diffs)
-
CaWE/LoadSave_cmap.cpp (modified) (3 diffs)
-
CaWE/MapCommands/ModifyModel.cpp (modified) (4 diffs)
-
CaWE/MapCommands/ModifyModel.hpp (modified) (3 diffs)
-
CaWE/MapHelperModel.cpp (modified) (6 diffs)
-
CaWE/MapHelperModel.hpp (modified) (2 diffs)
-
CaWE/MapModel.cpp (modified) (6 diffs)
-
CaWE/MapModel.hpp (modified) (2 diffs)
-
CaWE/ModelEditor/ModelDocument.cpp (modified) (3 diffs)
-
CaWE/ModelEditor/ModelDocument.hpp (modified) (1 diff)
-
Games/DeathMatch/Code/ARGrenade.cpp (modified) (1 diff)
-
Games/DeathMatch/Code/Butterfly.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/CompanyBot.cpp (modified) (6 diffs)
-
Games/DeathMatch/Code/CompanyBot.hpp (modified) (2 diffs)
-
Games/DeathMatch/Code/Corpse.cpp (modified) (1 diff)
-
Games/DeathMatch/Code/Eagle.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/FaceHugger.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/HandGrenade.cpp (modified) (1 diff)
-
Games/DeathMatch/Code/HumanPlayer.cpp (modified) (7 diffs)
-
Games/DeathMatch/Code/Item.cpp (modified) (1 diff)
-
Games/DeathMatch/Code/Rocket.cpp (modified) (1 diff)
-
Games/DeathMatch/Code/StaticDetailModel.cpp (modified) (4 diffs)
-
Games/DeathMatch/Code/Weapon.cpp (modified) (1 diff)
-
Libs/GuiSys/WindowModel.cpp (modified) (6 diffs)
-
Libs/GuiSys/WindowModel.hpp (modified) (2 diffs)
-
Libs/Models/AnimExpr.hpp (modified) (1 diff)
-
Libs/Models/AnimPose.cpp (modified) (3 diffs)
-
Libs/Models/AnimPose.hpp (modified) (3 diffs)
-
Libs/Models/Model_cmdl.cpp (modified) (2 diffs)
-
Libs/Models/Model_cmdl.hpp (modified) (1 diff)
-
Libs/SceneGraph/ModelNode.cpp (modified) (6 diffs)
-
Libs/SceneGraph/ModelNode.hpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cafu/trunk/CaWE/DialogInsp-PrimitiveProps.cpp
r455 r469 280 280 m_PropMan->AppendIn(Cat, new wxStringProperty ("Label", wxPG_LABEL, Model->m_Label))->SetClientData(Model); 281 281 m_PropMan->AppendIn(Cat, new wxFloatProperty ("Scale", wxPG_LABEL, Model->m_Scale))->SetClientData(Model); 282 m_PropMan->AppendIn(Cat, new wxIntProperty ("Sequence Number", wxPG_LABEL, Model->m_ SeqNumber))->SetClientData(Model);282 m_PropMan->AppendIn(Cat, new wxIntProperty ("Sequence Number", wxPG_LABEL, Model->m_AnimExpr->GetSequNr()))->SetClientData(Model); 283 283 m_PropMan->AppendIn(Cat, new wxFloatProperty ("Frame Offset", wxPG_LABEL, Model->m_FrameOffset))->SetClientData(Model); 284 284 m_PropMan->AppendIn(Cat, new wxFloatProperty ("Frame Scale", wxPG_LABEL, Model->m_FrameTimeScale))->SetClientData(Model); … … 368 368 369 369 if (PropName=="Model") 370 Command=new CommandModifyModelT(*m_MapDoc, Model, Prop->GetValueAsString(), Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Model->m_ SeqNumber, Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated);370 Command=new CommandModifyModelT(*m_MapDoc, Model, Prop->GetValueAsString(), Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Model->m_AnimExpr, Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated); 371 371 else if (PropName=="Collision Model") 372 Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Prop->GetValueAsString(), Model->m_Label, Model->m_Scale, Model->m_ SeqNumber, Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated);372 Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Prop->GetValueAsString(), Model->m_Label, Model->m_Scale, Model->m_AnimExpr, Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated); 373 373 else if (PropName=="Label") 374 Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Prop->GetValueAsString(), Model->m_Scale, Model->m_ SeqNumber, Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated);374 Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Prop->GetValueAsString(), Model->m_Scale, Model->m_AnimExpr, Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated); 375 375 else if (PropName=="Scale") 376 Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, PropValueF, Model->m_ SeqNumber, Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated);376 Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, PropValueF, Model->m_AnimExpr, Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated); 377 377 else if (PropName=="Sequence Number") 378 Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Prop->GetValue().GetLong(), Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated);378 Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Model->m_Model->GetAnimExprPool().GetStandard(Prop->GetValue().GetLong(), 0.0f), Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated); 379 379 else if (PropName=="Frame Offset") 380 Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Model->m_ SeqNumber, PropValueF, Model->m_FrameTimeScale, Model->m_Animated);380 Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Model->m_AnimExpr, PropValueF, Model->m_FrameTimeScale, Model->m_Animated); 381 381 else if (PropName=="Frame Scale") 382 Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Model->m_ SeqNumber, Model->m_FrameOffset, PropValueF, Model->m_Animated);382 Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Model->m_AnimExpr, Model->m_FrameOffset, PropValueF, Model->m_Animated); 383 383 else if (PropName=="Animated") 384 Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Model->m_ SeqNumber, Model->m_FrameOffset, Model->m_FrameTimeScale, Prop->GetValue().GetBool());384 Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Model->m_AnimExpr, Model->m_FrameOffset, Model->m_FrameTimeScale, Prop->GetValue().GetBool()); 385 385 386 386 if (Command) -
cafu/trunk/CaWE/LoadSave_cmap.cpp
r455 r469 36 36 37 37 #include "Math3D/Plane3.hpp" 38 #include "Models/Model_cmdl.hpp" 38 39 #include "TextParser/TextParser.hpp" 39 40 #include "SceneGraph/LightMapMan.hpp" … … 523 524 524 525 m_Scale =TP.GetNextTokenAsFloat(); 525 m_SeqNumber=TP.GetNextTokenAsInt();526 const int SequNr=TP.GetNextTokenAsInt(); 526 527 m_FrameOffset =TP.GetNextTokenAsFloat(); 527 528 m_FrameTimeScale=TP.GetNextTokenAsFloat(); 528 m_FrameNumber =m_FrameOffset;529 529 m_Animated =TP.GetNextTokenAsInt()!=0; 530 530 531 m_AnimExpr=m_Model->GetAnimExprPool().GetStandard(SequNr, m_FrameOffset); 531 532 TP.AssertAndSkipToken("}"); 532 533 } … … 547 548 548 549 OutFile << serialize(m_Scale) << " "; 549 OutFile << m_ SeqNumber<< " ";550 OutFile << m_AnimExpr->GetSequNr() << " "; 550 551 OutFile << serialize(m_FrameOffset) << " "; 551 552 OutFile << serialize(m_FrameTimeScale) << " "; -
cafu/trunk/CaWE/MapCommands/ModifyModel.cpp
r455 r469 30 30 31 31 32 CommandModifyModelT::CommandModifyModelT(MapDocumentT& MapDoc, MapModelT* Model, const wxString& ModelFileName, const wxString& CollisionModelFileName, const wxString& Label, float Scale, int Sequence, float FrameTimeOff, float FrameTimeScale, bool Animated) 32 CommandModifyModelT::CommandModifyModelT(MapDocumentT& MapDoc, MapModelT* Model, const wxString& ModelFileName, 33 const wxString& CollisionModelFileName, const wxString& Label, float Scale, 34 IntrusivePtrT<AnimExprStandardT> AnimExpr, float FrameTimeOff, float FrameTimeScale, bool Animated) 33 35 : m_MapDoc(MapDoc), 34 36 m_Model(Model), … … 41 43 m_NewScale(Scale), 42 44 m_OldScale(Model->m_Scale), 43 m_New Sequence(Sequence),44 m_Old Sequence(Model->m_SeqNumber),45 m_NewAnimExpr(AnimExpr), 46 m_OldAnimExpr(Model->m_AnimExpr), 45 47 m_NewFrameTimeOff(FrameTimeOff), 46 48 m_OldFrameTimeOff(Model->m_FrameOffset), … … 70 72 m_Model->m_Label =m_NewLabel; 71 73 m_Model->m_Scale =m_NewScale; 72 m_Model->m_SeqNumber =m_NewSequence; 73 m_Model->m_FrameNumber =m_Model->m_FrameNumber-m_Model->m_FrameOffset+m_NewFrameTimeOff; 74 m_Model->m_AnimExpr =m_NewAnimExpr; 74 75 m_Model->m_FrameOffset =m_NewFrameTimeOff, 75 76 m_Model->m_FrameTimeScale =m_NewFrameTimeScale, … … 100 101 m_Model->m_Label =m_OldLabel; 101 102 m_Model->m_Scale =m_OldScale; 102 m_Model->m_SeqNumber =m_OldSequence; 103 m_Model->m_FrameNumber =m_Model->m_FrameNumber-m_Model->m_FrameOffset+m_OldFrameTimeOff; 103 m_Model->m_AnimExpr =m_OldAnimExpr; 104 104 m_Model->m_FrameOffset =m_OldFrameTimeOff, 105 105 m_Model->m_FrameTimeScale =m_OldFrameTimeScale, -
cafu/trunk/CaWE/MapCommands/ModifyModel.hpp
r457 r469 24 24 25 25 #include "../CommandPattern.hpp" 26 #include "Models/AnimExpr.hpp" 26 27 27 28 … … 34 35 public: 35 36 36 CommandModifyModelT(MapDocumentT& MapDoc, MapModelT* Model, const wxString& ModelFileName, const wxString& CollisionModelFileName, const wxString& Label, float Scale, int Sequence, float FrameTimeOff, float FrameTimeScale, bool Animated); 37 CommandModifyModelT(MapDocumentT& MapDoc, MapModelT* Model, const wxString& ModelFileName, 38 const wxString& CollisionModelFileName, const wxString& Label, float Scale, 39 IntrusivePtrT<AnimExprStandardT> AnimExpr, float FrameTimeOff, float FrameTimeScale, bool Animated); 37 40 38 41 // CommandT implementation. … … 44 47 private: 45 48 46 MapDocumentT& m_MapDoc;47 MapModelT* m_Model;48 const wxString m_NewModelFileName;49 const wxString m_OldModelFileName;50 const wxString m_NewCollModelFileName;51 const wxString m_OldCollModelFileName;52 const wxString m_NewLabel;53 const wxString m_OldLabel;54 float m_NewScale;55 float m_OldScale;56 int m_NewSequence;57 int m_OldSequence;58 float m_NewFrameTimeOff;59 float m_OldFrameTimeOff;60 float m_NewFrameTimeScale;61 float m_OldFrameTimeScale;62 bool m_NewAnimated;63 bool m_OldAnimated;49 MapDocumentT& m_MapDoc; 50 MapModelT* m_Model; 51 const wxString m_NewModelFileName; 52 const wxString m_OldModelFileName; 53 const wxString m_NewCollModelFileName; 54 const wxString m_OldCollModelFileName; 55 const wxString m_NewLabel; 56 const wxString m_OldLabel; 57 float m_NewScale; 58 float m_OldScale; 59 IntrusivePtrT<AnimExprStandardT> m_NewAnimExpr; 60 IntrusivePtrT<AnimExprStandardT> m_OldAnimExpr; 61 float m_NewFrameTimeOff; 62 float m_OldFrameTimeOff; 63 float m_NewFrameTimeScale; 64 float m_OldFrameTimeScale; 65 bool m_NewAnimated; 66 bool m_OldAnimated; 64 67 }; 65 68 -
cafu/trunk/CaWE/MapHelperModel.cpp
r455 r469 56 56 m_HelperInfo(HelperInfo), 57 57 m_Model(NULL), 58 m_ModelFrameNr(0.0f), 58 m_AnimExpr(), 59 m_LastStdAE(), 59 60 m_GuiNames(), 60 61 m_Guis(), … … 67 68 : MapHelperT(Model), 68 69 m_HelperInfo(Model.m_HelperInfo), 69 m_Model(Model.m_Model), 70 m_ModelFrameNr(0.0f), 70 m_Model(NULL), // Don't start with Model.m_Model, so that m_AnimExpr and m_LastStdAE are properly inited in UpdateModelCache(). 71 m_AnimExpr(), 72 m_LastStdAE(), 71 73 m_GuiNames(), 72 74 m_Guis(), … … 100 102 m_ParentEntity=Model->m_ParentEntity; 101 103 m_HelperInfo =Model->m_HelperInfo; 102 m_Model =Model->m_Model; 103 m_ModelFrameNr=Model->m_ModelFrameNr; 104 m_Model =NULL; // Don't assign Model->m_Model, so that m_AnimExpr and m_LastStdAE are properly inited in UpdateModelCache(). 105 m_AnimExpr =NULL; 106 m_LastStdAE =NULL; 104 107 m_Timer =Model->m_Timer; 105 108 … … 119 122 // The 3D bounds are the bounds of the oriented model's first sequence, so that frustum culling works properly in the 3D view. 120 123 Vector3fT VerticesBB[8]; 121 m_Model->GetSharedPose( GetSequenceNr(), 0.0f)->GetBB().GetCornerVertices(VerticesBB);124 m_Model->GetSharedPose(m_AnimExpr)->GetBB().GetCornerVertices(VerticesBB); 122 125 123 126 // Rotate all eight vertices. … … 153 156 UpdateModelCache(); 154 157 158 if (SequenceNr!=m_LastStdAE->GetSequNr()) 159 { 160 if (Options.view3d.AnimateModels) 161 { 162 IntrusivePtrT<AnimExpressionT> BlendFrom=m_AnimExpr; 163 164 m_LastStdAE=m_Model->GetAnimExprPool().GetStandard(SequenceNr, 0.0f); 165 m_AnimExpr =m_Model->GetAnimExprPool().GetBlend(BlendFrom, m_LastStdAE, 3.0f); 166 } 167 else 168 { 169 m_LastStdAE=m_Model->GetAnimExprPool().GetStandard(SequenceNr, 0.0f); 170 m_AnimExpr =m_LastStdAE; 171 } 172 } 173 174 if (Options.view3d.AnimateModels) 175 { 176 m_AnimExpr->AdvanceTime(float(m_Timer.GetSecondsSinceLastCall())); 177 } 178 155 179 const Vector3fT ViewPoint=Renderer.GetViewWin3D().GetCamera().Pos; 156 180 const float ModelDist=length(Origin-ViewPoint); 157 AnimPoseT* Pose =m_Model->GetSharedPose(SequenceNr, m_ModelFrameNr); 158 159 if (Options.view3d.AnimateModels) 160 { 161 Pose->Advance(float(m_Timer.GetSecondsSinceLastCall())); 162 163 m_ModelFrameNr=Pose->GetFrameNr(); 164 } 181 AnimPoseT* Pose =m_Model->GetSharedPose(m_AnimExpr); 165 182 166 183 if (ModelDist < float(Options.view3d.ModelDistance)) … … 256 273 wxLogDebug("MapHelperModelT::UpdateModelCache(): Updating model from %s to %s. %s", PrevFileName, Model->GetFileName(), ErrorMsg); 257 274 258 m_Model =Model; 259 m_ModelFrameNr=0.0f; 275 m_Model =Model; 276 m_LastStdAE=m_Model->GetAnimExprPool().GetStandard(GetSequenceNr(), 0.0f); 277 m_AnimExpr =m_LastStdAE; 260 278 261 279 ClearGuis(); -
cafu/trunk/CaWE/MapHelperModel.hpp
r457 r469 24 24 25 25 #include "MapHelper.hpp" 26 #include "Models/AnimExpr.hpp" 26 27 #include "Util/Util.hpp" 27 28 … … 76 77 int GetSequenceNr() const; 77 78 78 const HelperInfoT* m_HelperInfo; ///< The HelperInfoT instance that caused the instantiation of this helper. 79 mutable const CafuModelT* m_Model; ///< Our model (obtained from the game config's model manager). 80 mutable float m_ModelFrameNr; ///< The frame number of the sequence to render this model in. 81 mutable ArrayT<wxString> m_GuiNames; ///< The names of the GUIs in m_Guis. 82 mutable ArrayT<cf::GuiSys::GuiImplT*> m_Guis; ///< The GUIs that are rendered where the model has GUI fixtures. 83 mutable TimerT m_Timer; 79 const HelperInfoT* m_HelperInfo; ///< The HelperInfoT instance that caused the instantiation of this helper. 80 mutable const CafuModelT* m_Model; ///< Our model (obtained from the game config's model manager). 81 mutable IntrusivePtrT<AnimExpressionT> m_AnimExpr; ///< The current expression used for configuring the pose of the model. 82 mutable IntrusivePtrT<AnimExprStandardT> m_LastStdAE; ///< The most recent standard expression that we set (as a subexpression of m_AnimExpr). 83 mutable ArrayT<wxString> m_GuiNames; ///< The names of the GUIs in m_Guis. 84 mutable ArrayT<cf::GuiSys::GuiImplT*> m_Guis; ///< The GUIs that are rendered where the model has GUI fixtures. 85 mutable TimerT m_Timer; 84 86 }; 85 87 -
cafu/trunk/CaWE/MapModel.cpp
r455 r469 59 59 m_Angles(), 60 60 m_Scale(1.0f), 61 m_ SeqNumber(0),61 m_AnimExpr(m_Model->GetAnimExprPool().GetStandard(0, 0.0f)), 62 62 m_FrameOffset(0.0f), 63 63 m_FrameTimeScale(1.0f), 64 m_FrameNumber(0.0f),65 64 m_Animated(false), 66 65 m_Timer() … … 78 77 m_Angles(Angles), 79 78 m_Scale(Scale), 80 m_ SeqNumber(Sequence),79 m_AnimExpr(), 81 80 m_FrameOffset(FrameOffset), 82 81 m_FrameTimeScale(FrameTimeScale), 83 m_FrameNumber(m_FrameOffset),84 82 m_Animated(Animated), 85 83 m_Timer() 86 84 { 85 m_AnimExpr=m_Model->GetAnimExprPool().GetStandard(Sequence, m_FrameOffset); 87 86 } 88 87 … … 96 95 m_Angles(Model.m_Angles), 97 96 m_Scale(Model.m_Scale), 98 m_ SeqNumber(Model.m_SeqNumber),97 m_AnimExpr(dynamic_cast<AnimExprStandardT*>(Model.m_AnimExpr->Clone().get())), 99 98 m_FrameOffset(Model.m_FrameOffset), 100 99 m_FrameTimeScale(Model.m_FrameTimeScale), 101 m_FrameNumber(Model.m_FrameNumber),102 100 m_Animated(Model.m_Animated), 103 101 m_Timer() … … 128 126 m_Angles =Model->m_Angles; 129 127 m_Scale =Model->m_Scale; 130 m_ SeqNumber =Model->m_SeqNumber;128 m_AnimExpr =dynamic_cast<AnimExprStandardT*>(Model->m_AnimExpr->Clone().get()); 131 129 m_FrameOffset =Model->m_FrameOffset; 132 130 m_FrameTimeScale =Model->m_FrameTimeScale; 133 m_FrameNumber =Model->m_FrameNumber;134 131 m_Animated =Model->m_Animated; 135 132 m_Timer =Model->m_Timer; … … 142 139 // The 3D bounds are the bounds of the oriented model's first sequence, so that frustum culling works properly in the 3D view. 143 140 Vector3fT VerticesBB[8]; 144 m_Model->GetSharedPose(m_ SeqNumber, 0.0f)->GetBB().GetCornerVertices(VerticesBB);141 m_Model->GetSharedPose(m_AnimExpr)->GetBB().GetCornerVertices(VerticesBB); 145 142 146 143 // Rotate all eight vertices. … … 187 184 const Vector3fT ViewPoint=Renderer.GetViewWin3D().GetCamera().Pos; 188 185 const float ModelDist=length(m_Origin-ViewPoint); 189 AnimPoseT* Pose =m_Model->GetSharedPose(m_ SeqNumber, m_FrameNumber);186 AnimPoseT* Pose =m_Model->GetSharedPose(m_AnimExpr); 190 187 191 188 if (Options.view3d.AnimateModels && m_Animated) 192 189 { 193 Pose->Advance(float(m_Timer.GetSecondsSinceLastCall())*m_FrameTimeScale); 194 195 m_FrameNumber=Pose->GetFrameNr(); 190 m_AnimExpr->AdvanceTime(float(m_Timer.GetSecondsSinceLastCall())*m_FrameTimeScale); 196 191 } 197 192 -
cafu/trunk/CaWE/MapModel.hpp
r457 r469 24 24 25 25 #include "MapPrimitive.hpp" 26 #include "Models/AnimExpr.hpp" 26 27 #include "Util/Util.hpp" 27 28 … … 85 86 cf::math::AnglesfT m_Angles; 86 87 float m_Scale; 87 int m_SeqNumber;88 mutable IntrusivePtrT<AnimExprStandardT> m_AnimExpr; ///< The current expression used for configuring the pose of the model. 88 89 float m_FrameOffset; 89 90 float m_FrameTimeScale; 90 mutable float m_FrameNumber;91 91 bool m_Animated; 92 92 mutable TimerT m_Timer; -
cafu/trunk/CaWE/ModelEditor/ModelDocument.cpp
r464 r469 40 40 41 41 42 ModelEditor::ModelDocumentT::AnimStateT::AnimStateT(const CafuModelT& Model) 43 : LastStdAE(Model.GetAnimExprPool().GetStandard(-1, 0.0f)), 44 Pose(Model, LastStdAE), 45 Speed(1.0f), 46 Loop(true) 47 { 48 } 49 50 42 51 ModelEditor::ModelDocumentT::SubmodelT::SubmodelT(CafuModelT* Submodel) 43 52 : m_Submodel(Submodel), 44 m_Pose(*Submodel, -1, 0.0f)53 m_Pose(*Submodel, Submodel->GetAnimExprPool().GetStandard(-1, 0.0f)) 45 54 { 46 55 } … … 152 161 } 153 162 154 m_AnimState.LastStdAE=m_ AnimState.Pool.GetStandard(m_Selection[ANIM].Size()==0 ? -1 : m_Selection[ANIM][0], 0.0f);155 m_AnimState.Pose.SetAnimExpr(m_ AnimState.Pool.GetBlend(BlendFrom, m_AnimState.LastStdAE, 3.0f));163 m_AnimState.LastStdAE=m_Model->GetAnimExprPool().GetStandard(m_Selection[ANIM].Size()==0 ? -1 : m_Selection[ANIM][0], 0.0f); 164 m_AnimState.Pose.SetAnimExpr(m_Model->GetAnimExprPool().GetBlend(BlendFrom, m_AnimState.LastStdAE, 3.0f)); 156 165 157 166 if (m_Selection[ANIM].Size()==0) … … 228 237 if (Time*m_AnimState.Speed!=0.0f) 229 238 { 230 m_AnimState.Pose. Advance(Time*m_AnimState.Speed, m_AnimState.Loop);239 m_AnimState.Pose.GetAnimExpr()->AdvanceTime(Time*m_AnimState.Speed, m_AnimState.Loop); 231 240 } 232 241 } -
cafu/trunk/CaWE/ModelEditor/ModelDocument.hpp
r457 r469 64 64 public: 65 65 66 AnimStateT(const CafuModelT& Model) 67 : Pool(Model), LastStdAE(Pool.GetStandard(-1, 0.0f)), Pose(Model, LastStdAE), Speed(1.0f), Loop(true) { } 66 AnimStateT(const CafuModelT& Model); 68 67 69 AnimExprPoolT Pool; 70 IntrusivePtrT<AnimExprStandardT> LastStdAE; 68 IntrusivePtrT<AnimExprStandardT> LastStdAE; ///< The last (most recent) "standard" anim expression that we set in the anim pose. 71 69 AnimPoseT Pose; ///< The current pose of the model, as defined by sequence and frame number. 72 70 float Speed; ///< The speed (relative to clock time) with which the animation is advanced, usually 0 for stop or 1 for playback. -
cafu/trunk/Games/DeathMatch/Code/ARGrenade.cpp
r455 r469 270 270 // glTranslatef(0.0, 0.0, 4.0); 271 271 272 AnimPoseT* Pose=m_Model->GetSharedPose( State.ModelSequNr, State.ModelFrameNr);272 AnimPoseT* Pose=m_Model->GetSharedPose(m_Model->GetAnimExprPool().GetStandard(State.ModelSequNr, State.ModelFrameNr)); 273 273 Pose->Draw(-1 /*default skin*/, LodDist); 274 274 } -
cafu/trunk/Games/DeathMatch/Code/Butterfly.cpp
r455 r469 90 90 void EntButterflyT::Draw(bool /*FirstPersonView*/, float LodDist) const 91 91 { 92 AnimPoseT* Pose=m_Model->GetSharedPose( State.ModelSequNr, State.ModelFrameNr);92 AnimPoseT* Pose=m_Model->GetSharedPose(m_Model->GetAnimExprPool().GetStandard(State.ModelSequNr, State.ModelFrameNr)); 93 93 Pose->Draw(-1 /*default skin*/, LodDist); 94 94 } … … 98 98 { 99 99 // Implicit simple "mini-prediction". 100 AnimPoseT* Pose=m_Model->GetSharedPose(State.ModelSequNr, State.ModelFrameNr); 101 Pose->Advance(FrameTime, true); 102 State.ModelFrameNr=Pose->GetFrameNr(); 100 IntrusivePtrT<AnimExprStandardT> AnimExpr=m_Model->GetAnimExprPool().GetStandard(State.ModelSequNr, State.ModelFrameNr); 101 102 AnimExpr->AdvanceTime(FrameTime, true); 103 State.ModelFrameNr=AnimExpr->GetFrameNr(); 103 104 } -
cafu/trunk/Games/DeathMatch/Code/CompanyBot.cpp
r455 r469 77 77 0.0)), // ActiveWeaponFrameNr 78 78 m_CompanyBotModel(Params.GameWorld->GetModel("Games/DeathMatch/Models/Players/Trinity.mdl")), 79 m_AnimExpr(), 80 m_LastStdAE(), 79 81 m_WeaponModel(Params.GameWorld->GetModel("Games/DeathMatch/Models/Weapons/DesertEagle_p.mdl")), 80 82 m_TimeForLightSource(0.0f) 81 83 { 84 m_LastStdAE=m_CompanyBotModel->GetAnimExprPool().GetStandard(State.ModelSequNr, State.ModelFrameNr); 85 m_AnimExpr =m_LastStdAE; 86 82 87 // Wir könnten im Boden stecken oder darüber schweben - korrigiere entsprechend! 83 88 // If multiple solid entities are stacked upon each other, this code might leave gaps between them, … … 196 201 Physics::MoveHuman(State, ClipModel, FrameTime, VectorT(), VectorT(), false, DummyOldWishJump, 0.0, GameWorld->GetClipWorld()); 197 202 198 AnimPoseT* Pose=m_CompanyBotModel->GetSharedPose(State.ModelSequNr, State.ModelFrameNr); 199 Pose->Advance(FrameTime); 200 State.ModelFrameNr=Pose->GetFrameNr(); 203 AdvanceModelTime(FrameTime, false); 201 204 202 205 // As we're in "dead" state, the ClipModel is no longer registered with the clip world, … … 260 263 double NewSpeed=length(XYVel); 261 264 262 AnimPoseT* Pose=m_CompanyBotModel->GetSharedPose(State.ModelSequNr, State.ModelFrameNr); 263 Pose->Advance(FrameTime, true); 264 State.ModelFrameNr=Pose->GetFrameNr(); 265 AdvanceModelTime(FrameTime, true); 265 266 266 267 if (OldSpeed<1000 && NewSpeed>1000) { State.ModelSequNr=3; State.ModelFrameNr=0.0; } … … 349 350 MatSys::Renderer->Translate(MatSys::RendererI::MODEL_TO_WORLD, 0.0f, 0.0f, -32.0f); 350 351 351 AnimPoseT* Pose=m_CompanyBotModel->GetSharedPose( State.ModelSequNr, State.ModelFrameNr);352 AnimPoseT* Pose=m_CompanyBotModel->GetSharedPose(m_AnimExpr); 352 353 Pose->Draw(-1 /*default skin*/, LodDist); 353 354 354 AnimPoseT* WeaponPose=m_WeaponModel->GetSharedPose( 0, 0.0f);355 AnimPoseT* WeaponPose=m_WeaponModel->GetSharedPose(m_WeaponModel->GetAnimExprPool().GetStandard(0, 0.0f)); 355 356 WeaponPose->SetSuperPose(Pose); 356 357 WeaponPose->Draw(-1 /*default skin*/, LodDist); … … 362 363 { 363 364 // Implicit simple "mini-prediction". 364 AnimPoseT* Pose=m_CompanyBotModel->GetSharedPose(State.ModelSequNr, State.ModelFrameNr); 365 Pose->Advance(FrameTime, State.ModelSequNr<18 || State.ModelSequNr>24); 366 State.ModelFrameNr=Pose->GetFrameNr(); 365 AdvanceModelTime(FrameTime, State.ModelSequNr<18 || State.ModelSequNr>24); 367 366 368 367 // Advance the time for the light source. … … 392 391 assert(false); 393 392 } 393 394 395 void EntCompanyBotT::AdvanceModelTime(float Time, bool Loop) 396 { 397 if (State.ModelSequNr==m_LastStdAE->GetSequNr()) 398 { 399 m_LastStdAE->SetFrameNr(State.ModelFrameNr); 400 } 401 else 402 { 403 m_LastStdAE=m_CompanyBotModel->GetAnimExprPool().GetStandard(State.ModelSequNr, State.ModelFrameNr); 404 m_AnimExpr =m_CompanyBotModel->GetAnimExprPool().GetBlend(m_AnimExpr, m_LastStdAE, 3.0f); 405 } 406 407 m_AnimExpr->AdvanceTime(Time, Loop); 408 State.ModelFrameNr=m_LastStdAE->GetFrameNr(); 409 } -
cafu/trunk/Games/DeathMatch/Code/CompanyBot.hpp
r457 r469 24 24 25 25 #include "../../BaseEntity.hpp" 26 #include "Models/AnimExpr.hpp" 26 27 #include "btBulletDynamicsCommon.h" 27 28 … … 59 60 private: 60 61 62 void AdvanceModelTime(float Time, bool Loop); 63 61 64 const CafuModelT* m_CompanyBotModel; 65 IntrusivePtrT<AnimExpressionT> m_AnimExpr; 66 IntrusivePtrT<AnimExprStandardT> m_LastStdAE; 62 67 const CafuModelT* m_WeaponModel; 63 68 float m_TimeForLightSource; -
cafu/trunk/Games/DeathMatch/Code/Corpse.cpp
r455 r469 86 86 87 87 const CafuModelT* Model=cf::GameSys::GameImplT::GetInstance().GetPlayerModel(State.ModelIndex); 88 AnimPoseT* Pose =Model->GetSharedPose( State.ModelSequNr, State.ModelFrameNr);88 AnimPoseT* Pose =Model->GetSharedPose(Model->GetAnimExprPool().GetStandard(State.ModelSequNr, State.ModelFrameNr)); 89 89 90 90 Pose->Draw(-1 /*default skin*/, LodDist); -
cafu/trunk/Games/DeathMatch/Code/Eagle.cpp
r455 r469 226 226 MatSys::Renderer->SetCurrentEyePosition(EyePos.x, EyePos.y, EyePos.z); 227 227 228 AnimPoseT* Pose=m_Model->GetSharedPose( State.ModelSequNr, State.ModelFrameNr);228 AnimPoseT* Pose=m_Model->GetSharedPose(m_Model->GetAnimExprPool().GetStandard(State.ModelSequNr, State.ModelFrameNr)); 229 229 Pose->Draw(-1 /*default skin*/, LodDist); 230 230 } … … 233 233 void EntEagleT::PostDraw(float FrameTime, bool /*FirstPersonView*/) 234 234 { 235 AnimPoseT* Pose=m_Model->GetSharedPose(State.ModelSequNr, State.ModelFrameNr);236 Pose->Advance(FrameTime, true);237 State.ModelFrameNr= Pose->GetFrameNr();235 IntrusivePtrT<AnimExprStandardT> StdAE=m_Model->GetAnimExprPool().GetStandard(State.ModelSequNr, State.ModelFrameNr); 236 StdAE->AdvanceTime(FrameTime, true); 237 State.ModelFrameNr=StdAE->GetFrameNr(); 238 238 239 239 // Update sound position and velocity. -
cafu/trunk/Games/DeathMatch/Code/FaceHugger.cpp
r455 r469 106 106 void EntFaceHuggerT::Draw(bool /*FirstPersonView*/, float LodDist) const 107 107 { 108 AnimPoseT* Pose=m_Model->GetSharedPose( State.ModelSequNr, State.ModelFrameNr);108 AnimPoseT* Pose=m_Model->GetSharedPose(m_Model->GetAnimExprPool().GetStandard(State.ModelSequNr, State.ModelFrameNr)); 109 109 Pose->Draw(-1 /*default skin*/, LodDist); 110 110 } … … 113 113 void EntFaceHuggerT::PostDraw(float FrameTime, bool /*FirstPersonView*/) 114 114 { 115 AnimPoseT* Pose=m_Model->GetSharedPose(State.ModelSequNr, State.ModelFrameNr);116 Pose->Advance(FrameTime, true);115 IntrusivePtrT<AnimExprStandardT> StdAE=m_Model->GetAnimExprPool().GetStandard(State.ModelSequNr, State.ModelFrameNr); 116 StdAE->AdvanceTime(FrameTime, true); 117 117 118 const bool SequenceWrap= Pose->GetFrameNr() < State.ModelFrameNr;119 State.ModelFrameNr= Pose->GetFrameNr();118 const bool SequenceWrap=StdAE->GetFrameNr() < State.ModelFrameNr; 119 State.ModelFrameNr=StdAE->GetFrameNr(); 120 120 121 121 if (SequenceWrap) -
cafu/trunk/Games/DeathMatch/Code/HandGrenade.cpp
r455 r469 253 253 if (State.ActiveWeaponFrameNr>=3.0) return; 254 254 255 AnimPoseT* Pose=m_Model->GetSharedPose( State.ModelSequNr, State.ModelFrameNr);255 AnimPoseT* Pose=m_Model->GetSharedPose(m_Model->GetAnimExprPool().GetStandard(State.ModelSequNr, State.ModelFrameNr)); 256 256 Pose->Draw(-1 /*default skin*/, LodDist); 257 257 } -
cafu/trunk/Games/DeathMatch/Code/HumanPlayer.cpp
r455 r469 463 463 const CafuModelT* WeaponModel=CarriedWeapon->GetViewWeaponModel(); 464 464 465 AnimPoseT* Pose=WeaponModel->GetSharedPose(State.ActiveWeaponSequNr, State.ActiveWeaponFrameNr);466 Pose->Advance(PlayerCommands[PCNr].FrameTime, true);467 468 const float NewFrameNr= Pose->GetFrameNr();465 IntrusivePtrT<AnimExprStandardT> StdAE=WeaponModel->GetAnimExprPool().GetStandard(State.ActiveWeaponSequNr, State.ActiveWeaponFrameNr); 466 StdAE->AdvanceTime(PlayerCommands[PCNr].FrameTime, true); 467 468 const float NewFrameNr=StdAE->GetFrameNr(); 469 469 const bool AnimSequenceWrap=NewFrameNr < State.ActiveWeaponFrameNr || NewFrameNr > WeaponModel->GetAnims()[State.ActiveWeaponSequNr].Frames.Size()-1; 470 470 … … 694 694 695 695 // Advance frame time of model sequence. 696 const CafuModelT* PlayerModel=cf::GameSys::GameImplT::GetInstance().GetPlayerModel(State.ModelIndex);697 AnimPoseT* Pose =PlayerModel->GetSharedPose(State.ModelSequNr, State.ModelFrameNr);698 699 Pose->Advance(PlayerCommands[PCNr].FrameTime, true);700 State.ModelFrameNr= Pose->GetFrameNr();696 const CafuModelT* PlayerModel=cf::GameSys::GameImplT::GetInstance().GetPlayerModel(State.ModelIndex); 697 IntrusivePtrT<AnimExprStandardT> StdAE =PlayerModel->GetAnimExprPool().GetStandard(State.ModelSequNr, State.ModelFrameNr); 698 699 StdAE->AdvanceTime(PlayerCommands[PCNr].FrameTime, true); 700 State.ModelFrameNr=StdAE->GetFrameNr(); 701 701 break; 702 702 } … … 731 731 732 732 // Advance frame time of model sequence. 733 const CafuModelT* PlayerModel=cf::GameSys::GameImplT::GetInstance().GetPlayerModel(State.ModelIndex);734 AnimPoseT* Pose =PlayerModel->GetSharedPose(State.ModelSequNr, State.ModelFrameNr);735 736 Pose->Advance(PlayerCommands[PCNr].FrameTime, false);737 State.ModelFrameNr= Pose->GetFrameNr();733 const CafuModelT* PlayerModel=cf::GameSys::GameImplT::GetInstance().GetPlayerModel(State.ModelIndex); 734 IntrusivePtrT<AnimExprStandardT> StdAE =PlayerModel->GetAnimExprPool().GetStandard(State.ModelSequNr, State.ModelFrameNr); 735 736 StdAE->AdvanceTime(PlayerCommands[PCNr].FrameTime, false); 737 State.ModelFrameNr=StdAE->GetFrameNr(); 738 738 739 739 // We entered this state after we died. … … 966 966 967 967 const CafuModelT* WeaponModel=cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(State.ActiveWeaponSlot)->GetViewWeaponModel(); 968 AnimPoseT* Pose =WeaponModel->GetSharedPose( State.ActiveWeaponSequNr, State.ActiveWeaponFrameNr);968 AnimPoseT* Pose =WeaponModel->GetSharedPose(WeaponModel->GetAnimExprPool().GetStandard(State.ActiveWeaponSequNr, State.ActiveWeaponFrameNr)); 969 969 970 970 Pose->Draw(-1 /*default skin*/, LodDist); … … 983 983 // Draw the own player body model and the "_p" (player) model of the active weapon as sub-model of the body. 984 984 const CafuModelT* PlayerModel=cf::GameSys::GameImplT::GetInstance().GetPlayerModel(State.ModelIndex); 985 AnimPoseT* Pose =PlayerModel->GetSharedPose( State.ModelSequNr, State.ModelFrameNr);985 AnimPoseT* Pose =PlayerModel->GetSharedPose(PlayerModel->GetAnimExprPool().GetStandard(State.ModelSequNr, State.ModelFrameNr)); 986 986 987 987 Pose->Draw(-1 /*default skin*/, LodDist); … … 990 990 { 991 991 const CafuModelT* WeaponModel=cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(State.ActiveWeaponSlot)->GetPlayerWeaponModel(); 992 AnimPoseT* WeaponPose =WeaponModel->GetSharedPose( 0, 0.0f);992 AnimPoseT* WeaponPose =WeaponModel->GetSharedPose(WeaponModel->GetAnimExprPool().GetStandard(0, 0.0f)); 993 993 994 994 WeaponPose->SetSuperPose(Pose); … … 1164 1164 else 1165 1165 { 1166 const CafuModelT* PlayerModel=cf::GameSys::GameImplT::GetInstance().GetPlayerModel(State.ModelIndex);1167 AnimPoseT* Pose =PlayerModel->GetSharedPose(State.ModelSequNr, State.ModelFrameNr);1166 const CafuModelT* PlayerModel=cf::GameSys::GameImplT::GetInstance().GetPlayerModel(State.ModelIndex); 1167 IntrusivePtrT<AnimExprStandardT> StdAE =PlayerModel->GetAnimExprPool().GetStandard(State.ModelSequNr, State.ModelFrameNr); 1168 1168 1169 1169 // Implicit simple "mini-prediction". WARNING, this does not really work...! 1170 Pose->Advance(FrameTime, State.StateOfExistance!=StateOfExistance_Dead);1171 State.ModelFrameNr= Pose->GetFrameNr();1170 StdAE->AdvanceTime(FrameTime, State.StateOfExistance!=StateOfExistance_Dead); 1171 State.ModelFrameNr=StdAE->GetFrameNr(); 1172 1172 } 1173 1173 -
cafu/trunk/Games/DeathMatch/Code/Item.cpp
r455 r469 132 132 if (State.StateOfExistance==StateOfExistance_NotActive) return; 133 133 134 AnimPoseT* Pose=m_ItemModel->GetSharedPose( 0, 0.0f);134 AnimPoseT* Pose=m_ItemModel->GetSharedPose(m_ItemModel->GetAnimExprPool().GetStandard(0, 0.0f)); 135 135 Pose->Draw(-1 /*default skin*/, LodDist); 136 136 -
cafu/trunk/Games/DeathMatch/Code/Rocket.cpp
r455 r469 254 254 if (State.ActiveWeaponFrameNr>0.0) return; 255 255 256 AnimPoseT* Pose=m_Model->GetSharedPose( State.ModelSequNr, State.ModelFrameNr);256 AnimPoseT* Pose=m_Model->GetSharedPose(m_Model->GetAnimExprPool().GetStandard(State.ModelSequNr, State.ModelFrameNr)); 257 257 Pose->Draw(-1 /*default skin*/, LodDist); 258 258 } -
cafu/trunk/Games/DeathMatch/Code/StaticDetailModel.cpp
r455 r469 195 195 // and it must be properly scaled and rotated for world space. 196 196 VectorT V[8]; 197 m_Model->GetSharedPose(m_ SequNr, 0.0f)->GetBB().AsBoxOfDouble().GetCornerVertices(V);197 m_Model->GetSharedPose(m_Model->GetAnimExprPool().GetStandard(m_SequNr, 0.0f))->GetBB().AsBoxOfDouble().GetCornerVertices(V); 198 198 199 199 for (unsigned int VertexNr=0; VertexNr<8; VertexNr++) … … 288 288 289 289 290 AnimPoseT* Pose=m_Model->GetSharedPose(m_ SequNr, m_FrameNr);290 AnimPoseT* Pose=m_Model->GetSharedPose(m_Model->GetAnimExprPool().GetStandard(m_SequNr, m_FrameNr)); 291 291 Pose->Draw(-1 /*default skin*/, LodDist); 292 292 … … 346 346 { 347 347 // Advance the client-local animation. 348 AnimPoseT* Pose=m_Model->GetSharedPose(m_SequNr, m_FrameNr); 349 Pose->Advance(FrameTime, true); 350 m_FrameNr=Pose->GetFrameNr(); 348 IntrusivePtrT<AnimExprStandardT> StdAE=m_Model->GetAnimExprPool().GetStandard(m_SequNr, m_FrameNr); 349 350 StdAE->AdvanceTime(FrameTime, true); 351 m_FrameNr=StdAE->GetFrameNr(); 351 352 } 352 353 … … 417 418 bool EntStaticDetailModelT::GetGuiPlane(unsigned int GFNr, Vector3fT& GuiOrigin, Vector3fT& GuiAxisX, Vector3fT& GuiAxisY) const 418 419 { 419 if (!m_Model->GetSharedPose(m_ SequNr, m_FrameNr)->GetGuiPlane(GFNr, GuiOrigin, GuiAxisX, GuiAxisY)) return false;420 if (!m_Model->GetSharedPose(m_Model->GetAnimExprPool().GetStandard(m_SequNr, m_FrameNr))->GetGuiPlane(GFNr, GuiOrigin, GuiAxisX, GuiAxisY)) return false; 420 421 421 422 // Okay, got the plane. Now transform it from model space into world space. -
cafu/trunk/Games/DeathMatch/Code/Weapon.cpp
r455 r469 132 132 if (State.StateOfExistance==StateOfExistance_NotActive) return; 133 133 134 AnimPoseT* Pose=m_WeaponModel->GetSharedPose( 0, 0.0f);134 AnimPoseT* Pose=m_WeaponModel->GetSharedPose(m_WeaponModel->GetAnimExprPool().GetStandard(0, 0.0f)); 135 135 Pose->Draw(-1 /*default skin*/, LodDist); 136 136 -
cafu/trunk/Libs/GuiSys/WindowModel.cpp
r455 r469 68 68 m_Model(NULL), 69 69 m_Pose(NULL), 70 m_LastStdAE(), 70 71 ModelPos(0, 0, 0), 71 72 ModelScale(1.0f), … … 84 85 m_Model(NULL), 85 86 m_Pose(NULL), 87 m_LastStdAE(), 86 88 ModelPos(Window.ModelPos), 87 89 ModelScale(Window.ModelScale), … … 116 118 if (m_Pose==NULL || PrevModel!=m_Model) 117 119 { 120 m_LastStdAE=m_Model->GetAnimExprPool().GetStandard(0, 0.0f); 121 118 122 delete m_Pose; 119 m_Pose=new AnimPoseT(*m_Model, 0, 0.0f);123 m_Pose=new AnimPoseT(*m_Model, m_LastStdAE); 120 124 } 121 125 } … … 124 128 int ModelWindowT::GetModelSequNr() const 125 129 { 126 return m_ Pose->GetSequNr();130 return m_LastStdAE->GetSequNr(); 127 131 } 128 132 … … 165 169 bool ModelWindowT::OnClockTickEvent(float t) 166 170 { 167 m_Pose-> Advance(t, true);171 m_Pose->GetAnimExpr()->AdvanceTime(t, true); 168 172 169 173 return WindowT::OnClockTickEvent(t); … … 211 215 int ModelWindowT::SetModelSequNr(lua_State* LuaState) 212 216 { 213 ModelWindowT* ModelWin=(ModelWindowT*)cf::GuiSys::GuiImplT::GetCheckedObjectParam(LuaState, 1, TypeInfo); 214 215 ModelWin->m_Pose->SetSequNr(luaL_checkinteger(LuaState, 2)); 217 ModelWindowT* ModelWin=(ModelWindowT*)cf::GuiSys::GuiImplT::GetCheckedObjectParam(LuaState, 1, TypeInfo); 218 const CafuModelT* Model =ModelWin->m_Model; 219 AnimPoseT* Pose =ModelWin->m_Pose; 220 221 IntrusivePtrT<AnimExpressionT> BlendFrom=Pose->GetAnimExpr(); 222 223 ModelWin->m_LastStdAE=Model->GetAnimExprPool().GetStandard(luaL_checkinteger(LuaState, 2), 0.0f); 224 Pose->SetAnimExpr(Model->GetAnimExprPool().GetBlend(BlendFrom, ModelWin->m_LastStdAE, 3.0f)); 216 225 return 0; 217 226 } -
cafu/trunk/Libs/GuiSys/WindowModel.hpp
r457 r469 25 25 #include "Window.hpp" 26 26 #include "Math3D/Vector3.hpp" 27 #include "Models/AnimExpr.hpp" 27 28 28 29 … … 78 79 private: 79 80 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. 81 const CafuModelT* m_Model; ///< The model instance rendered by this window. 82 AnimPoseT* m_Pose; ///< The pose of the model. 83 IntrusivePtrT<AnimExprStandardT> m_LastStdAE; ///< The most recent standard expression that we set (as a subexpression of m_Pose->GetAnimExpr()). 84 Vector3fT ModelPos; ///< The position of the model in world space. 85 float ModelScale; ///< The scale factor applied to the model coordinates when converted to world space. 86 Vector3fT ModelAngles; ///< The angles around the axes that determine the orientation of the model in world space. 87 Vector3fT CameraPos; ///< The position of the camera in world space. 86 88 87 89 -
cafu/trunk/Libs/Models/AnimExpr.hpp
r462 r469 70 70 virtual void GetData(unsigned int JointNr, float& Weight, Vector3fT& Pos, cf::math::QuaternionfT& Quat, Vector3fT& Scale) const=0; 71 71 72 /// Advances the frame numbers of the referenced animation sequences, cross-fades, etc. 72 /// Advances the time for this anim expression, 73 /// i.e.\ frame numbers of the referenced animation sequences, cross-fades, etc. 73 74 virtual void AdvanceTime(float Time, bool ForceLoop=false) { } 74 75 -
cafu/trunk/Libs/Models/AnimPose.cpp
r459 r469 44 44 m_DlodPose = new AnimPoseT(*m_Model.GetDlodModel(), m_AnimExpr); 45 45 } 46 }47 48 49 AnimPoseT::AnimPoseT(const CafuModelT& Model, int SequNr, float FrameNr)50 : m_Model(Model),51 m_AnimExpr(new AnimExprStandardT(m_Model, SequNr, FrameNr)),52 m_SuperPose(NULL),53 m_DlodPose(m_Model.GetDlodModel() ? new AnimPoseT(*m_Model.GetDlodModel(), m_AnimExpr) : NULL), // Recursively create the chain of dlod poses matching the chain of dlod models.54 m_CachedAE(NULL),55 m_BoundingBox()56 {57 46 } 58 47 … … 449 438 450 439 451 int AnimPoseT::GetSequNr() const452 {453 return dynamic_cast<const AnimExprStandardT*>(&*m_AnimExpr)->GetSequNr();454 }455 456 457 float AnimPoseT::GetFrameNr() const458 {459 return dynamic_cast<const AnimExprStandardT*>(&*m_AnimExpr)->GetFrameNr();460 }461 462 463 void AnimPoseT::SetSequNr(int SequNr)464 {465 dynamic_cast<AnimExprStandardT*>(&*m_AnimExpr)->SetSequNr(SequNr);466 467 // Recursively update the chain of dlod poses.468 if (m_DlodPose) m_DlodPose->SetSequNr(SequNr);469 }470 471 472 void AnimPoseT::SetFrameNr(float FrameNr)473 {474 dynamic_cast<AnimExprStandardT*>(&*m_AnimExpr)->SetFrameNr(FrameNr);475 476 // Recursively update the chain of dlod poses.477 if (m_DlodPose) m_DlodPose->SetFrameNr(FrameNr);478 }479 480 481 440 void AnimPoseT::SetSuperPose(const AnimPoseT* SuperPose) 482 441 { … … 488 447 // Recursively update the chain of dlod poses. 489 448 if (m_DlodPose) m_DlodPose->SetSuperPose(SuperPose); 490 }491 492 493 void AnimPoseT::Advance(float Time, bool ForceLoop)494 {495 m_AnimExpr->AdvanceTime(Time, ForceLoop);496 497 // Don't do this -- the dlod models share the same anim expression as the main model.498 // In fact, this method should be removed. Have the caller call Pose->GetAnimExpr()->AdvanceTime() instead.499 //500 // // Recursively update the chain of dlod poses.501 // if (m_DlodPose) m_DlodPose->Advance(Time, ForceLoop);502 449 } 503 450 -
cafu/trunk/Libs/Models/AnimPose.hpp
r459 r469 89 89 AnimPoseT(const CafuModelT& Model, IntrusivePtrT<AnimExpressionT> AnimExpr); 90 90 91 /// The constructor.92 AnimPoseT(const CafuModelT& Model, int SequNr=-1, float FrameNr=0.0f);93 94 91 /// The destructor. 95 92 ~AnimPoseT(); … … 103 100 void SetAnimExpr(IntrusivePtrT<AnimExpressionT> AnimExpr); 104 101 105 int GetSequNr() const;106 107 /// @param SequNr The number of the animation sequence to use, -1 for the bind pose.108 void SetSequNr(int SequNr);109 110 float GetFrameNr() const;111 112 /// @param FrameNr The frame number in the animation sequence to render the model at.113 void SetFrameNr(float FrameNr);114 115 102 /// This method assigns a pose of a parent or "super" model that should be used when rendering this model. 116 103 /// … … 121 108 /// @param SuperPose The super model pose that should be used when rendering this model. 122 109 void SetSuperPose(const AnimPoseT* SuperPose); 123 124 /// Advances the pose in time.125 /// Use GetFrameNr() to learn the new frame number after calling this method.126 void Advance(float Time, bool ForceLoop=false);127 110 128 111 /// Call this if something in the related model has changed. -
cafu/trunk/Libs/Models/Model_cmdl.cpp
r459 r469 293 293 } 294 294 295 m_TEMP_Pose=new AnimPoseT(*this );295 m_TEMP_Pose=new AnimPoseT(*this, m_AnimExprPool.GetStandard(-1, 0.0f)); 296 296 297 297 // Make sure that each skin has as many materials as there are meshes. … … 930 930 931 931 932 AnimPoseT* CafuModelT::GetSharedPose(int SequNr, float FrameNr) const 933 { 934 m_TEMP_Pose->SetSequNr(SequNr); 935 m_TEMP_Pose->SetFrameNr(FrameNr); 932 AnimPoseT* CafuModelT::GetSharedPose(IntrusivePtrT<AnimExpressionT> AE) const 933 { 934 m_TEMP_Pose->SetAnimExpr(AE); 936 935 937 936 return m_TEMP_Pose; -
cafu/trunk/Libs/Models/Model_cmdl.hpp
r459 r469 285 285 286 286 /// This method is strictly for backwards-compatibility only, do not use in new code! 287 AnimPoseT* GetSharedPose( int SequNr, float FrameNr) const;287 AnimPoseT* GetSharedPose(IntrusivePtrT<AnimExpressionT> AE) const; 288 288 289 289 /// An obsolete method that should not be used in new code. -
cafu/trunk/Libs/SceneGraph/ModelNode.cpp
r455 r469 33 33 m_Angles(), 34 34 m_Scale(0.0f), 35 m_ SeqNumber(0),35 m_AnimExpr(), 36 36 m_FrameOffset(0.0f), 37 37 m_FrameTimeScale(1.0f), 38 m_FrameNumber(0.0f),39 38 m_Animate(false), 40 39 m_Timer() … … 49 48 m_Angles(Angles), 50 49 m_Scale(Scale), 51 m_ SeqNumber(SeqNumber),50 m_AnimExpr(m_Model->GetAnimExprPool().GetStandard(SeqNumber, FrameOffset)), 52 51 m_FrameOffset(FrameOffset), 53 52 m_FrameTimeScale(FrameTimeScale), 54 m_FrameNumber(m_FrameOffset),55 53 m_Animate(Animate), 56 54 m_Timer() … … 63 61 ModelNodeT* ModelNode=new ModelNodeT(); 64 62 65 ModelNode->m_Model =ModelMan.GetModel(Pool.ReadString(InFile)); 66 ModelNode->m_Label =aux::ReadString(InFile); 67 ModelNode->m_Origin =aux::ReadVector3f(InFile); 63 ModelNode->m_Model =ModelMan.GetModel(Pool.ReadString(InFile)); 64 ModelNode->m_Label =aux::ReadString(InFile); 65 ModelNode->m_Origin=aux::ReadVector3f(InFile); 66 ModelNode->m_Angles=Pool.ReadVector3f(InFile); 67 ModelNode->m_Scale =aux::ReadFloat(InFile); 68 68 69 ModelNode->m_Angles =Pool.ReadVector3f(InFile); 70 71 ModelNode->m_Scale =aux::ReadFloat(InFile); 72 ModelNode->m_SeqNumber=aux::ReadInt32(InFile); 73 69 const int32_t SequNr =aux::ReadInt32(InFile); 74 70 ModelNode->m_FrameOffset =aux::ReadFloat(InFile); 75 71 ModelNode->m_FrameTimeScale=aux::ReadFloat(InFile); 76 72 77 ModelNode->m_ FrameNumber=ModelNode->m_FrameOffset;73 ModelNode->m_AnimExpr=ModelNode->m_Model->GetAnimExprPool().GetStandard(SequNr, ModelNode->m_FrameOffset); 78 74 79 75 InFile.read((char*)&ModelNode->m_Animate, sizeof(ModelNode->m_Animate)); … … 99 95 100 96 aux::Write(OutFile, m_Scale); 101 aux::Write(OutFile, (int32_t)m_ SeqNumber);97 aux::Write(OutFile, (int32_t)m_AnimExpr->GetSequNr()); 102 98 103 99 aux::Write(OutFile, m_FrameOffset); … … 112 108 static BoundingBox3dT BB; 113 109 114 BB=m_Model->GetSharedPose(m_ SeqNumber, m_FrameNumber)->GetBB().AsBoxOfDouble();110 BB=m_Model->GetSharedPose(m_AnimExpr)->GetBB().AsBoxOfDouble(); 115 111 116 112 return BB; … … 122 118 // Calculate model distance from viewer position. 123 119 float Distance=length(m_Origin-ViewerPos.AsVectorOfFloat()); 124 AnimPoseT* Pose =m_Model->GetSharedPose(m_ SeqNumber, m_FrameNumber);120 AnimPoseT* Pose =m_Model->GetSharedPose(m_AnimExpr); 125 121 126 122 if (m_Animate) 127 123 { 128 Pose->Advance(float(m_Timer.GetSecondsSinceLastCall())*m_FrameTimeScale); 129 130 m_FrameNumber=Pose->GetFrameNr(); 124 m_AnimExpr->AdvanceTime(float(m_Timer.GetSecondsSinceLastCall())*m_FrameTimeScale); 131 125 } 132 126 -
cafu/trunk/Libs/SceneGraph/ModelNode.hpp
r457 r469 24 24 25 25 #include "Node.hpp" 26 #include "Models/AnimExpr.hpp" 26 27 #include "Util/Util.hpp" 27 28 … … 73 74 Vector3fT m_Angles; 74 75 float m_Scale; 75 int m_SeqNumber;76 mutable IntrusivePtrT<AnimExprStandardT> m_AnimExpr; // FIXME: See comment below. The anim expression is updated inside the constant DrawAmbientContrib() method... 76 77 float m_FrameOffset; 77 78 float m_FrameTimeScale; 78 mutable float m_FrameNumber; // FIXME: See comment below. The models animation frame number is updated inside the constant DrawAmbientContrib() method...79 79 bool m_Animate; 80 80
