]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/CAnimatedMeshSceneNode.h
Add OpenGL3 renderer
[irrlicht.git] / source / Irrlicht / CAnimatedMeshSceneNode.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 __C_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__\r
6 #define __C_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__\r
7 \r
8 #include "IAnimatedMeshSceneNode.h"\r
9 #include "IAnimatedMesh.h"\r
10 \r
11 #include "matrix4.h"\r
12 \r
13 \r
14 namespace irr\r
15 {\r
16 namespace scene\r
17 {\r
18         class IDummyTransformationSceneNode;\r
19 \r
20         class CAnimatedMeshSceneNode : public IAnimatedMeshSceneNode\r
21         {\r
22         public:\r
23 \r
24                 //! constructor\r
25                 CAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent, ISceneManager* mgr,     s32 id,\r
26                         const core::vector3df& position = core::vector3df(0,0,0),\r
27                         const core::vector3df& rotation = core::vector3df(0,0,0),\r
28                         const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f));\r
29 \r
30                 //! destructor\r
31                 virtual ~CAnimatedMeshSceneNode();\r
32 \r
33                 //! sets the current frame. from now on the animation is played from this frame.\r
34                 void setCurrentFrame(f32 frame) override;\r
35 \r
36                 //! frame\r
37                 void OnRegisterSceneNode() override;\r
38 \r
39                 //! OnAnimate() is called just before rendering the whole scene.\r
40                 void OnAnimate(u32 timeMs) override;\r
41 \r
42                 //! renders the node.\r
43                 void render() override;\r
44 \r
45                 //! returns the axis aligned bounding box of this node\r
46                 const core::aabbox3d<f32>& getBoundingBox() const override;\r
47 \r
48                 //! sets the frames between the animation is looped.\r
49                 //! the default is 0 - MaximalFrameCount of the mesh.\r
50                 //! NOTE: setMesh will also change this value and set it to the full range of animations of the mesh\r
51                 bool setFrameLoop(s32 begin, s32 end) override;\r
52 \r
53                 //! Sets looping mode which is on by default. If set to false,\r
54                 //! animations will not be looped.\r
55                 void setLoopMode(bool playAnimationLooped) override;\r
56 \r
57                 //! returns the current loop mode\r
58                 bool getLoopMode() const override;\r
59 \r
60                 //! Sets a callback interface which will be called if an animation\r
61                 //! playback has ended. Set this to 0 to disable the callback again.\r
62                 void setAnimationEndCallback(IAnimationEndCallBack* callback=0) override;\r
63 \r
64                 //! sets the speed with which the animation is played\r
65                 //! NOTE: setMesh will also change this value and set it to the default speed of the mesh\r
66                 void setAnimationSpeed(f32 framesPerSecond) override;\r
67 \r
68                 //! gets the speed with which the animation is played\r
69                 f32 getAnimationSpeed() const override;\r
70 \r
71                 //! returns the material based on the zero based index i. To get the amount\r
72                 //! of materials used by this scene node, use getMaterialCount().\r
73                 //! This function is needed for inserting the node into the scene hierarchy on a\r
74                 //! optimal position for minimizing renderstate changes, but can also be used\r
75                 //! to directly modify the material of a scene node.\r
76                 video::SMaterial& getMaterial(u32 i) override;\r
77 \r
78                 //! returns amount of materials used by this scene node.\r
79                 u32 getMaterialCount() const override;\r
80 \r
81                 //! Returns a pointer to a child node, which has the same transformation as\r
82                 //! the corresponding joint, if the mesh in this scene node is a skinned mesh.\r
83                 IBoneSceneNode* getJointNode(const c8* jointName) override;\r
84 \r
85                 //! same as getJointNode(const c8* jointName), but based on id\r
86                 IBoneSceneNode* getJointNode(u32 jointID) override;\r
87 \r
88                 //! Gets joint count.\r
89                 u32 getJointCount() const override;\r
90 \r
91                 //! Removes a child from this scene node.\r
92                 //! Implemented here, to be able to remove the shadow properly, if there is one,\r
93                 //! or to remove attached child.\r
94                 bool removeChild(ISceneNode* child) override;\r
95 \r
96                 //! Returns the current displayed frame number.\r
97                 f32 getFrameNr() const override;\r
98                 //! Returns the current start frame number.\r
99                 s32 getStartFrame() const override;\r
100                 //! Returns the current end frame number.\r
101                 s32 getEndFrame() const override;\r
102 \r
103                 //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style.\r
104                 /* In this way it is possible to change the materials a mesh causing all mesh scene nodes\r
105                 referencing this mesh to change too. */\r
106                 void setReadOnlyMaterials(bool readonly) override;\r
107 \r
108                 //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style\r
109                 bool isReadOnlyMaterials() const override;\r
110 \r
111                 //! Sets a new mesh\r
112                 void setMesh(IAnimatedMesh* mesh) override;\r
113 \r
114                 //! Returns the current mesh\r
115                 IAnimatedMesh* getMesh(void) override { return Mesh; }\r
116 \r
117                 //! Returns type of the scene node\r
118                 ESCENE_NODE_TYPE getType() const override { return ESNT_ANIMATED_MESH; }\r
119 \r
120                 //! updates the absolute position based on the relative and the parents position\r
121                 void updateAbsolutePosition() override;\r
122 \r
123 \r
124                 //! Set the joint update mode (0-unused, 1-get joints only, 2-set joints only, 3-move and set)\r
125                 void setJointMode(E_JOINT_UPDATE_ON_RENDER mode) override;\r
126 \r
127                 //! Sets the transition time in seconds (note: This needs to enable joints, and setJointmode maybe set to 2)\r
128                 //! you must call animateJoints(), or the mesh will not animate\r
129                 void setTransitionTime(f32 Time) override;\r
130 \r
131                 //! updates the joint positions of this mesh\r
132                 void animateJoints(bool CalculateAbsolutePositions=true) override;\r
133 \r
134                 //! render mesh ignoring its transformation. Used with ragdolls. (culling is unaffected)\r
135                 void setRenderFromIdentity( bool On ) override;\r
136 \r
137                 //! Creates a clone of this scene node and its children.\r
138                 /** \param newParent An optional new parent.\r
139                 \param newManager An optional new scene manager.\r
140                 \return The newly created clone of this node. */\r
141                 ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0) override;\r
142 \r
143         private:\r
144 \r
145                 //! Get a static mesh for the current frame of this animated mesh\r
146                 IMesh* getMeshForCurrentFrame();\r
147 \r
148                 void buildFrameNr(u32 timeMs);\r
149                 void checkJoints();\r
150                 void beginTransition();\r
151 \r
152                 core::array<video::SMaterial> Materials;\r
153                 core::aabbox3d<f32> Box;\r
154                 IAnimatedMesh* Mesh;\r
155 \r
156                 s32 StartFrame;\r
157                 s32 EndFrame;\r
158                 f32 FramesPerSecond;\r
159                 f32 CurrentFrameNr;\r
160 \r
161                 u32 LastTimeMs;\r
162                 u32 TransitionTime; //Transition time in millisecs\r
163                 f32 Transiting; //is mesh transiting (plus cache of TransitionTime)\r
164                 f32 TransitingBlend; //0-1, calculated on buildFrameNr\r
165 \r
166                 //0-unused, 1-get joints only, 2-set joints only, 3-move and set\r
167                 E_JOINT_UPDATE_ON_RENDER JointMode;\r
168                 bool JointsUsed;\r
169 \r
170                 bool Looping;\r
171                 bool ReadOnlyMaterials;\r
172                 bool RenderFromIdentity;\r
173 \r
174                 IAnimationEndCallBack* LoopCallBack;\r
175                 s32 PassCount;\r
176 \r
177                 core::array<IBoneSceneNode* > JointChildSceneNodes;\r
178                 core::array<core::matrix4> PretransitingSave;\r
179         };\r
180 \r
181 } // end namespace scene\r
182 } // end namespace irr\r
183 \r
184 #endif\r
185 \r