arsa  2.7
ISkinnedMesh.h
Go to the documentation of this file.
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 __I_SKINNED_MESH_H_INCLUDED__
6 #define __I_SKINNED_MESH_H_INCLUDED__
7 
8 #include "irrArray.h"
9 #include "IBoneSceneNode.h"
10 #include "IAnimatedMesh.h"
11 #include "SSkinMeshBuffer.h"
12 
13 namespace irr
14 {
15 namespace scene
16 {
17 
19  {
20  // constant does use the current key-values without interpolation
22 
23  // linear interpolation
25 
28  };
29 
30 
32  class ISkinnedMesh : public IAnimatedMesh
33  {
34  public:
35 
37 
38  virtual u32 getJointCount() const = 0;
39 
41 
44  virtual const c8* getJointName(u32 number) const = 0;
45 
47 
49  virtual s32 getJointNumber(const c8* name) const = 0;
50 
52 
57  virtual bool useAnimationFrom(const ISkinnedMesh *mesh) = 0;
58 
60 
63  virtual void updateNormalsWhenAnimating(bool on) = 0;
64 
67 
69  virtual void animateMesh(f32 frame, f32 blend)=0;
70 
72  virtual void skinMesh() = 0;
73 
75 
76  virtual void convertMeshToTangents() = 0;
77 
79  /* This feature is not implemented in Irrlicht yet */
80  virtual bool setHardwareSkinning(bool on) = 0;
81 
83  struct SWeight
84  {
86  u16 buffer_id; //I doubt 32bits is needed
87 
89  u32 vertex_id; //Store global ID here
90 
93 
94  //private:
96  friend class CSkinnedMesh;
97  bool *Moved;
100  };
101 
102 
105  {
108  };
109 
111  struct SScaleKey
112  {
115  };
116 
119  {
122  };
123 
125  struct SJoint
126  {
127  SJoint() : UseAnimationFrom(0), GlobalSkinningSpace(false),
128  positionHint(-1),scaleHint(-1),rotationHint(-1)
129  {
130  }
131 
134 
137 
140 
143 
146 
149 
152 
155 
163 
164  core::matrix4 GlobalInversedMatrix; //the x format pre-calculates this
165 
166  private:
168  friend class CSkinnedMesh;
169 
170  SJoint *UseAnimationFrom;
171  bool GlobalSkinningSpace;
172 
173  s32 positionHint;
174  s32 scaleHint;
175  s32 rotationHint;
176  };
177 
178 
179  //Interface for the mesh loaders (finalize should lock these functions, and they should have some prefix like loader_
180 
181  //these functions will use the needed arrays, set values, etc to help the loaders
182 
185 
187  virtual core::array<SJoint*>& getAllJoints() = 0;
188 
190  virtual const core::array<SJoint*>& getAllJoints() const = 0;
191 
193  virtual void finalize() = 0;
194 
196  virtual SSkinMeshBuffer* addMeshBuffer() = 0;
197 
199  virtual SJoint* addJoint(SJoint *parent=0) = 0;
200 
202  virtual SWeight* addWeight(SJoint *joint) = 0;
203 
205  virtual SPositionKey* addPositionKey(SJoint *joint) = 0;
207  virtual SScaleKey* addScaleKey(SJoint *joint) = 0;
209  virtual SRotationKey* addRotationKey(SJoint *joint) = 0;
210 
212  virtual bool isStatic()=0;
213 
214  virtual void setSkinnedLastFrame(bool lastframe) = 0;
215  virtual void setLastAnimatedFrame(f32 frame) = 0;
216  virtual bool isSkinnedLastFrame() const = 0;
217  virtual f32 getLastAnimatedFrame() const = 0;
218 
219  };
220 
221 } // end namespace scene
222 } // end namespace irr
223 
224 #endif
225 
u32 vertex_id
Index of the vertex.
Definition: ISkinnedMesh.h:89
virtual void updateNormalsWhenAnimating(bool on)=0
Update Normals when Animating.
core::stringc Name
The name of this joint.
Definition: ISkinnedMesh.h:133
virtual void animateMesh(f32 frame, f32 blend)=0
Animates this mesh's joints based on frame input.
virtual u32 getJointCount() const =0
Gets joint count.
friend class CSkinnedMesh
Internal members used by CSkinnedMesh.
Definition: ISkinnedMesh.h:168
virtual core::array< SJoint * > & getAllJoints()=0
exposed for loaders: joints list
friend class CSkinnedMesh
Internal members used by CSkinnedMesh.
Definition: ISkinnedMesh.h:96
virtual void convertMeshToTangents()=0
converts the vertex type of all meshbuffers to tangents.
f32 strength
Weight Strength/Percentage (0-1)
Definition: ISkinnedMesh.h:92
count of all available interpolation modes
Definition: ISkinnedMesh.h:27
virtual core::array< SSkinMeshBuffer * > & getMeshBuffers()=0
exposed for loaders: to add mesh buffers
float f32
32 bit floating point variable.
Definition: irrTypes.h:108
core::array< u32 > AttachedMeshes
List of attached meshes.
Definition: ISkinnedMesh.h:142
core::array< SScaleKey > ScaleKeys
Animation keys causing scale change.
Definition: ISkinnedMesh.h:148
virtual SSkinMeshBuffer * addMeshBuffer()=0
Adds a new meshbuffer to the mesh, access it as last one.
core::array< SJoint * > Children
List of child joints.
Definition: ISkinnedMesh.h:139
char c8
8 bit character variable.
Definition: irrTypes.h:35
core::array< SWeight > Weights
Skin weights.
Definition: ISkinnedMesh.h:154
virtual void skinMesh()=0
Preforms a software skin on this mesh based of joint positions.
GLuint const GLchar * name
Everything in the Irrlicht Engine can be found in this namespace.
Definition: CARSADPad.h:6
Very simple string class with some useful features.
Definition: irrString.h:37
Interface for using some special functions of Skinned meshes.
Definition: ISkinnedMesh.h:32
Animation keyframe which describes a new position.
Definition: ISkinnedMesh.h:104
virtual bool isSkinnedLastFrame() const =0
virtual SPositionKey * addPositionKey(SJoint *joint)=0
Adds a new position key to the mesh, access it as last one.
u16 buffer_id
Index of the mesh buffer.
Definition: ISkinnedMesh.h:86
unsigned short u16
16 bit unsigned variable.
Definition: irrTypes.h:44
core::matrix4 GlobalMatrix
Unnecessary for loaders, will be overwritten on finalize.
Definition: ISkinnedMesh.h:157
A mesh buffer able to choose between S3DVertex2TCoords, S3DVertex and S3DVertexTangents at runtime.
signed int s32
32 bit signed variable.
Definition: irrTypes.h:70
virtual void setSkinnedLastFrame(bool lastframe)=0
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:62
GLenum mode
virtual SScaleKey * addScaleKey(SJoint *joint)=0
Adds a new scale key to the mesh, access it as last one.
virtual void setInterpolationMode(E_INTERPOLATION_MODE mode)=0
Sets Interpolation Mode.
virtual bool setHardwareSkinning(bool on)=0
Allows to enable hardware skinning.
virtual bool useAnimationFrom(const ISkinnedMesh *mesh)=0
Use animation from another mesh.
virtual void setLastAnimatedFrame(f32 frame)=0
core::matrix4 LocalMatrix
Local matrix of this joint.
Definition: ISkinnedMesh.h:136
virtual f32 getLastAnimatedFrame() const =0
4x4 matrix. Mostly used as transformation matrix for 3d calculations.
Definition: matrix4.h:45
virtual bool isStatic()=0
Check if the mesh is non-animated.
Animation keyframe which describes a new rotation.
Definition: ISkinnedMesh.h:118
Animation keyframe which describes a new scale.
Definition: ISkinnedMesh.h:111
Self reallocating template array (like stl vector) with additional features.
Definition: irrArray.h:22
virtual s32 getJointNumber(const c8 *name) const =0
Gets a joint number from its name.
virtual SRotationKey * addRotationKey(SJoint *joint)=0
Adds a new rotation key to the mesh, access it as last one.
virtual SWeight * addWeight(SJoint *joint)=0
Adds a new weight to the mesh, access it as last one.
virtual const c8 * getJointName(u32 number) const =0
Gets the name of a joint.
virtual SJoint * addJoint(SJoint *parent=0)=0
Adds a new joint to the mesh, access it as last one.
Quaternion class for representing rotations.
Definition: quaternion.h:31
Interface for an animated mesh.
Definition: IAnimatedMesh.h:20
virtual void finalize()=0
loaders should call this after populating the mesh
core::array< SPositionKey > PositionKeys
Animation keys causing translation change.
Definition: ISkinnedMesh.h:145
core::array< SRotationKey > RotationKeys
Animation keys causing rotation change.
Definition: ISkinnedMesh.h:151