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

- File List
- File Members

# FCDocument/FCDSceneNode.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_SCENE_NODE_
    00021 #define _FCD_SCENE_NODE_
    00022
    00023 #ifndef _FCD_ENTITY_H_
    00024 #include "FCDocument/FCDEntity.h"
    00025 #endif // _FCD_ENTITY_H_
    00026 #ifndef _FCD_TRANSFORM_H_
    00027 #include "FCDocument/FCDTransform.h"
    00028 #endif // _FCD_TRANSFORM_H_
    00029 #ifndef _FCD_ENTITY_INSTANCE_H_
    00030 #include "FCDocument/FCDEntityInstance.h"
    00031 #endif // _FCD_ENTITY_INSTANCE_H_
    00032
    00033 class FCDocument;
    00034 class FCDEntityInstance;
    00035 class FCDSceneNode;
    00036 class FCDTransform;
    00037
    00054 class FCOLLADA_EXPORT FCDSceneNode : public FCDEntity
    00055 {
    00056 private:
    00057     DeclareObjectType(FCDEntity);
    00058
    00059     // Hierarchy and instances
    00060     DeclareParameterTrackList(FCDSceneNode, parents, FC("Parents"));
    00061     DeclareParameterTrackList(FCDSceneNode, children, FC("Child Nodes"));
    00062     DeclareParameterContainer(FCDTransform, transforms, FC("Transforms"));
    00063     DeclareParameterContainer(FCDEntityInstance, instances, FC("Instances"));
    00064
    00065     // Visibility parameter.
    00066     // Should be a boolean, but is animated as float.
    00067     DeclareParameterAnimatable(float, FUParameterQualifiers::SIMPLE, visibility, FC("Visibility"));
    00068
    00069     // The number of entities that target this node
    00070     uint32 targetCount;
    00071
    00072     // Mainly for joints.
    00073     DeclareParameter(fm::string, FUParameterQualifiers::SIMPLE, daeSubId, FC("Sub-id"));
    00074
    00075 public:
    00076     DeclareFlag(TransformsDirty, 0);
    00077     DeclareFlag(Joint, 1);
    00078     DeclareFlagCount(2);
    00080 public:
    00086     FCDSceneNode(FCDocument* document);
    00087
    00089     virtual ~FCDSceneNode();
    00090
    00093     virtual Type GetType() const { return SCENE_NODE; }
    00094
    00097     inline size_t GetParentCount() const { return parents.size(); };
    00098
    00103     inline FCDSceneNode* GetParent(size_t index = 0) { FUAssert(index == 0 || index < parents.size(), return NULL); return (!parents.empty()) ? parents.at(index) : NULL; }
    00104     inline const FCDSceneNode* GetParent(size_t index = 0) const { FUAssert(index == 0 || index < parents.size(), return NULL); return (!parents.empty()) ? parents.at(index) : NULL; }
    00108     inline const FCDSceneNode** GetParents() const { return parents.begin(); }
    00109
    00112     inline size_t GetChildrenCount() const { return children.size(); };
    00113
    00118     inline FCDSceneNode* GetChild(size_t index) { FUAssert(index < children.size(), return NULL); return children.at(index); }
    00119     inline const FCDSceneNode* GetChild(size_t index) const { FUAssert(index < children.size(), return NULL); return children.at(index); }
    00123     inline const FCDSceneNode** GetChildren() const { return children.begin(); }
    00124
    00127     FCDSceneNode* AddChildNode();
    00128
    00134     bool AddChildNode(FCDSceneNode* sceneNode);
    00135
    00143     void RemoveChildNode(FCDSceneNode* childNode);
    00144
    00147     inline size_t GetInstanceCount() const { return instances.size(); };
    00148
    00153     inline FCDEntityInstance* GetInstance(size_t index) { FUAssert(index < instances.size(), return NULL); return instances.at(index); }
    00154     inline const FCDEntityInstance* GetInstance(size_t index) const { FUAssert(index < instances.size(), return NULL); return instances.at(index); }
    00158     inline const FCDEntityInstance** GetInstances() const { return instances.begin(); }
    00159
    00167     FCDEntityInstance* AddInstance(FCDEntity* entity);
    00168
    00176     FCDEntityInstance* AddInstance(FCDEntity::Type type);
    00177
    00180     inline size_t GetTransformCount() const { return transforms.size(); };
    00181
    00186     inline FCDTransform* GetTransform(size_t index) { FUAssert(index < transforms.size(), return NULL); return transforms.at(index); }
    00187     inline const FCDTransform* GetTransform(size_t index) const { FUAssert(index < transforms.size(), return NULL); return transforms.at(index); }
    00191     inline const FCDTransform** GetTransforms() const { return transforms.begin(); }
    00202     FCDTransform* AddTransform(FCDTransform::Type type, size_t index = (size_t)-1);
    00203
    00207     inline void GetHierarchicalAssets(FCDAssetList& assets) { GetHierarchicalAssets(*(FCDAssetConstList*) &assets); }
    00208     virtual void GetHierarchicalAssets(FCDAssetConstList& assets) const;
    00216     virtual FCDEntity* FindDaeId(const fm::string& daeId) { return const_cast<FCDEntity*>(const_cast<const FCDSceneNode*>(this)->FindDaeId(daeId)); }
    00217     virtual const FCDEntity* FindDaeId(const fm::string& daeId) const;
    00222     inline const fm::string& GetSubId() const { return daeSubId; }
    00223
    00227     void SetSubId(const fm::string& id);
    00228
    00235     inline FCDEntity* FindSubId(const fm::string& subId) { return const_cast<FCDEntity*>(const_cast<const FCDSceneNode*>(this)->FindSubId(subId)); }
    00236     const FCDEntity* FindSubId(const fm::string& subId) const;
    00243     inline FCDParameterAnimatableFloat& GetVisibility() { return visibility; }
    00244     inline const FCDParameterAnimatableFloat& GetVisibility() const { return visibility; }
    00245     inline bool IsVisible() const { return visibility > 0.5f; }
    00251     inline void SetVisibility(bool isVisible) { visibility = isVisible ? 1.0f : 0.0f; }
    00252
    00255     inline bool IsTarget() const { return targetCount > 0; }
    00256
    00260     DEPRECATED(3.05A, GetJointFlag) bool IsJoint() const { return GetJointFlag(); }
    00261
    00265     FMMatrix44 ToMatrix() const;
    00266
    00271     inline FMMatrix44 CalculateLocalTransform() const { return ToMatrix(); }
    00272
    00276     FMMatrix44 CalculateWorldTransform() const;
    00277
    00287     virtual FCDEntity* Clone(FCDEntity* clone = NULL, bool cloneChildren = false) const;
    00288
    00291     inline void IncrementTargetCount() { ++targetCount; }
    00292
    00295     inline void DecrementTargetCount() { if (targetCount > 0) --targetCount; }
    00296
    00299     virtual void CleanSubId();
    00300 };
    00301
    00302 #endif // _FCD_SCENE_NODE_