Changeset 422 for cafu/trunk
- Timestamp:
- 11/14/11 13:43:11 (6 months ago)
- Location:
- cafu/trunk
- Files:
-
- 7 modified
-
CaWE/ModelEditor/ModelDocument.cpp (modified) (2 diffs)
-
CaWE/ModelEditor/ModelDocument.hpp (modified) (1 diff)
-
CaWE/ModelEditor/SceneView3D.cpp (modified) (2 diffs)
-
CaWE/ModelEditor/SubmodelsList.cpp (modified) (1 diff)
-
Libs/Models/AnimPose.cpp (modified) (6 diffs)
-
Libs/Models/AnimPose.hpp (modified) (4 diffs)
-
Libs/Models/Model_cmdl.hpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
cafu/trunk/CaWE/ModelEditor/ModelDocument.cpp
r415 r422 41 41 42 42 43 ModelEditor::ModelDocumentT::SubmodelT::SubmodelT(const wxString& fn, CafuModelT* sm, const ArrayT<unsigned int>& jm) 44 : m_Filename(fn), 45 m_Submodel(sm), 46 m_Pose(*sm, -1, 0.0f), 47 m_JointsMap(jm) 43 ModelEditor::ModelDocumentT::SubmodelT::SubmodelT(CafuModelT* Submodel) 44 : m_Submodel(Submodel), 45 m_Pose(*Submodel, -1, 0.0f) 48 46 { 49 47 } … … 167 165 try 168 166 { 169 CafuModelT* Submodel=LoadModel(FileName); 170 ArrayT<unsigned int> JointsMap; 171 172 for (unsigned int JointNr=0; JointNr<Submodel->GetJoints().Size(); JointNr++) 173 { 174 const std::string& SubName=Submodel->GetJoints()[JointNr].Name; 175 176 unsigned int JNr; 177 for (JNr=0; JNr<m_Model->GetJoints().Size(); JNr++) 178 if (wxStricmp(SubName, m_Model->GetJoints()[JNr].Name)==0) 179 break; 180 181 // Not found / no correspondence is indicated by a too large and thus invalid JNr. 182 JointsMap.PushBack(JNr); 183 } 184 185 m_Submodels.PushBack(new SubmodelT(FileName, Submodel, JointsMap)); 167 m_Submodels.PushBack(new SubmodelT(LoadModel(FileName))); 186 168 } 187 169 catch (const ModelT::LoadError& /*E*/) -
cafu/trunk/CaWE/ModelEditor/ModelDocument.hpp
r400 r422 76 76 public: 77 77 78 SubmodelT( const wxString& fn, CafuModelT* sm, const ArrayT<unsigned int>& jm);78 SubmodelT(CafuModelT* Submodel); 79 79 ~SubmodelT(); 80 80 81 const wxString& GetFilename() const { return m_Filename; } 82 const CafuModelT* GetSubmodel() const { return m_Submodel; } 83 AnimPoseT& GetPose() { return m_Pose; } 84 const ArrayT<unsigned int>& GetJointsMap() const { return m_JointsMap; } 81 const CafuModelT* GetSubmodel() const { return m_Submodel; } 82 AnimPoseT& GetPose() { return m_Pose; } 85 83 86 84 87 85 private: 88 86 89 wxString m_Filename; ///< The filename of the submodel.90 CafuModelT* m_Submodel; ///< The submodel that is shown with the main model.91 AnimPoseT m_Pose; ///< The pose of the submodel.92 ArrayT<unsigned int> m_JointsMap; ///< Describes how the joints of the m_Submodel map to the joints of the m_Model super model.93 94 87 SubmodelT(const SubmodelT&); ///< Use of the Copy Constructor is not allowed. 95 88 void operator = (const SubmodelT&); ///< Use of the Assignment Operator is not allowed. 89 90 CafuModelT* m_Submodel; ///< The submodel that is shown with the main model. 91 AnimPoseT m_Pose; ///< The pose of the submodel. 96 92 }; 97 93 -
cafu/trunk/CaWE/ModelEditor/SceneView3D.cpp
r402 r422 379 379 AnimPoseT& SmPose=SM->GetPose(); 380 380 381 const AnimPoseT::SuperT Super( 382 Anim.Pose.GetJointMatrices(), 383 SM->GetJointsMap()); 384 385 SmPose.SetSuper(&Super); 381 SmPose.SetSuperPose(&Anim.Pose); 386 382 SmPose.Draw(-1 /*SkinNr*/, 0.0f /*LodDist*/); 387 SmPose.SetSuper (NULL);383 SmPose.SetSuperPose(NULL); 388 384 } 389 385 } … … 400 396 AnimPoseT& SmPose=SM->GetPose(); 401 397 402 const AnimPoseT::SuperT Super( 403 Anim.Pose.GetJointMatrices(), 404 SM->GetJointsMap()); 405 406 SmPose.SetSuper(&Super); 398 SmPose.SetSuperPose(&Anim.Pose); 407 399 RenderSkeleton(SM->GetSubmodel()->GetJoints(), SmPose.GetJointMatrices(), true); 408 SmPose.SetSuper (NULL);400 SmPose.SetSuperPose(NULL); 409 401 } 410 402 } -
cafu/trunk/CaWE/ModelEditor/SubmodelsList.cpp
r343 r422 94 94 for (unsigned long ElemNr=0; ElemNr<m_ModelDoc->GetSubmodels().Size(); ElemNr++) 95 95 { 96 wxFileName fn(m_ModelDoc->GetSubmodels()[ElemNr]->Get Filename());96 wxFileName fn(m_ModelDoc->GetSubmodels()[ElemNr]->GetSubmodel()->GetFileName()); 97 97 98 98 fn.MakeRelativeTo(m_ModelDoc->GetGameConfig()->ModDir); -
cafu/trunk/Libs/Models/AnimPose.cpp
r406 r422 33 33 m_SequNr(SequNr), 34 34 m_FrameNr(FrameNr), 35 m_Super (NULL),35 m_SuperPose(NULL), 36 36 m_DlodPose(m_Model.GetDlodModel() ? new AnimPoseT(*m_Model.GetDlodModel(), SequNr, FrameNr) : NULL), // Recursively create the chain of dlod poses matching the chain of dlod models. 37 37 m_NeedsRecache(true), … … 76 76 77 77 78 void AnimPoseT::SetSuper (const SuperT* Super)79 { 80 if (m_Super ==Super) return;81 82 m_Super =Super;78 void AnimPoseT::SetSuperPose(const AnimPoseT* SuperPose) 79 { 80 if (m_SuperPose==SuperPose) return; 81 82 m_SuperPose=SuperPose; 83 83 84 84 m_NeedsRecache=true; 85 85 86 86 // Recursively update the chain of dlod poses. 87 if (m_DlodPose) m_DlodPose->SetSuper (Super);87 if (m_DlodPose) m_DlodPose->SetSuperPose(SuperPose); 88 88 } 89 89 … … 406 406 407 407 408 const MatrixT* AnimPoseT::GetJointMatrix(const std::string& JointName) const 409 { 410 Recache(); 411 412 for (unsigned int JointNr=0; JointNr<m_Model.GetJoints().Size(); JointNr++) 413 if (m_Model.GetJoints()[JointNr].Name == JointName) 414 return &m_JointMatrices[JointNr]; 415 416 return NULL; 417 } 418 419 408 420 const ArrayT<AnimPoseT::MeshInfoT>& AnimPoseT::GetMeshInfos() const 409 421 { … … 526 538 for (unsigned long JointNr=0; JointNr<Joints.Size(); JointNr++) 527 539 { 528 if (m_Super && m_Super->HasMatrix(JointNr)) 529 { 530 m_JointMatrices[JointNr]=m_Super->GetMatrix(JointNr); 531 continue; 540 if (m_SuperPose) 541 { 542 const MatrixT* SuperMat=m_SuperPose->GetJointMatrix(Joints[JointNr].Name); 543 544 if (SuperMat) 545 { 546 m_JointMatrices[JointNr]=*SuperMat; 547 continue; 548 } 532 549 } 533 550 … … 548 565 for (unsigned long JointNr=0; JointNr<Joints.Size(); JointNr++) 549 566 { 550 if (m_Super && m_Super->HasMatrix(JointNr)) 551 { 552 m_JointMatrices[JointNr]=m_Super->GetMatrix(JointNr); 553 continue; 567 if (m_SuperPose) 568 { 569 const MatrixT* SuperMat=m_SuperPose->GetJointMatrix(Joints[JointNr].Name); 570 571 if (SuperMat) 572 { 573 m_JointMatrices[JointNr]=*SuperMat; 574 continue; 575 } 554 576 } 555 577 … … 820 842 void AnimPoseT::Recache() const 821 843 { 822 if (!m_NeedsRecache && !m_Super ) return;844 if (!m_NeedsRecache && !m_SuperPose) return; 823 845 824 846 SyncDimensions(); -
cafu/trunk/Libs/Models/AnimPose.hpp
r416 r422 75 75 76 76 77 /// This struct describes information about a parent or "super" model whose skeleton pose78 /// should be used when rendering this model. For example, a player model can act as the79 /// super model for a weapon, so that the skeleton of the weapon is copied from the80 /// player model in order to align the weapon with the hands of the player.81 struct SuperT82 {83 /// The constructor.84 /// @param Matrices_ The draw matrices of the super model.85 /// @param Map_ Describes how our joints map to the joints of the super model.86 /// If <tt>Map_[i]</tt> is not a valid index into \c Matrices_, then our joint \c i has no match in the skeleton of the super model.87 SuperT(const ArrayT<MatrixT>& Matrices_, const ArrayT<unsigned int>& Map_) : Matrices(Matrices_), Map(Map_) { }88 89 /// Has our joint \c JointNr a correspondence in the super model?90 bool HasMatrix(unsigned long JointNr) const { return Map[JointNr] < Matrices.Size(); }91 92 /// For our joint \c JointNr, return the corresponding matrix from the super model.93 /// Only call this if HasMatrix(JointNr) returns \c true.94 const MatrixT& GetMatrix(unsigned long JointNr) const { return Matrices[Map[JointNr]]; }95 96 const ArrayT<MatrixT>& Matrices; ///< The draw matrices of the super model.97 const ArrayT<unsigned int>& Map; ///< Describes how our joints map to the joints of the super model. If <tt>Map[i]</tt> is not a valid index into \c Matrices, then our joint \c i has no match in the skeleton of the super model.98 };99 100 101 77 /// The constructor. 102 78 AnimPoseT(const CafuModelT& Model, int SequNr=-1, float FrameNr=0.0f); … … 112 88 float GetFrameNr() const { return m_FrameNr; } 113 89 114 /// @param FrameNr The frame number in the animation sequence to render t omodel at.90 /// @param FrameNr The frame number in the animation sequence to render the model at. 115 91 void SetFrameNr(float FrameNr); 116 92 117 /// @param Super Information about a parent or "super" model whose skeleton pose should be used when rendering this model. 118 void SetSuper(const SuperT* Super); 93 /// This method assigns a pose of a parent or "super" model that should be used when rendering this model. 94 /// 95 /// For example, a player model can act as the super model for a weapon, 96 /// so that the skeleton of the weapon is copied from the player model 97 /// in order to align the weapon with the hands of the player. 98 /// 99 /// @param SuperPose The super model pose that should be used when rendering this model. 100 void SetSuperPose(const AnimPoseT* SuperPose); 119 101 120 102 /// Advances the pose in time. … … 147 129 const ArrayT<MatrixT>& GetJointMatrices() const; 148 130 131 /// Returns the transformation matrix for the joint with the given name, or \c NULL if there is no such joint. 132 const MatrixT* GetJointMatrix(const std::string& JointName) const; 133 149 134 /// Returns the mesh infos with additional data for each mesh in this pose. 150 135 const ArrayT<MeshInfoT>& GetMeshInfos() const; … … 170 155 int m_SequNr; ///< The animation sequence number at which we have computed the cache data. 171 156 float m_FrameNr; ///< The animation frame number at which we have computed the cache data. 172 const SuperT* m_Super;157 const AnimPoseT* m_SuperPose; 173 158 AnimPoseT* m_DlodPose; ///< The next pose in the chain of dlod poses matching the chain of dlod models. 174 159 // ArrayT<...> m_Def; ///< Array of { channel, sequence, framenr, (forceloop), blendweight } tuples. -
cafu/trunk/Libs/Models/Model_cmdl.hpp
r414 r422 279 279 280 280 // The ModelT interface. 281 const std::string& GetFileName() const; // TODO: Remove!?!281 const std::string& GetFileName() const; 282 282 void Draw(int SequenceNr, float FrameNr, float LodDist, const ModelT* SubModel=NULL) const; 283 283 bool GetGuiPlane(int SequenceNr, float FrameNr, float LodDist, Vector3fT& GuiOrigin, Vector3fT& GuiAxisX, Vector3fT& GuiAxisY) const;
