]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/CAnimatedMeshSceneNode.h
Fix some more problems with OSX build file.
[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                 virtual void setCurrentFrame(f32 frame) _IRR_OVERRIDE_;\r
35 \r
36                 //! frame\r
37                 virtual void OnRegisterSceneNode() _IRR_OVERRIDE_;\r
38 \r
39                 //! OnAnimate() is called just before rendering the whole scene.\r
40                 virtual void OnAnimate(u32 timeMs) _IRR_OVERRIDE_;\r
41 \r
42                 //! renders the node.\r
43                 virtual void render() _IRR_OVERRIDE_;\r
44 \r
45                 //! returns the axis aligned bounding box of this node\r
46                 virtual const core::aabbox3d<f32>& getBoundingBox() const _IRR_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                 virtual bool setFrameLoop(s32 begin, s32 end) _IRR_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                 virtual void setLoopMode(bool playAnimationLooped) _IRR_OVERRIDE_;\r
56 \r
57                 //! returns the current loop mode\r
58                 virtual bool getLoopMode() const _IRR_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                 virtual void setAnimationEndCallback(IAnimationEndCallBack* callback=0) _IRR_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                 virtual void setAnimationSpeed(f32 framesPerSecond) _IRR_OVERRIDE_;\r
67 \r
68                 //! gets the speed with which the animation is played\r
69                 virtual f32 getAnimationSpeed() const _IRR_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                 virtual video::SMaterial& getMaterial(u32 i) _IRR_OVERRIDE_;\r
77 \r
78                 //! returns amount of materials used by this scene node.\r
79                 virtual u32 getMaterialCount() const _IRR_OVERRIDE_;\r
80 \r
81                 //! Creates shadow volume scene node as child of this node\r
82                 //! and returns a pointer to it.\r
83                 virtual IShadowVolumeSceneNode* addShadowVolumeSceneNode(const IMesh* shadowMesh,\r
84                         s32 id, bool zfailmethod=true, f32 infinity=1000.0f) _IRR_OVERRIDE_;\r
85 \r
86                 //! Returns a pointer to a child node, which has the same transformation as\r
87                 //! the corresponding joint, if the mesh in this scene node is a skinned mesh.\r
88                 virtual IBoneSceneNode* getJointNode(const c8* jointName) _IRR_OVERRIDE_;\r
89 \r
90                 //! same as getJointNode(const c8* jointName), but based on id\r
91                 virtual IBoneSceneNode* getJointNode(u32 jointID) _IRR_OVERRIDE_;\r
92 \r
93                 //! Gets joint count.\r
94                 virtual u32 getJointCount() const _IRR_OVERRIDE_;\r
95 \r
96                 //! Removes a child from this scene node.\r
97                 //! Implemented here, to be able to remove the shadow properly, if there is one,\r
98                 //! or to remove attached child.\r
99                 virtual bool removeChild(ISceneNode* child) _IRR_OVERRIDE_;\r
100 \r
101                 //! Starts a MD2 animation.\r
102                 virtual bool setMD2Animation(EMD2_ANIMATION_TYPE anim) _IRR_OVERRIDE_;\r
103 \r
104                 //! Starts a special MD2 animation.\r
105                 virtual bool setMD2Animation(const c8* animationName) _IRR_OVERRIDE_;\r
106 \r
107                 //! Returns the current displayed frame number.\r
108                 virtual f32 getFrameNr() const _IRR_OVERRIDE_;\r
109                 //! Returns the current start frame number.\r
110                 virtual s32 getStartFrame() const _IRR_OVERRIDE_;\r
111                 //! Returns the current end frame number.\r
112                 virtual s32 getEndFrame() const _IRR_OVERRIDE_;\r
113 \r
114                 //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style.\r
115                 /* In this way it is possible to change the materials a mesh causing all mesh scene nodes\r
116                 referencing this mesh to change too. */\r
117                 virtual void setReadOnlyMaterials(bool readonly) _IRR_OVERRIDE_;\r
118 \r
119                 //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style\r
120                 virtual bool isReadOnlyMaterials() const _IRR_OVERRIDE_;\r
121 \r
122                 //! Sets a new mesh\r
123                 virtual void setMesh(IAnimatedMesh* mesh) _IRR_OVERRIDE_;\r
124 \r
125                 //! Returns the current mesh\r
126                 virtual IAnimatedMesh* getMesh(void) _IRR_OVERRIDE_ { return Mesh; }\r
127 \r
128                 //! Writes attributes of the scene node.\r
129                 virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const _IRR_OVERRIDE_;\r
130 \r
131                 //! Reads attributes of the scene node.\r
132                 virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) _IRR_OVERRIDE_;\r
133 \r
134                 //! Returns type of the scene node\r
135                 virtual ESCENE_NODE_TYPE getType() const _IRR_OVERRIDE_ { return ESNT_ANIMATED_MESH; }\r
136 \r
137                 // returns the absolute transformation for a special MD3 Tag if the mesh is a md3 mesh,\r
138                 // or the absolutetransformation if it's a normal scenenode\r
139                 const SMD3QuaternionTag* getMD3TagTransformation( const core::stringc & tagname) _IRR_OVERRIDE_;\r
140 \r
141                 //! updates the absolute position based on the relative and the parents position\r
142                 virtual void updateAbsolutePosition() _IRR_OVERRIDE_;\r
143 \r
144 \r
145                 //! Set the joint update mode (0-unused, 1-get joints only, 2-set joints only, 3-move and set)\r
146                 virtual void setJointMode(E_JOINT_UPDATE_ON_RENDER mode) _IRR_OVERRIDE_;\r
147 \r
148                 //! Sets the transition time in seconds (note: This needs to enable joints, and setJointmode maybe set to 2)\r
149                 //! you must call animateJoints(), or the mesh will not animate\r
150                 virtual void setTransitionTime(f32 Time) _IRR_OVERRIDE_;\r
151 \r
152                 //! updates the joint positions of this mesh\r
153                 virtual void animateJoints(bool CalculateAbsolutePositions=true) _IRR_OVERRIDE_;\r
154 \r
155                 //! render mesh ignoring its transformation. Used with ragdolls. (culling is unaffected)\r
156                 virtual void setRenderFromIdentity( bool On ) _IRR_OVERRIDE_;\r
157 \r
158                 //! Creates a clone of this scene node and its children.\r
159                 /** \param newParent An optional new parent.\r
160                 \param newManager An optional new scene manager.\r
161                 \return The newly created clone of this node. */\r
162                 virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0) _IRR_OVERRIDE_;\r
163 \r
164         private:\r
165 \r
166                 //! Get a static mesh for the current frame of this animated mesh\r
167                 IMesh* getMeshForCurrentFrame();\r
168 \r
169                 void buildFrameNr(u32 timeMs);\r
170                 void checkJoints();\r
171                 void beginTransition();\r
172 \r
173                 core::array<video::SMaterial> Materials;\r
174                 core::aabbox3d<f32> Box;\r
175                 IAnimatedMesh* Mesh;\r
176 \r
177                 s32 StartFrame;\r
178                 s32 EndFrame;\r
179                 f32 FramesPerSecond;\r
180                 f32 CurrentFrameNr;\r
181 \r
182                 u32 LastTimeMs;\r
183                 u32 TransitionTime; //Transition time in millisecs\r
184                 f32 Transiting; //is mesh transiting (plus cache of TransitionTime)\r
185                 f32 TransitingBlend; //0-1, calculated on buildFrameNr\r
186 \r
187                 //0-unused, 1-get joints only, 2-set joints only, 3-move and set\r
188                 E_JOINT_UPDATE_ON_RENDER JointMode;\r
189                 bool JointsUsed;\r
190 \r
191                 bool Looping;\r
192                 bool ReadOnlyMaterials;\r
193                 bool RenderFromIdentity;\r
194 \r
195                 IAnimationEndCallBack* LoopCallBack;\r
196                 s32 PassCount;\r
197 \r
198                 IShadowVolumeSceneNode* Shadow;\r
199 \r
200                 core::array<IBoneSceneNode* > JointChildSceneNodes;\r
201                 core::array<core::matrix4> PretransitingSave;\r
202 \r
203                 // Quake3 Model\r
204                 struct SMD3Special : public virtual IReferenceCounted\r
205                 {\r
206                         core::stringc Tagname;\r
207                         SMD3QuaternionTagList AbsoluteTagList;\r
208 \r
209                         SMD3Special & operator = (const SMD3Special & copyMe)\r
210                         {\r
211                                 Tagname = copyMe.Tagname;\r
212                                 AbsoluteTagList = copyMe.AbsoluteTagList;\r
213                                 return *this;\r
214                         }\r
215                 };\r
216                 SMD3Special *MD3Special;\r
217         };\r
218 \r
219 } // end namespace scene\r
220 } // end namespace irr\r
221 \r
222 #endif\r
223 \r