1 /* 2 Copyright (c) 2008-2009 NetAllied Systems GmbH 3 4 This file is part of COLLADAMaya. 5 6 Portions of the code are: 7 Copyright (c) 2005-2007 Feeling Software Inc. 8 Copyright (c) 2005-2007 Sony Computer Entertainment America 9 Copyright (c) 2004-2005 Alias Systems Corp. 10 11 Licensed under the MIT Open Source License, 12 for details please see LICENSE file or the website 13 http://www.opensource.org/licenses/mit-license.php 14 */ 15 16 #ifndef __COLLADA_MAYA_SCENE_ELEMENT_H__ 17 #define __COLLADA_MAYA_SCENE_ELEMENT_H__ 18 19 #include "COLLADAMayaStableHeaders.h" 20 #include "COLLADAMayaPrerequisites.h" 21 22 #include <set> 23 24 25 namespace COLLADAMaya 26 { 27 28 class SceneElement; 29 30 /** List of scene element. */ 31 typedef std::vector<SceneElement*> SceneElementsList; 32 33 34 /** 35 * This class should be the base class for all the FCollada 'user-handle' structures. 36 */ 37 class SceneElement 38 { 39 40 public: 41 42 enum Type 43 { 44 UNDETERMINED, 45 UNKNOWN, 46 TRANSFORM, 47 MESH, 48 IKHANDLE, // Inverse Kinematic 49 CAMERA, 50 LIGHT, 51 PHYSIK, 52 PHYSIK_BULLET, 53 PHYSX_RIGID_SOLVER, 54 PHYSX_RIGID_BODY, 55 PHYSX_RIGID_CONSTRAINT, 56 PHYSX_SHAPE, 57 SPLINE, 58 NURBS, 59 EMITTER, 60 CONSTRAINT, 61 BONE, 62 LIGHT_PROBE, 63 LOD 64 }; 65 66 private: 67 68 /** Persistent information for DAG nodes */ 69 const MDagPath mDagPath; 70 71 /** Transient information */ 72 mutable MObject mNode; 73 74 /** The unique id of the node */ 75 String mNodeId; 76 77 /** The name of the node */ 78 mutable String mNodeName; 79 80 /** std::vector with parent elements */ 81 SceneElementsList mParentElements; 82 83 /** std::vector with child elements */ 84 SceneElementsList mChildElements; 85 86 /** Pointer to the instantiated scene element, if it exist. */ 87 SceneElement* mInstantiatedSceneElement; 88 89 /** The type of the node*/ 90 mutable Type mType; 91 92 /** true, if the node should be exported */ 93 bool mIsExportNode; 94 95 /** false, if the node has a file reference */ 96 bool mIsLocal; 97 98 /** true, if the node is a mesh node from type MFn::kSkinClusterFilter or MFn::kJointCluster. */ 99 bool mIsForced; 100 101 /** true, if it is a visible node */ 102 bool mIsVisible; 103 104 /** True, if the transform element has joints. */ 105 bool mHasJoint; 106 107 /** true, if the node is used as physics Node */ 108 bool mIsPhysicsNode; 109 110 /** Set the list of skeleton-Ids. It indicates where a skin 111 controller is to start to search for the joint nodes 112 it needs. This element is meaningless for morph controllers. */ 113 std::set<URI> mSkeletonURIs; 114 115 /** Holds for every skin controller dag path the bind shape matrix. */ 116 MMatrix mBindShapeMatrix; 117 118 public: 119 120 /** Constructor. */ 121 SceneElement ( const MDagPath _nodePath, Type _type=UNDETERMINED ); 122 virtual ~SceneElement (); 123 124 /** Returns the node path */ 125 const MDagPath& getPath () const; 126 127 /** Returns the node */ 128 const MObject& getNode () const; 129 130 /** Returns the type of the node*/ 131 const Type& getType() const; setType(const Type & _type)132 void setType ( const Type& _type ) 133 { 134 mType = _type; 135 } 136 137 /** Set the unique id of the export node to @a id*/ setNodeId(const String & id)138 void setNodeId ( const String& id ) 139 { 140 mNodeId = id; 141 } 142 143 /** Set the unique id of the export node to @a id*/ getNodeId()144 const String& getNodeId () const 145 { 146 return mNodeId; 147 } 148 149 /** Set the unique id of the export node to @a id*/ setNodeName(const String & name)150 void setNodeName ( const String& name ) 151 { 152 mNodeName = name; 153 } 154 155 const String& getNodeName () const; 156 157 /** Adds @a exportNode to its children*/ addParentElement(SceneElement * exportElement)158 void addParentElement ( SceneElement* exportElement ) 159 { 160 mParentElements.push_back ( exportElement ); 161 } 162 163 /** Returns the number of child nodes*/ getParentCount()164 const size_t getParentCount () const 165 { 166 return mParentElements.size(); 167 } 168 169 /** Returns the @a i'th child*/ 170 SceneElement* getParent ( size_t index=0 ) const 171 { 172 return mParentElements[index]; 173 } 174 175 /** True, if the node has the element as parent. */ 176 bool containsParentElement ( SceneElement* searchedSceneElement ); 177 178 /** True, if the node has the element as parent. */ 179 bool containsParentElement ( MDagPath searchedPath ); 180 181 /** Adds @a exportNode to its children*/ addChildElement(SceneElement * exportNode)182 void addChildElement ( SceneElement* exportNode ) 183 { 184 mChildElements.push_back ( exportNode ); 185 } 186 187 /** Returns the number of child nodes*/ getChildCount()188 const size_t getChildCount () const 189 { 190 return mChildElements.size(); 191 } 192 193 /** Returns the @a i'th child*/ getChild(size_t i)194 SceneElement* getChild ( size_t i ) const 195 { 196 return mChildElements[i]; 197 } 198 199 /** True, if the node has the element as child. */ 200 const bool containsChildElement ( SceneElement* searchedSceneElement ) const; 201 202 /** True, if the node has the element as child. */ 203 const bool containsChildElement ( MDagPath searchedPath ) const; 204 205 /** Pointer to the instantiated scene element, if it exist. */ getInstantiatedSceneElement()206 SceneElement* getInstantiatedSceneElement() const 207 { 208 return mInstantiatedSceneElement; 209 } 210 211 /** Pointer to the instantiated scene element, if it exist. */ setInstantiatedSceneElement(SceneElement * val)212 void setInstantiatedSceneElement ( SceneElement* val ) 213 { 214 mInstantiatedSceneElement = val; 215 } 216 217 /** Set the export flag on the current scene element. */ setIsExportNode(const bool _isExportNode)218 void setIsExportNode ( const bool _isExportNode ) 219 { 220 mIsExportNode = _isExportNode; 221 } 222 223 /** Set the export flag on the current scene element. */ getIsExportNode()224 const bool getIsExportNode () const 225 { 226 return mIsExportNode; 227 } 228 229 /** false, if the node has a file reference */ getIsLocal()230 const bool getIsLocal () const { return mIsLocal; } 231 232 /** false, if the node has a file reference */ setIsLocal(const bool val)233 void setIsLocal ( const bool val ) { mIsLocal = val; } 234 235 /** Set the forced flag on the current scene element. */ setIsForced(const bool _isForced)236 void setIsForced ( const bool _isForced ) 237 { 238 mIsForced = _isForced; 239 } 240 241 /** Set the forced flag on the current scene element. */ getIsForced()242 const bool getIsForced() const 243 { 244 return mIsForced; 245 } 246 247 /** Set the visible flag on the current scene element. */ setIsVisible(const bool _isVisible)248 void setIsVisible ( const bool _isVisible ) 249 { 250 mIsVisible= _isVisible; 251 } 252 253 /** Set the visible flag on the current scene element. */ getIsVisible()254 const bool getIsVisible () const 255 { 256 return mIsVisible; 257 } 258 259 /** 260 * True, if the transform element has joints. 261 * @param hasJoint True, if the transform element has joints. 262 */ setHasJoint(bool hasJoint)263 void setHasJoint ( bool hasJoint ) { mHasJoint = hasJoint; } 264 265 /** 266 * True, if the transform element has joints. 267 * @return bool True, if the transform element has joints. 268 */ getHasJoint()269 bool getHasJoint () { return mHasJoint; } 270 271 /** Set physicsNode on the current scene element. */ setIsPhysicsNode(bool val)272 void setIsPhysicsNode(bool val) 273 { 274 mIsPhysicsNode = val; 275 } 276 277 /** 278 * True, if the element is used as a Physics Node. 279 * @return bool True, if the element is used as a Physics Node. 280 */ getIsPhysicsNode()281 bool getIsPhysicsNode() const 282 { 283 return mIsPhysicsNode; 284 } 285 286 /** Set the skeleton uri. It indicates where a skin 287 controller is to start to search for the joint nodes 288 it needs. This element is meaningless for morph controllers. */ getSkeletonURIs()289 const std::set<URI>& getSkeletonURIs () const { return mSkeletonURIs; } 290 291 /** Set the skeleton uri. It indicates where a skin 292 controller is to start to search for the joint nodes 293 it needs. This element is meaningless for morph controllers. */ addSkeletonURI(const URI & val)294 void addSkeletonURI ( const URI& val ) { mSkeletonURIs.insert ( val ); } 295 296 /** Holds for every skin controller dag path the bind shape matrix. */ getBindShapeMatrix()297 const MMatrix& getBindShapeMatrix () const { return mBindShapeMatrix; } setBindShapeMatrix(const MMatrix & val)298 void setBindShapeMatrix ( const MMatrix& val ) { mBindShapeMatrix = val; } 299 300 private: 301 302 /** Returns the type of the node*/ 303 const Type determineType() const; 304 }; 305 } 306 307 #endif // __COLLADA_MAYA_SCENE_ELEMENT_H__ 308