[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 FCDController.h
|
---|
| 14 | This file contains the FCDController class.
|
---|
| 15 | */
|
---|
| 16 |
|
---|
| 17 | #ifndef _FCD_CONTROLLER_H_
|
---|
| 18 | #define _FCD_CONTROLLER_H_
|
---|
| 19 |
|
---|
| 20 | #include "FCDocument/FCDEntity.h"
|
---|
| 21 |
|
---|
| 22 | class FCDocument;
|
---|
| 23 | class FCDSkinController;
|
---|
| 24 | class FCDMorphController;
|
---|
| 25 |
|
---|
| 26 | /**
|
---|
| 27 | A generic COLLADA controller.
|
---|
| 28 | A COLLADA controller is used to influence a mesh.
|
---|
| 29 | COLLADA defines two types of controller:
|
---|
| 30 | skins (FCDSkinController) and morphers (FCDMorphController).
|
---|
| 31 |
|
---|
| 32 | @ingroup FCDGeometry
|
---|
| 33 | */
|
---|
| 34 | class FCOLLADA_EXPORT FCDController : public FCDEntity
|
---|
| 35 | {
|
---|
| 36 | private:
|
---|
| 37 | DeclareObjectType;
|
---|
| 38 |
|
---|
| 39 | FCDSkinController* skinController;
|
---|
| 40 | FCDMorphController* morphController;
|
---|
| 41 |
|
---|
| 42 | string targetId; // COLLADA 1.3 backward compatibility
|
---|
| 43 |
|
---|
| 44 | public:
|
---|
| 45 | /** Constructor: do not use directly.
|
---|
| 46 | Instead, use the FCDLibrary::AddEntity function.
|
---|
| 47 | @param document The COLLADA document that owns the controller. */
|
---|
| 48 | FCDController(FCDocument* document);
|
---|
| 49 |
|
---|
| 50 | /** Destructor: do not use directly.
|
---|
| 51 | Instead, use the FCDLibrary::ReleaseEntity function. */
|
---|
| 52 | virtual ~FCDController();
|
---|
| 53 |
|
---|
| 54 | /** Retrieves the entity class type.
|
---|
| 55 | This function is a part of the FCDEntity interface.
|
---|
| 56 | @return The entity class type: CONTROLLER. */
|
---|
| 57 | virtual Type GetType() const { return CONTROLLER; };
|
---|
| 58 |
|
---|
| 59 | /** Retrieves whether this controller is a skin controller.
|
---|
| 60 | @return Whether this controller is a skin controller. */
|
---|
| 61 | bool HasSkinController() const { return skinController != NULL; }
|
---|
| 62 |
|
---|
| 63 | /** Retrieves whether this controller is a morph controller.
|
---|
| 64 | @return Whether this controller is a morph controller. */
|
---|
| 65 | bool HasMorphController() const { return morphController != NULL; }
|
---|
| 66 |
|
---|
| 67 | /** Sets the type of this controller to a skin controller.
|
---|
| 68 | This function will release any previously created morpher or skin.
|
---|
| 69 | @return The new skin controller. */
|
---|
| 70 | FCDSkinController* CreateSkinController();
|
---|
| 71 |
|
---|
| 72 | /** Sets the type of this controller to a morph controller.
|
---|
| 73 | This function will release any previously created morpher or skin.
|
---|
| 74 | @return The new morph controller. */
|
---|
| 75 | FCDMorphController* CreateMorphController();
|
---|
| 76 |
|
---|
| 77 | /** Retrieves the skin controller.
|
---|
| 78 | This pointer is only valid for skins. To verify that this is a skin,
|
---|
| 79 | check the HasSkinController function.
|
---|
| 80 | @return The skin controller. This pointer will be NULL, if the controller
|
---|
| 81 | is not a skin. */
|
---|
| 82 | FCDSkinController* GetSkinController() { return skinController; }
|
---|
| 83 | const FCDSkinController* GetSkinController() const { return skinController; } /**< See above. */
|
---|
| 84 |
|
---|
| 85 | /** Retrieves the morph controller.
|
---|
| 86 | This pointer is only valid for skins. To verify that this is a morpher,
|
---|
| 87 | check the HasMorphController function.
|
---|
| 88 | @return The morph controller. This pointer will be NULL, if the controller
|
---|
| 89 | is not a morpher. */
|
---|
| 90 | FCDMorphController* GetMorphController() { return morphController; }
|
---|
| 91 | const FCDMorphController* GetMorphController() const { return morphController; } /**< See above. */
|
---|
| 92 |
|
---|
| 93 | /** Retrieves the base target entity for this controller.
|
---|
| 94 | The base target entity may be another controller or a geometry entity.
|
---|
| 95 | To change the base target, use the FCDMorphController::SetBaseTarget
|
---|
| 96 | or the FCDSkinController::SetTarget functions.
|
---|
| 97 | @return The base target entity. This pointer will be NULL
|
---|
| 98 | if no base target is defined. */
|
---|
| 99 | FCDEntity* GetBaseTarget();
|
---|
| 100 | const FCDEntity* GetBaseTarget() const; /**< See above. */
|
---|
| 101 |
|
---|
| 102 | /** Retrieves the base target geometry for this controller.
|
---|
| 103 | Controllers can be chained together. This function allows
|
---|
| 104 | you to retrieve the base target geometry, if there is one.
|
---|
| 105 | @return The base target geometry. This pointer will be NULL
|
---|
| 106 | if no base target is defined or if the base target entity
|
---|
| 107 | is not a geometry. */
|
---|
| 108 | FCDGeometry* GetBaseGeometry();
|
---|
| 109 | const FCDGeometry* GetBaseGeometry() const; /**< See above. */
|
---|
| 110 |
|
---|
| 111 | /** [INTERNAL] Retrieves the COLLADA id of the target entity.
|
---|
| 112 | This value is only useful for COLLADA 1.3 backward compatibility.
|
---|
| 113 | For more recent COLLADA documents, this value is unused.
|
---|
| 114 | @return The COLLADA id of the target entity. */
|
---|
| 115 | const string& GetTargetId() const { return targetId; }
|
---|
| 116 |
|
---|
| 117 | /** [INTERNAL] Reads in the \<controller\> element from a given COLLADA XML tree node.
|
---|
| 118 | @param controllerNode The COLLADA XML tree node.
|
---|
| 119 | @return The status of the import. If the status is not successful,
|
---|
| 120 | it may be dangerous to extract information from the controller.*/
|
---|
| 121 | virtual FUStatus LoadFromXML(xmlNode* controllerNode);
|
---|
| 122 |
|
---|
| 123 | /** [INTERNAL] Writes out the \<controller\> element to the given COLLADA XML tree node.
|
---|
| 124 | @param parentNode The COLLADA XML parent node in which to insert the controller information.
|
---|
| 125 | @return The created element XML tree node. */
|
---|
| 126 | virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
|
---|
| 127 |
|
---|
| 128 | /** [INTERNAL] Links the controller entities with their many targets/influences.
|
---|
| 129 | This function is executed for all the controllers, after the scene graph has been imported.
|
---|
| 130 | It is mainly used to link the skin and its bones.
|
---|
| 131 | @return The status of the linkage.*/
|
---|
| 132 | FUStatus Link();
|
---|
| 133 | };
|
---|
| 134 |
|
---|
| 135 | #endif // _FCD_CONTROLLER_H_
|
---|
| 136 |
|
---|