- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# FCDocument/FCDSkinController.h

Go to the documentation of this file.

    00001 /*
    00002     Copyright (C) 2005-2007 Feeling Software Inc.
    00003     Portions of the code are:
    00004     Copyright (C) 2005-2007 Sony Computer Entertainment America
    00005
    00006     MIT License: http://www.opensource.org/licenses/mit-license.php
    00007 */
    00008 /*
    00009     Based on the FS Import classes:
    00010     Copyright (C) 2005-2006 Feeling Software Inc
    00011     Copyright (C) 2005-2006 Autodesk Media Entertainment
    00012     MIT License: http://www.opensource.org/licenses/mit-license.php
    00013 */
    00014
    00020 #ifndef _FCD_SKIN_CONTROLLER_H_
    00021 #define _FCD_SKIN_CONTROLLER_H_
    00022
    00023 #ifndef __FCD_OBJECT_H_
    00024 #include "FCDocument/FCDObject.h"
    00025 #endif // __FCD_OBJECT_H_
    00026 #ifndef _FU_PARAMETER_H_
    00027 #include "FUtils/FUParameter.h"
    00028 #endif // _FU_PARAMETER_H_
    00029
    00030 class FCDocument;
    00031 class FCDController;
    00032 class FCDGeometry;
    00033 class FCDSceneNode;
    00034 class FCDEntityReference;
    00035 class FUUri;
    00036
    00041 struct FCOLLADA_EXPORT FCDJointWeightPair
    00042 {
    00044     FCDJointWeightPair() { jointIndex = -1; weight = 0.0f; }
    00045
    00049     FCDJointWeightPair(int32 _jointIndex, float _weight) { jointIndex = _jointIndex; weight = _weight; }
    00050
    00055     int32 jointIndex;
    00056
    00058     float weight;
    00059 };
    00060
    00067 class FCOLLADA_EXPORT FCDSkinControllerVertex
    00068 {
    00069 private:
    00070     fm::vector<FCDJointWeightPair> pairs;
    00071
    00072 public:
    00075     inline size_t GetPairCount() const { return pairs.size(); }
    00076
    00079     void SetPairCount(size_t count);
    00080
    00084     inline FCDJointWeightPair* GetPair(size_t index) { FUAssert(index < pairs.size(), return NULL); return &(pairs.at(index)); }
    00085     inline const FCDJointWeightPair* GetPair(size_t index) const { FUAssert(index < pairs.size(), return NULL); return &(pairs.at(index)); }
    00091     void AddPair(int32 jointIndex, float weight);
    00092 };
    00093
    00101 class FCOLLADA_EXPORT FCDSkinControllerJoint
    00102 {
    00103 private:
    00104     fm::string id;
    00105     FMMatrix44 bindPoseInverse;
    00106
    00107 public:
    00110     inline const fm::string& GetId() const { return id; }
    00111
    00114     void SetId(const fm::string& id);
    00115
    00118     inline const FMMatrix44& GetBindPoseInverse() const { return bindPoseInverse; }
    00119
    00122     inline void SetBindPoseInverse(const FMMatrix44& inverseBindPose) { bindPoseInverse = inverseBindPose; }
    00123 };
    00124
    00138 class FCOLLADA_EXPORT FCDSkinController : public FCDObject
    00139 {
    00140 private:
    00141     DeclareObjectType(FCDObject);
    00142     FCDController* parent;
    00143
    00144     FUObjectRef<FCDEntityReference> target;
    00145     DeclareParameter(FMMatrix44, FUParameterQualifiers::SIMPLE, bindShapeTransform, FC("Base Mesh Bind-pose Transform"));
    00146
    00147     fm::vector<FCDSkinControllerJoint> joints;
    00148     fm::vector<FCDSkinControllerVertex> influences;
    00149
    00150 public:
    00155     FCDSkinController(FCDocument* document, FCDController* parent);
    00156
    00158     virtual ~FCDSkinController();
    00159
    00162     inline FCDController* GetParent() { return parent; }
    00163     inline const FCDController* GetParent() const { return parent; }
    00168     FCDEntity* GetTarget();
    00169     const FCDEntity* GetTarget() const;
    00170
    00174     FUUri GetTargetUri() const;
    00175
    00178     void SetTargetUri(const FUUri& uri);
    00179
    00186     void SetTarget(FCDEntity* _target);
    00187
    00190     const FMMatrix44& GetBindShapeTransform() const { return *bindShapeTransform; }
    00191
    00194     void SetBindShapeTransform(const FMMatrix44& bindPose) { bindShapeTransform = bindPose; SetDirtyFlag(); }
    00195
    00198     inline size_t GetJointCount() const { return joints.size(); }
    00199
    00202     void SetJointCount(size_t count);
    00203
    00206     inline FCDSkinControllerJoint* GetJoints() { return !joints.empty() ? &(joints.front()) : NULL; }
    00207     inline const FCDSkinControllerJoint* GetJoints() const { return !joints.empty() ? &(joints.front()) : NULL; }
    00212     inline FCDSkinControllerJoint* GetJoint(size_t index) { FUAssert(index < joints.size(), return NULL); return &joints.at(index); }
    00213     inline const FCDSkinControllerJoint* GetJoint(size_t index) const { FUAssert(index < joints.size(), return NULL); return &joints.at(index); }
    00218     FCDSkinControllerJoint* AddJoint(const fm::string jSubId = "", const FMMatrix44& inverseBindPose = FMMatrix44::Identity);
    00219
    00222     inline size_t GetInfluenceCount() const { return influences.size(); }
    00223
    00226     void SetInfluenceCount(size_t count);
    00227
    00230     inline FCDSkinControllerVertex* GetVertexInfluences() { return influences.size() > 0 ? &(influences.front()) : NULL; }
    00231     inline const FCDSkinControllerVertex* GetVertexInfluences() const { return influences.size() > 0 ? &(influences.front()) : NULL; }
    00236     inline FCDSkinControllerVertex* GetVertexInfluence(size_t index) { FUAssert(index < influences.size(), return NULL); return &influences.at(index); }
    00237     inline const FCDSkinControllerVertex* GetVertexInfluence(size_t index) const { FUAssert(index < influences.size(), return NULL); return &influences.at(index); }
    00246     void ReduceInfluences(uint32 maxInfluenceCount, float minimumWeight=0.0f);
    00247 };
    00248
    00249 #endif // _FCD_SKIN_CONTROLLER_H_
    00250