aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/source/Irrlicht/CSkinnedMesh.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CSkinnedMesh.h')
-rw-r--r--src/others/irrlicht-1.8.1/source/Irrlicht/CSkinnedMesh.h215
1 files changed, 215 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CSkinnedMesh.h b/src/others/irrlicht-1.8.1/source/Irrlicht/CSkinnedMesh.h
new file mode 100644
index 0000000..cb3665c
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CSkinnedMesh.h
@@ -0,0 +1,215 @@
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//New skinned mesh
6
7#ifndef __C_SKINNED_MESH_H_INCLUDED__
8#define __C_SKINNED_MESH_H_INCLUDED__
9
10#include "ISkinnedMesh.h"
11#include "SMeshBuffer.h"
12#include "S3DVertex.h"
13#include "irrString.h"
14#include "matrix4.h"
15#include "quaternion.h"
16
17namespace irr
18{
19namespace scene
20{
21
22 class IAnimatedMeshSceneNode;
23 class IBoneSceneNode;
24
25 class CSkinnedMesh: public ISkinnedMesh
26 {
27 public:
28
29 //! constructor
30 CSkinnedMesh();
31
32 //! destructor
33 virtual ~CSkinnedMesh();
34
35 //! returns the amount of frames. If the amount is 1, it is a static (=non animated) mesh.
36 virtual u32 getFrameCount() const;
37
38 //! Gets the default animation speed of the animated mesh.
39 /** \return Amount of frames per second. If the amount is 0, it is a static, non animated mesh. */
40 virtual f32 getAnimationSpeed() const;
41
42 //! Gets the frame count of the animated mesh.
43 /** \param fps Frames per second to play the animation with. If the amount is 0, it is not animated.
44 The actual speed is set in the scene node the mesh is instantiated in.*/
45 virtual void setAnimationSpeed(f32 fps);
46
47 //! returns the animated mesh based on a detail level (which is ignored)
48 virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1);
49
50 //! Animates this mesh's joints based on frame input
51 //! blend: {0-old position, 1-New position}
52 virtual void animateMesh(f32 frame, f32 blend);
53
54 //! Preforms a software skin on this mesh based of joint positions
55 virtual void skinMesh();
56
57 //! returns amount of mesh buffers.
58 virtual u32 getMeshBufferCount() const;
59
60 //! returns pointer to a mesh buffer
61 virtual IMeshBuffer* getMeshBuffer(u32 nr) const;
62
63 //! Returns pointer to a mesh buffer which fits a material
64 /** \param material: material to search for
65 \return Returns the pointer to the mesh buffer or
66 NULL if there is no such mesh buffer. */
67 virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const;
68
69 //! returns an axis aligned bounding box
70 virtual const core::aabbox3d<f32>& getBoundingBox() const;
71
72 //! set user axis aligned bounding box
73 virtual void setBoundingBox( const core::aabbox3df& box);
74
75 //! sets a flag of all contained materials to a new value
76 virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue);
77
78 //! set the hardware mapping hint, for driver
79 virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX);
80
81 //! flags the meshbuffer as changed, reloads hardware buffers
82 virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX);
83
84 //! Returns the type of the animated mesh.
85 virtual E_ANIMATED_MESH_TYPE getMeshType() const;
86
87 //! Gets joint count.
88 virtual u32 getJointCount() const;
89
90 //! Gets the name of a joint.
91 virtual const c8* getJointName(u32 number) const;
92
93 //! Gets a joint number from its name
94 virtual s32 getJointNumber(const c8* name) const;
95
96 //! uses animation from another mesh
97 virtual bool useAnimationFrom(const ISkinnedMesh *mesh);
98
99 //! Update Normals when Animating
100 //! False= Don't (default)
101 //! True = Update normals, slower
102 virtual void updateNormalsWhenAnimating(bool on);
103
104 //! Sets Interpolation Mode
105 virtual void setInterpolationMode(E_INTERPOLATION_MODE mode);
106
107 //! Convertes the mesh to contain tangent information
108 virtual void convertMeshToTangents();
109
110 //! Does the mesh have no animation
111 virtual bool isStatic();
112
113 //! (This feature is not implemented in irrlicht yet)
114 virtual bool setHardwareSkinning(bool on);
115
116 //Interface for the mesh loaders (finalize should lock these functions, and they should have some prefix like loader_
117 //these functions will use the needed arrays, set values, etc to help the loaders
118
119 //! exposed for loaders to add mesh buffers
120 virtual core::array<SSkinMeshBuffer*> &getMeshBuffers();
121
122 //! alternative method for adding joints
123 virtual core::array<SJoint*> &getAllJoints();
124
125 //! alternative method for adding joints
126 virtual const core::array<SJoint*> &getAllJoints() const;
127
128 //! loaders should call this after populating the mesh
129 virtual void finalize();
130
131 //! Adds a new meshbuffer to the mesh, access it as last one
132 virtual SSkinMeshBuffer *addMeshBuffer();
133
134 //! Adds a new joint to the mesh, access it as last one
135 virtual SJoint *addJoint(SJoint *parent=0);
136
137 //! Adds a new position key to the mesh, access it as last one
138 virtual SPositionKey *addPositionKey(SJoint *joint);
139 //! Adds a new rotation key to the mesh, access it as last one
140 virtual SRotationKey *addRotationKey(SJoint *joint);
141 //! Adds a new scale key to the mesh, access it as last one
142 virtual SScaleKey *addScaleKey(SJoint *joint);
143
144 //! Adds a new weight to the mesh, access it as last one
145 virtual SWeight *addWeight(SJoint *joint);
146
147 virtual void updateBoundingBox(void);
148
149 //! Recovers the joints from the mesh
150 void recoverJointsFromMesh(core::array<IBoneSceneNode*> &jointChildSceneNodes);
151
152 //! Tranfers the joint data to the mesh
153 void transferJointsToMesh(const core::array<IBoneSceneNode*> &jointChildSceneNodes);
154
155 //! Tranfers the joint hints to the mesh
156 void transferOnlyJointsHintsToMesh(const core::array<IBoneSceneNode*> &jointChildSceneNodes);
157
158 //! Creates an array of joints from this mesh as children of node
159 void addJoints(core::array<IBoneSceneNode*> &jointChildSceneNodes,
160 IAnimatedMeshSceneNode* node,
161 ISceneManager* smgr);
162
163private:
164 void checkForAnimation();
165
166 void normalizeWeights();
167
168 void buildAllLocalAnimatedMatrices();
169
170 void buildAllGlobalAnimatedMatrices(SJoint *Joint=0, SJoint *ParentJoint=0);
171
172 void getFrameData(f32 frame, SJoint *Node,
173 core::vector3df &position, s32 &positionHint,
174 core::vector3df &scale, s32 &scaleHint,
175 core::quaternion &rotation, s32 &rotationHint);
176
177 void calculateGlobalMatrices(SJoint *Joint,SJoint *ParentJoint);
178
179 void skinJoint(SJoint *Joint, SJoint *ParentJoint);
180
181 void calculateTangents(core::vector3df& normal,
182 core::vector3df& tangent, core::vector3df& binormal,
183 core::vector3df& vt1, core::vector3df& vt2, core::vector3df& vt3,
184 core::vector2df& tc1, core::vector2df& tc2, core::vector2df& tc3);
185
186 core::array<SSkinMeshBuffer*> *SkinningBuffers; //Meshbuffer to skin, default is to skin localBuffers
187
188 core::array<SSkinMeshBuffer*> LocalBuffers;
189
190 core::array<SJoint*> AllJoints;
191 core::array<SJoint*> RootJoints;
192
193 core::array< core::array<bool> > Vertices_Moved;
194
195 core::aabbox3d<f32> BoundingBox;
196
197 f32 AnimationFrames;
198 f32 FramesPerSecond;
199
200 f32 LastAnimatedFrame;
201 bool SkinnedLastFrame;
202
203 E_INTERPOLATION_MODE InterpolationMode:8;
204
205 bool HasAnimation;
206 bool PreparedForSkinning;
207 bool AnimateNormals;
208 bool HardwareSkinning;
209 };
210
211} // end namespace scene
212} // end namespace irr
213
214#endif
215