/* Copyright (C) 2005-2006 Feeling Software Inc. MIT License: http://www.opensource.org/licenses/mit-license.php */ /* Based on the FS Import classes: Copyright (C) 2005-2006 Feeling Software Inc Copyright (C) 2005-2006 Autodesk Media Entertainment MIT License: http://www.opensource.org/licenses/mit-license.php */ /** @file FCDEntityInstance.h This file contains the FCDEntityInstance class. */ #ifndef _FCD_ENTITY_INSTANCE_H_ #define _FCD_ENTITY_INSTANCE_H_ class FCDocument; class FCDEntity; #include "FCDocument/FCDObject.h" #include "FCDocument/FCDEntity.h" /** A COLLADA entity instance. COLLADA allows for quite a bit of per-instance settings for entities. This information is held by the up-classes of this class. This base class is simply meant to hold the entity that is instantiated. @ingroup FCDocument */ class FCOLLADA_EXPORT FCDEntityInstance : public FCDObject { public: /** The class type of the entity instance class. Used this information to up-cast an entity instance. */ enum Type { SIMPLE, /**< A simple entity instance that has no per-instance information. This is used for lights and cameras in the visual scene graph and there is no up-class. */ EXTERNAL_REFERENCE, /**< An external reference(FCDExternalReference). */ GEOMETRY, /**< A geometry entity(FCDGeometryInstance). */ MATERIAL, /**< A material entity(FCDMaterialInstance). */ PHYSICS_MODEL, /**< A physics model(FCDPhysicsModelInstance). */ PHYSICS_RIGID_BODY, /**< A physics rigid body(FCDPhysicsRigidBodyInstance). */ PHYSICS_RIGID_CONSTRAINT /**< A physics rigid constraint(FCDPhysicsRigidConstraintInstance). */ }; private: DeclareObjectType; FCDEntity* entity; public: /** Constructor: do not use directly. Instead, use the appropriate allocation function. For scene node instance: FCDSceneNode::AddInstance. @param document The COLLADA document that owns the entity instance. @param entity The entity to instantiate. This pointer will be NULL for some up-classes where the entity instantiate is more complex. */ FCDEntityInstance(FCDocument* document, FCDEntity* entity = NULL); /** Destructor: do not use directly. Instead, use the appropriate release funciton. For scene node instances: FCDSceneNode::ReleaseInstance. */ virtual ~FCDEntityInstance(); /** Retrieves the entity instance class type. This is used to determine the up-class for the entity instance object. @return The class type: SIMPLE for entity instances with no up-class. */ virtual Type GetType() const { return SIMPLE; } /** Retrieves the instantiated entity. @return The instantiated entity. */ inline FCDEntity* GetEntity() { return entity; } inline const FCDEntity* GetEntity() const { return entity; } /**< See above. */ /** [INTERNAL] Reads in the entity instance from a given COLLADA XML tree node. @param UNUSED The COLLADA XML tree node. @return The status of the import. If the status is not successful, it may be dangerous to extract information from the instance.*/ virtual FUStatus LoadFromXML(xmlNode* UNUSED(instanceNode)) { return FUStatus(true); } /** [INTERNAL] Writes out the entity instance to the given COLLADA XML tree node. @param parentNode The COLLADA XML parent node in which to insert the node. @return The created XML tree node. */ virtual xmlNode* WriteToXML(xmlNode* parentNode) const; protected: /** Sets the instantiated entity. This is used in up-classes to support different instantiation schemes. @param _entity The instantiated entity. */ inline void SetEntity(FCDEntity* _entity) { entity = _entity; } /** [INTERNAL] Retrieves the COLLADA name for the instantiation of a given entity type. @param type The entity class type. @return The COLLADA name to instantiate an entity of the given class type. */ static const char* GetInstanceClassType(FCDEntity::Type type); }; #endif // _FCD_ENTITY_INSTANCE_H_