FCDocument/FCDSkinController.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005-2006 Feeling Software Inc.
00003     MIT License: http://www.opensource.org/licenses/mit-license.php
00004 */
00005 /*
00006     Based on the FS Import classes:
00007     Copyright (C) 2005-2006 Feeling Software Inc
00008     Copyright (C) 2005-2006 Autodesk Media Entertainment
00009     MIT License: http://www.opensource.org/licenses/mit-license.php
00010 */
00011 
00017 #ifndef _FCD_SKIN_CONTROLLER_H_
00018 #define _FCD_SKIN_CONTROLLER_H_
00019 
00020 #include "FCDocument/FCDObject.h"
00021 
00022 class FCDocument;
00023 class FCDController;
00024 class FCDGeometry;
00025 class FCDSceneNode;
00026 
00030 struct FCDJointWeightPair
00031 {
00033     FCDJointWeightPair() { jointIndex = 0; weight = 0.0f; }
00034 
00038     FCDJointWeightPair(uint32 _jointIndex, float _weight) { jointIndex = _jointIndex; weight = _weight; }
00039 
00040     uint32 jointIndex; 
00041     float weight; 
00042 };
00043 
00047 struct FCDJointMatrixPair
00048 {
00049     FMMatrix44 invertedBindPose; 
00050     FCDSceneNode* joint; 
00051 };
00052 
00054 typedef vector<FCDJointMatrixPair> FCDJointList;
00055 
00058 typedef vector<FCDJointWeightPair> FCDJointWeightPairList;
00059 
00062 typedef vector<FCDJointWeightPairList> FCDWeightedMatches;
00063 
00076 class FCOLLADA_EXPORT FCDSkinController : public FCDObject
00077 {
00078 private:
00079     DeclareObjectType;
00080     FCDController* parent;
00081 
00082     bool ownsTarget;
00083     FCDEntity* target;
00084     FMMatrix44 bindShapeTransform;
00085 
00086     StringList jointIds;
00087     FCDJointList joints;
00088     FCDWeightedMatches weightedMatches;
00089 
00090 public:
00095     FCDSkinController(FCDocument* document, FCDController* parent);
00096 
00099     virtual ~FCDSkinController();
00100     
00104     FCDEntity* GetTarget() { return target; }
00105     const FCDEntity* GetTarget() const { return target; } 
00113     void SetTarget(FCDEntity* _target);
00114 
00117     const FMMatrix44& GetBindShapeTransform() const { return bindShapeTransform; }
00118 
00121     void SetBindShapeTransform(const FMMatrix44& bindPose) { bindShapeTransform = bindPose; }
00122 
00125     FCDJointList& GetJoints() { return joints; }
00126     const FCDJointList& GetJoints() const { return joints; } 
00130     size_t GetJointCount() const { return joints.size(); }
00131 
00135     FCDJointMatrixPair* GetJoint(size_t index) { FUAssert(index < GetJointCount(), return NULL); return &joints.at(index); }
00136     const FCDJointMatrixPair* GetJoint(size_t index) const { FUAssert(index < GetJointCount(), return NULL); return &joints.at(index); } 
00142     FCDJointMatrixPair* FindJoint(FCDSceneNode* joint);
00143     const FCDJointMatrixPair* FindJoint(const FCDSceneNode* joint) const; 
00148     void AddJoint(FCDSceneNode* joint, const FMMatrix44& bindPose);
00149 
00153     void RemoveJoint(FCDSceneNode* joint);
00154 
00159     FCDWeightedMatches& GetWeightedMatches() { return weightedMatches; }
00160     const FCDWeightedMatches& GetWeightedMatches() const { return weightedMatches; } 
00165     FCDWeightedMatches& GetVertexInfluences() { return weightedMatches; }
00166     const FCDWeightedMatches& GetVertexInfluences() const { return weightedMatches; } 
00172     size_t GetVertexInfluenceCount() const { return weightedMatches.size(); }
00173 
00177     FCDJointWeightPairList* GetInfluences(size_t index) { FUAssert(index < GetVertexInfluenceCount(), return NULL); return &weightedMatches.at(index); }
00178     const FCDJointWeightPairList* GetInfluences(size_t index) const { FUAssert(index < GetVertexInfluenceCount(), return NULL); return &weightedMatches.at(index); } 
00187     void ReduceInfluences(uint32 maxInfluenceCount, float minimumWeight=0.0f);
00188 
00193     FUStatus LoadFromXML(xmlNode* skinNode);
00194 
00198     xmlNode* WriteToXML(xmlNode* parentNode) const;
00199 
00204     FUStatus Link();
00205 };
00206 
00207 #endif // _FCD_SKIN_CONTROLLER_H_
00208 

Generated on Fri May 12 16:44:39 2006 for FCollada by  doxygen 1.4.6-NO