]> git.lizzy.rs Git - irrlicht.git/blob - include/IAnimatedMeshSceneNode.h
Unify & improve log messages
[irrlicht.git] / include / IAnimatedMeshSceneNode.h
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt\r
2 // This file is part of the "Irrlicht Engine".\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h\r
4 \r
5 #ifndef __I_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__\r
6 #define __I_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__\r
7 \r
8 #include "ISceneNode.h"\r
9 #include "IBoneSceneNode.h"\r
10 #include "IAnimatedMesh.h"\r
11 \r
12 namespace irr\r
13 {\r
14 namespace scene\r
15 {\r
16         enum E_JOINT_UPDATE_ON_RENDER\r
17         {\r
18                 //! do nothing\r
19                 EJUOR_NONE = 0,\r
20 \r
21                 //! get joints positions from the mesh (for attached nodes, etc)\r
22                 EJUOR_READ,\r
23 \r
24                 //! control joint positions in the mesh (eg. ragdolls, or set the animation from animateJoints() )\r
25                 EJUOR_CONTROL\r
26         };\r
27 \r
28 \r
29         class IAnimatedMeshSceneNode;\r
30 \r
31         //! Callback interface for catching events of ended animations.\r
32         /** Implement this interface and use\r
33         IAnimatedMeshSceneNode::setAnimationEndCallback to be able to\r
34         be notified if an animation playback has ended.\r
35         **/\r
36         class IAnimationEndCallBack : public virtual IReferenceCounted\r
37         {\r
38         public:\r
39 \r
40                 //! Will be called when the animation playback has ended.\r
41                 /** See IAnimatedMeshSceneNode::setAnimationEndCallback for\r
42                 more information.\r
43                 \param node: Node of which the animation has ended. */\r
44                 virtual void OnAnimationEnd(IAnimatedMeshSceneNode* node) = 0;\r
45         };\r
46 \r
47         //! Scene node capable of displaying an animated mesh.\r
48         class IAnimatedMeshSceneNode : public ISceneNode\r
49         {\r
50         public:\r
51 \r
52                 //! Constructor\r
53                 IAnimatedMeshSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,\r
54                         const core::vector3df& position = core::vector3df(0,0,0),\r
55                         const core::vector3df& rotation = core::vector3df(0,0,0),\r
56                         const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f))\r
57                         : ISceneNode(parent, mgr, id, position, rotation, scale) {}\r
58 \r
59                 //! Destructor\r
60                 virtual ~IAnimatedMeshSceneNode() {}\r
61 \r
62                 //! Sets the current frame number.\r
63                 /** From now on the animation is played from this frame.\r
64                 \param frame: Number of the frame to let the animation be started from.\r
65                 The frame number must be a valid frame number of the IMesh used by this\r
66                 scene node. Set IAnimatedMesh::getMesh() for details. */\r
67                 virtual void setCurrentFrame(f32 frame) = 0;\r
68 \r
69                 //! Sets the frame numbers between the animation is looped.\r
70                 /** The default is 0 to getFrameCount()-1 of the mesh.\r
71                 Number of played frames is end-start.\r
72                 It interpolates toward the last frame but stops when it is reached.\r
73                 It does not interpolate back to start even when looping.\r
74                 Looping animations should ensure last and first frame-key are identical.\r
75                 \param begin: Start frame number of the loop.\r
76                 \param end: End frame number of the loop.\r
77                 \return True if successful, false if not. */\r
78                 virtual bool setFrameLoop(s32 begin, s32 end) = 0;\r
79 \r
80                 //! Sets the speed with which the animation is played.\r
81                 /** \param framesPerSecond: Frames per second played. */\r
82                 virtual void setAnimationSpeed(f32 framesPerSecond) = 0;\r
83 \r
84                 //! Gets the speed with which the animation is played.\r
85                 /** \return Frames per second played. */\r
86                 virtual f32 getAnimationSpeed() const =0;\r
87 \r
88                 //! Get a pointer to a joint in the mesh (if the mesh is a bone based mesh).\r
89                 /** With this method it is possible to attach scene nodes to\r
90                 joints for example possible to attach a weapon to the left hand\r
91                 of an animated model. This example shows how:\r
92                 \code\r
93                 ISceneNode* hand =\r
94                         yourAnimatedMeshSceneNode->getJointNode("LeftHand");\r
95                 hand->addChild(weaponSceneNode);\r
96                 \endcode\r
97                 Please note that the joint returned by this method may not exist\r
98                 before this call and the joints in the node were created by it.\r
99                 \param jointName: Name of the joint.\r
100                 \return Pointer to the scene node which represents the joint\r
101                 with the specified name. Returns 0 if the contained mesh is not\r
102                 an skinned mesh or the name of the joint could not be found. */\r
103                 virtual IBoneSceneNode* getJointNode(const c8* jointName)=0;\r
104 \r
105                 //! same as getJointNode(const c8* jointName), but based on id\r
106                 virtual IBoneSceneNode* getJointNode(u32 jointID) = 0;\r
107 \r
108                 //! Gets joint count.\r
109                 /** \return Amount of joints in the mesh. */\r
110                 virtual u32 getJointCount() const = 0;\r
111 \r
112                 //! Returns the currently displayed frame number.\r
113                 virtual f32 getFrameNr() const = 0;\r
114                 //! Returns the current start frame number.\r
115                 virtual s32 getStartFrame() const = 0;\r
116                 //! Returns the current end frame number.\r
117                 virtual s32 getEndFrame() const = 0;\r
118 \r
119                 //! Sets looping mode which is on by default.\r
120                 /** If set to false, animations will not be played looped. */\r
121                 virtual void setLoopMode(bool playAnimationLooped) = 0;\r
122 \r
123                 //! returns the current loop mode\r
124                 /** When true the animations are played looped */\r
125                 virtual bool getLoopMode() const = 0;\r
126 \r
127                 //! Sets a callback interface which will be called if an animation playback has ended.\r
128                 /** Set this to 0 to disable the callback again.\r
129                 Please note that this will only be called when in non looped\r
130                 mode, see IAnimatedMeshSceneNode::setLoopMode(). */\r
131                 virtual void setAnimationEndCallback(IAnimationEndCallBack* callback=0) = 0;\r
132 \r
133                 //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style.\r
134                 /** In this way it is possible to change the materials a mesh\r
135                 causing all mesh scene nodes referencing this mesh to change\r
136                 too. */\r
137                 virtual void setReadOnlyMaterials(bool readonly) = 0;\r
138 \r
139                 //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style\r
140                 virtual bool isReadOnlyMaterials() const = 0;\r
141 \r
142                 //! Sets a new mesh\r
143                 virtual void setMesh(IAnimatedMesh* mesh) = 0;\r
144 \r
145                 //! Returns the current mesh\r
146                 virtual IAnimatedMesh* getMesh(void) = 0;\r
147 \r
148                 //! Set how the joints should be updated on render\r
149                 virtual void setJointMode(E_JOINT_UPDATE_ON_RENDER mode)=0;\r
150 \r
151                 //! Sets the transition time in seconds\r
152                 /** Note: This needs to enable joints, and setJointmode set to\r
153                 EJUOR_CONTROL. You must call animateJoints(), or the mesh will\r
154                 not animate. */\r
155                 virtual void setTransitionTime(f32 Time) =0;\r
156 \r
157                 //! animates the joints in the mesh based on the current frame.\r
158                 /** Also takes in to account transitions. */\r
159                 virtual void animateJoints(bool CalculateAbsolutePositions=true) = 0;\r
160 \r
161                 //! render mesh ignoring its transformation.\r
162                 /** Culling is unaffected. */\r
163                 virtual void setRenderFromIdentity( bool On )=0;\r
164 \r
165                 //! Creates a clone of this scene node and its children.\r
166                 /** \param newParent An optional new parent.\r
167                 \param newManager An optional new scene manager.\r
168                 \return The newly created clone of this node. */\r
169                 virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0) = 0;\r
170 \r
171         };\r
172 \r
173 } // end namespace scene\r
174 } // end namespace irr\r
175 \r
176 #endif\r
177 \r