diff options
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CAnimatedMeshSceneNode.h')
-rw-r--r-- | src/others/irrlicht-1.8.1/source/Irrlicht/CAnimatedMeshSceneNode.h | 227 |
1 files changed, 227 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CAnimatedMeshSceneNode.h b/src/others/irrlicht-1.8.1/source/Irrlicht/CAnimatedMeshSceneNode.h new file mode 100644 index 0000000..522393d --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CAnimatedMeshSceneNode.h | |||
@@ -0,0 +1,227 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt | ||
2 | // This file is part of the "Irrlicht Engine". | ||
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | ||
4 | |||
5 | #ifndef __C_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__ | ||
6 | #define __C_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__ | ||
7 | |||
8 | #include "IAnimatedMeshSceneNode.h" | ||
9 | #include "IAnimatedMesh.h" | ||
10 | |||
11 | #include "matrix4.h" | ||
12 | |||
13 | |||
14 | namespace irr | ||
15 | { | ||
16 | namespace scene | ||
17 | { | ||
18 | class IDummyTransformationSceneNode; | ||
19 | |||
20 | class CAnimatedMeshSceneNode : public IAnimatedMeshSceneNode | ||
21 | { | ||
22 | public: | ||
23 | |||
24 | //! constructor | ||
25 | CAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id, | ||
26 | const core::vector3df& position = core::vector3df(0,0,0), | ||
27 | const core::vector3df& rotation = core::vector3df(0,0,0), | ||
28 | const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); | ||
29 | |||
30 | //! destructor | ||
31 | virtual ~CAnimatedMeshSceneNode(); | ||
32 | |||
33 | //! sets the current frame. from now on the animation is played from this frame. | ||
34 | virtual void setCurrentFrame(f32 frame); | ||
35 | |||
36 | //! frame | ||
37 | virtual void OnRegisterSceneNode(); | ||
38 | |||
39 | //! OnAnimate() is called just before rendering the whole scene. | ||
40 | virtual void OnAnimate(u32 timeMs); | ||
41 | |||
42 | //! renders the node. | ||
43 | virtual void render(); | ||
44 | |||
45 | //! returns the axis aligned bounding box of this node | ||
46 | virtual const core::aabbox3d<f32>& getBoundingBox() const; | ||
47 | |||
48 | //! sets the frames between the animation is looped. | ||
49 | //! the default is 0 - MaximalFrameCount of the mesh. | ||
50 | virtual bool setFrameLoop(s32 begin, s32 end); | ||
51 | |||
52 | //! Sets looping mode which is on by default. If set to false, | ||
53 | //! animations will not be looped. | ||
54 | virtual void setLoopMode(bool playAnimationLooped); | ||
55 | |||
56 | //! returns the current loop mode | ||
57 | virtual bool getLoopMode() const; | ||
58 | |||
59 | //! Sets a callback interface which will be called if an animation | ||
60 | //! playback has ended. Set this to 0 to disable the callback again. | ||
61 | virtual void setAnimationEndCallback(IAnimationEndCallBack* callback=0); | ||
62 | |||
63 | //! sets the speed with which the animation is played | ||
64 | virtual void setAnimationSpeed(f32 framesPerSecond); | ||
65 | |||
66 | //! gets the speed with which the animation is played | ||
67 | virtual f32 getAnimationSpeed() const; | ||
68 | |||
69 | //! returns the material based on the zero based index i. To get the amount | ||
70 | //! of materials used by this scene node, use getMaterialCount(). | ||
71 | //! This function is needed for inserting the node into the scene hirachy on a | ||
72 | //! optimal position for minimizing renderstate changes, but can also be used | ||
73 | //! to directly modify the material of a scene node. | ||
74 | virtual video::SMaterial& getMaterial(u32 i); | ||
75 | |||
76 | //! returns amount of materials used by this scene node. | ||
77 | virtual u32 getMaterialCount() const; | ||
78 | |||
79 | //! Creates shadow volume scene node as child of this node | ||
80 | //! and returns a pointer to it. | ||
81 | virtual IShadowVolumeSceneNode* addShadowVolumeSceneNode(const IMesh* shadowMesh, | ||
82 | s32 id, bool zfailmethod=true, f32 infinity=1000.0f); | ||
83 | |||
84 | //! Returns a pointer to a child node, which has the same transformation as | ||
85 | //! the corrsesponding joint, if the mesh in this scene node is a skinned mesh. | ||
86 | virtual IBoneSceneNode* getJointNode(const c8* jointName); | ||
87 | |||
88 | //! same as getJointNode(const c8* jointName), but based on id | ||
89 | virtual IBoneSceneNode* getJointNode(u32 jointID); | ||
90 | |||
91 | //! Gets joint count. | ||
92 | virtual u32 getJointCount() const; | ||
93 | |||
94 | //! Deprecated command, please use getJointNode. | ||
95 | virtual ISceneNode* getMS3DJointNode(const c8* jointName); | ||
96 | |||
97 | //! Deprecated command, please use getJointNode. | ||
98 | virtual ISceneNode* getXJointNode(const c8* jointName); | ||
99 | |||
100 | //! Removes a child from this scene node. | ||
101 | //! Implemented here, to be able to remove the shadow properly, if there is one, | ||
102 | //! or to remove attached childs. | ||
103 | virtual bool removeChild(ISceneNode* child); | ||
104 | |||
105 | //! Starts a MD2 animation. | ||
106 | virtual bool setMD2Animation(EMD2_ANIMATION_TYPE anim); | ||
107 | |||
108 | //! Starts a special MD2 animation. | ||
109 | virtual bool setMD2Animation(const c8* animationName); | ||
110 | |||
111 | //! Returns the current displayed frame number. | ||
112 | virtual f32 getFrameNr() const; | ||
113 | //! Returns the current start frame number. | ||
114 | virtual s32 getStartFrame() const; | ||
115 | //! Returns the current end frame number. | ||
116 | virtual s32 getEndFrame() const; | ||
117 | |||
118 | //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. | ||
119 | /* In this way it is possible to change the materials a mesh causing all mesh scene nodes | ||
120 | referencing this mesh to change too. */ | ||
121 | virtual void setReadOnlyMaterials(bool readonly); | ||
122 | |||
123 | //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style | ||
124 | virtual bool isReadOnlyMaterials() const; | ||
125 | |||
126 | //! Sets a new mesh | ||
127 | virtual void setMesh(IAnimatedMesh* mesh); | ||
128 | |||
129 | //! Returns the current mesh | ||
130 | virtual IAnimatedMesh* getMesh(void) { return Mesh; } | ||
131 | |||
132 | //! Writes attributes of the scene node. | ||
133 | virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; | ||
134 | |||
135 | //! Reads attributes of the scene node. | ||
136 | virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); | ||
137 | |||
138 | //! Returns type of the scene node | ||
139 | virtual ESCENE_NODE_TYPE getType() const { return ESNT_ANIMATED_MESH; } | ||
140 | |||
141 | // returns the absolute transformation for a special MD3 Tag if the mesh is a md3 mesh, | ||
142 | // or the absolutetransformation if it's a normal scenenode | ||
143 | const SMD3QuaternionTag* getMD3TagTransformation( const core::stringc & tagname); | ||
144 | |||
145 | //! updates the absolute position based on the relative and the parents position | ||
146 | virtual void updateAbsolutePosition(); | ||
147 | |||
148 | |||
149 | //! Set the joint update mode (0-unused, 1-get joints only, 2-set joints only, 3-move and set) | ||
150 | virtual void setJointMode(E_JOINT_UPDATE_ON_RENDER mode); | ||
151 | |||
152 | //! Sets the transition time in seconds (note: This needs to enable joints, and setJointmode maybe set to 2) | ||
153 | //! you must call animateJoints(), or the mesh will not animate | ||
154 | virtual void setTransitionTime(f32 Time); | ||
155 | |||
156 | //! updates the joint positions of this mesh | ||
157 | virtual void animateJoints(bool CalculateAbsolutePositions=true); | ||
158 | |||
159 | //! render mesh ignoring its transformation. Used with ragdolls. (culling is unaffected) | ||
160 | virtual void setRenderFromIdentity( bool On ); | ||
161 | |||
162 | //! Creates a clone of this scene node and its children. | ||
163 | /** \param newParent An optional new parent. | ||
164 | \param newManager An optional new scene manager. | ||
165 | \return The newly created clone of this node. */ | ||
166 | virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0); | ||
167 | |||
168 | private: | ||
169 | |||
170 | //! Get a static mesh for the current frame of this animated mesh | ||
171 | IMesh* getMeshForCurrentFrame(); | ||
172 | |||
173 | void buildFrameNr(u32 timeMs); | ||
174 | void checkJoints(); | ||
175 | void beginTransition(); | ||
176 | |||
177 | core::array<video::SMaterial> Materials; | ||
178 | core::aabbox3d<f32> Box; | ||
179 | IAnimatedMesh* Mesh; | ||
180 | |||
181 | s32 StartFrame; | ||
182 | s32 EndFrame; | ||
183 | f32 FramesPerSecond; | ||
184 | f32 CurrentFrameNr; | ||
185 | |||
186 | u32 LastTimeMs; | ||
187 | u32 TransitionTime; //Transition time in millisecs | ||
188 | f32 Transiting; //is mesh transiting (plus cache of TransitionTime) | ||
189 | f32 TransitingBlend; //0-1, calculated on buildFrameNr | ||
190 | |||
191 | //0-unused, 1-get joints only, 2-set joints only, 3-move and set | ||
192 | E_JOINT_UPDATE_ON_RENDER JointMode; | ||
193 | bool JointsUsed; | ||
194 | |||
195 | bool Looping; | ||
196 | bool ReadOnlyMaterials; | ||
197 | bool RenderFromIdentity; | ||
198 | |||
199 | IAnimationEndCallBack* LoopCallBack; | ||
200 | s32 PassCount; | ||
201 | |||
202 | IShadowVolumeSceneNode* Shadow; | ||
203 | |||
204 | core::array<IBoneSceneNode* > JointChildSceneNodes; | ||
205 | core::array<core::matrix4> PretransitingSave; | ||
206 | |||
207 | // Quake3 Model | ||
208 | struct SMD3Special : public virtual IReferenceCounted | ||
209 | { | ||
210 | core::stringc Tagname; | ||
211 | SMD3QuaternionTagList AbsoluteTagList; | ||
212 | |||
213 | SMD3Special & operator = (const SMD3Special & copyMe) | ||
214 | { | ||
215 | Tagname = copyMe.Tagname; | ||
216 | AbsoluteTagList = copyMe.AbsoluteTagList; | ||
217 | return *this; | ||
218 | } | ||
219 | }; | ||
220 | SMD3Special *MD3Special; | ||
221 | }; | ||
222 | |||
223 | } // end namespace scene | ||
224 | } // end namespace irr | ||
225 | |||
226 | #endif | ||
227 | |||