[964] | 1 | /*
|
---|
| 2 | Copyright (C) 2005-2006 Feeling Software Inc.
|
---|
| 3 | MIT License: http://www.opensource.org/licenses/mit-license.php
|
---|
| 4 | */
|
---|
| 5 | /*
|
---|
| 6 | Based on the FS Import classes:
|
---|
| 7 | Copyright (C) 2005-2006 Feeling Software Inc
|
---|
| 8 | Copyright (C) 2005-2006 Autodesk Media Entertainment
|
---|
| 9 | MIT License: http://www.opensource.org/licenses/mit-license.php
|
---|
| 10 | */
|
---|
| 11 |
|
---|
| 12 | /**
|
---|
| 13 | @file FCDEntityInstance.h
|
---|
| 14 | This file contains the FCDEntityInstance class.
|
---|
| 15 | */
|
---|
| 16 | |
---|
| 17 | #ifndef _FCD_ENTITY_INSTANCE_H_ |
---|
| 18 | #define _FCD_ENTITY_INSTANCE_H_ |
---|
| 19 | |
---|
| 20 | class FCDocument; |
---|
| 21 | class FCDEntity; |
---|
| 22 | |
---|
| 23 | #include "FCDocument/FCDObject.h" |
---|
| 24 | #include "FCDocument/FCDEntity.h" |
---|
| 25 | |
---|
| 26 | /** |
---|
| 27 | A COLLADA entity instance. |
---|
| 28 | COLLADA allows for quite a bit of per-instance settings |
---|
| 29 | for entities. This information is held by the up-classes of this class. |
---|
| 30 | This base class is simply meant to hold the entity that is instantiated. |
---|
| 31 | |
---|
| 32 | @ingroup FCDocument |
---|
| 33 | */ |
---|
| 34 | class FCOLLADA_EXPORT FCDEntityInstance : public FCDObject |
---|
| 35 | { |
---|
| 36 | public: |
---|
| 37 | /** The class type of the entity instance class. |
---|
| 38 | Used this information to up-cast an entity instance. */ |
---|
| 39 | enum Type |
---|
| 40 | { |
---|
| 41 | SIMPLE, /**< A simple entity instance that has no per-instance information. |
---|
| 42 | This is used for lights and cameras in the visual scene graph and there is no up-class. */ |
---|
| 43 | EXTERNAL_REFERENCE, /**< An external reference(FCDExternalReference). */ |
---|
| 44 | GEOMETRY, /**< A geometry entity(FCDGeometryInstance). */ |
---|
| 45 | MATERIAL, /**< A material entity(FCDMaterialInstance). */ |
---|
| 46 | PHYSICS_MODEL, /**< A physics model(FCDPhysicsModelInstance). */ |
---|
| 47 | PHYSICS_RIGID_BODY, /**< A physics rigid body(FCDPhysicsRigidBodyInstance). */ |
---|
| 48 | PHYSICS_RIGID_CONSTRAINT /**< A physics rigid constraint(FCDPhysicsRigidConstraintInstance). */ |
---|
| 49 | }; |
---|
| 50 | |
---|
| 51 | private: |
---|
| 52 | DeclareObjectType; |
---|
| 53 | FCDEntity* entity; |
---|
| 54 | |
---|
| 55 | public: |
---|
| 56 | /** Constructor: do not use directly. |
---|
| 57 | Instead, use the appropriate allocation function. |
---|
| 58 | For scene node instance: FCDSceneNode::AddInstance. |
---|
| 59 | @param document The COLLADA document that owns the entity instance. |
---|
| 60 | @param entity The entity to instantiate. This pointer will be NULL |
---|
| 61 | for some up-classes where the entity instantiate is more complex. */ |
---|
| 62 | FCDEntityInstance(FCDocument* document, FCDEntity* entity = NULL); |
---|
| 63 | |
---|
| 64 | /** Destructor: do not use directly. |
---|
| 65 | Instead, use the appropriate release funciton. |
---|
| 66 | For scene node instances: FCDSceneNode::ReleaseInstance. */ |
---|
| 67 | virtual ~FCDEntityInstance(); |
---|
| 68 | |
---|
| 69 | /** Retrieves the entity instance class type. |
---|
| 70 | This is used to determine the up-class for the entity instance object. |
---|
| 71 | @return The class type: SIMPLE for entity instances with no up-class. */ |
---|
| 72 | virtual Type GetType() const { return SIMPLE; } |
---|
| 73 | |
---|
| 74 | /** Retrieves the instantiated entity. |
---|
| 75 | @return The instantiated entity. */ |
---|
| 76 | inline FCDEntity* GetEntity() { return entity; } |
---|
| 77 | inline const FCDEntity* GetEntity() const { return entity; } /**< See above. */ |
---|
| 78 | |
---|
| 79 | /** [INTERNAL] Reads in the entity instance from a given COLLADA XML tree node.
|
---|
| 80 | @param UNUSED The COLLADA XML tree node.
|
---|
| 81 | @return The status of the import. If the status is not successful,
|
---|
| 82 | it may be dangerous to extract information from the instance.*/ |
---|
| 83 | virtual FUStatus LoadFromXML(xmlNode* UNUSED(instanceNode)) { return FUStatus(true); } |
---|
| 84 | |
---|
| 85 | /** [INTERNAL] Writes out the entity instance to the given COLLADA XML tree node.
|
---|
| 86 | @param parentNode The COLLADA XML parent node in which to insert the node.
|
---|
| 87 | @return The created XML tree node. */
|
---|
| 88 | virtual xmlNode* WriteToXML(xmlNode* parentNode) const; |
---|
| 89 | |
---|
| 90 | protected: |
---|
| 91 | /** Sets the instantiated entity. |
---|
| 92 | This is used in up-classes to support different instantiation schemes. |
---|
| 93 | @param _entity The instantiated entity. */ |
---|
| 94 | inline void SetEntity(FCDEntity* _entity) { entity = _entity; } |
---|
| 95 | |
---|
| 96 | /** [INTERNAL] Retrieves the COLLADA name for the instantiation of a given entity type. |
---|
| 97 | @param type The entity class type. |
---|
| 98 | @return The COLLADA name to instantiate an entity of the given class type. */ |
---|
| 99 | static const char* GetInstanceClassType(FCDEntity::Type type); |
---|
| 100 | }; |
---|
| 101 | |
---|
| 102 | #endif // _FCD_ENTITY_INSTANCE_H_ |
---|