]> git.lizzy.rs Git - irrlicht.git/blob - include/ISkinnedMesh.h
Remove unused attribute saving and loading (#86)
[irrlicht.git] / include / ISkinnedMesh.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 __I_SKINNED_MESH_H_INCLUDED__\r
6 #define __I_SKINNED_MESH_H_INCLUDED__\r
7 \r
8 #include "irrArray.h"\r
9 #include "IBoneSceneNode.h"\r
10 #include "IAnimatedMesh.h"\r
11 #include "SSkinMeshBuffer.h"\r
12 \r
13 namespace irr\r
14 {\r
15 namespace scene\r
16 {\r
17 \r
18         enum E_INTERPOLATION_MODE\r
19         {\r
20                 // constant does use the current key-values without interpolation\r
21                 EIM_CONSTANT = 0,\r
22 \r
23                 // linear interpolation\r
24                 EIM_LINEAR,\r
25 \r
26                 //! count of all available interpolation modes\r
27                 EIM_COUNT\r
28         };\r
29 \r
30 \r
31         //! Interface for using some special functions of Skinned meshes\r
32         class ISkinnedMesh : public IAnimatedMesh\r
33         {\r
34         public:\r
35 \r
36                 //! Gets joint count.\r
37                 /** \return Amount of joints in the skeletal animated mesh. */\r
38                 virtual u32 getJointCount() const = 0;\r
39 \r
40                 //! Gets the name of a joint.\r
41                 /** \param number: Zero based index of joint. The last joint\r
42                 has the number getJointCount()-1;\r
43                 \return Name of joint and null if an error happened. */\r
44                 virtual const c8* getJointName(u32 number) const = 0;\r
45 \r
46                 //! Gets a joint number from its name\r
47                 /** \param name: Name of the joint.\r
48                 \return Number of the joint or -1 if not found. */\r
49                 virtual s32 getJointNumber(const c8* name) const = 0;\r
50 \r
51                 //! Use animation from another mesh\r
52                 /** The animation is linked (not copied) based on joint names\r
53                 so make sure they are unique.\r
54                 \return True if all joints in this mesh were\r
55                 matched up (empty names will not be matched, and it's case\r
56                 sensitive). Unmatched joints will not be animated. */\r
57                 virtual bool useAnimationFrom(const ISkinnedMesh *mesh) = 0;\r
58 \r
59                 //! Update Normals when Animating\r
60                 /** \param on If false don't animate, which is faster.\r
61                 Else update normals, which allows for proper lighting of\r
62                 animated meshes. */\r
63                 virtual void updateNormalsWhenAnimating(bool on) = 0;\r
64 \r
65                 //! Sets Interpolation Mode\r
66                 virtual void setInterpolationMode(E_INTERPOLATION_MODE mode) = 0;\r
67 \r
68                 //! Animates this mesh's joints based on frame input\r
69                 virtual void animateMesh(f32 frame, f32 blend)=0;\r
70 \r
71                 //! Preforms a software skin on this mesh based of joint positions\r
72                 virtual void skinMesh() = 0;\r
73 \r
74                 //! converts the vertex type of all meshbuffers to tangents.\r
75                 /** E.g. used for bump mapping. */\r
76                 virtual void convertMeshToTangents() = 0;\r
77 \r
78                 //! Allows to enable hardware skinning.\r
79                 /* This feature is not implemented in Irrlicht yet */\r
80                 virtual bool setHardwareSkinning(bool on) = 0;\r
81 \r
82                 //! Refreshes vertex data cached in joints such as positions and normals\r
83                 virtual void refreshJointCache() = 0;\r
84 \r
85                 //! A vertex weight\r
86                 struct SWeight\r
87                 {\r
88                         //! Index of the mesh buffer\r
89                         u16 buffer_id; //I doubt 32bits is needed\r
90 \r
91                         //! Index of the vertex\r
92                         u32 vertex_id; //Store global ID here\r
93 \r
94                         //! Weight Strength/Percentage (0-1)\r
95                         f32 strength;\r
96 \r
97                 private:\r
98                         //! Internal members used by CSkinnedMesh\r
99                         friend class CSkinnedMesh;\r
100                         bool *Moved;\r
101                         core::vector3df StaticPos;\r
102                         core::vector3df StaticNormal;\r
103                 };\r
104 \r
105 \r
106                 //! Animation keyframe which describes a new position\r
107                 struct SPositionKey\r
108                 {\r
109                         f32 frame;\r
110                         core::vector3df position;\r
111                 };\r
112 \r
113                 //! Animation keyframe which describes a new scale\r
114                 struct SScaleKey\r
115                 {\r
116                         f32 frame;\r
117                         core::vector3df scale;\r
118                 };\r
119 \r
120                 //! Animation keyframe which describes a new rotation\r
121                 struct SRotationKey\r
122                 {\r
123                         f32 frame;\r
124                         core::quaternion rotation;\r
125                 };\r
126 \r
127                 //! Joints\r
128                 struct SJoint\r
129                 {\r
130                         SJoint() : UseAnimationFrom(0), GlobalSkinningSpace(false),\r
131                                 positionHint(-1),scaleHint(-1),rotationHint(-1)\r
132                         {\r
133                         }\r
134 \r
135                         //! The name of this joint\r
136                         core::stringc Name;\r
137 \r
138                         //! Local matrix of this joint\r
139                         core::matrix4 LocalMatrix;\r
140 \r
141                         //! List of child joints\r
142                         core::array<SJoint*> Children;\r
143 \r
144                         //! List of attached meshes\r
145                         core::array<u32> AttachedMeshes;\r
146 \r
147                         //! Animation keys causing translation change\r
148                         core::array<SPositionKey> PositionKeys;\r
149 \r
150                         //! Animation keys causing scale change\r
151                         core::array<SScaleKey> ScaleKeys;\r
152 \r
153                         //! Animation keys causing rotation change\r
154                         core::array<SRotationKey> RotationKeys;\r
155 \r
156                         //! Skin weights\r
157                         core::array<SWeight> Weights;\r
158 \r
159                         //! Unnecessary for loaders, will be overwritten on finalize\r
160                         core::matrix4 GlobalMatrix;\r
161                         core::matrix4 GlobalAnimatedMatrix;\r
162                         core::matrix4 LocalAnimatedMatrix;\r
163                         core::vector3df Animatedposition;\r
164                         core::vector3df Animatedscale;\r
165                         core::quaternion Animatedrotation;\r
166 \r
167                         core::matrix4 GlobalInversedMatrix; //the x format pre-calculates this\r
168 \r
169                 private:\r
170                         //! Internal members used by CSkinnedMesh\r
171                         friend class CSkinnedMesh;\r
172 \r
173                         SJoint *UseAnimationFrom;\r
174                         bool GlobalSkinningSpace;\r
175 \r
176                         s32 positionHint;\r
177                         s32 scaleHint;\r
178                         s32 rotationHint;\r
179                 };\r
180 \r
181 \r
182                 //Interface for the mesh loaders (finalize should lock these functions, and they should have some prefix like loader_\r
183 \r
184                 //these functions will use the needed arrays, set values, etc to help the loaders\r
185 \r
186                 //! exposed for loaders: to add mesh buffers\r
187                 virtual core::array<SSkinMeshBuffer*>& getMeshBuffers() = 0;\r
188 \r
189                 //! exposed for loaders: joints list\r
190                 virtual core::array<SJoint*>& getAllJoints() = 0;\r
191 \r
192                 //! exposed for loaders: joints list\r
193                 virtual const core::array<SJoint*>& getAllJoints() const = 0;\r
194 \r
195                 //! loaders should call this after populating the mesh\r
196                 virtual void finalize() = 0;\r
197 \r
198                 //! Adds a new meshbuffer to the mesh, access it as last one\r
199                 virtual SSkinMeshBuffer* addMeshBuffer() = 0;\r
200 \r
201                 //! Adds a new joint to the mesh, access it as last one\r
202                 virtual SJoint* addJoint(SJoint *parent=0) = 0;\r
203 \r
204                 //! Adds a new weight to the mesh, access it as last one\r
205                 virtual SWeight* addWeight(SJoint *joint) = 0;\r
206 \r
207                 //! Adds a new position key to the mesh, access it as last one\r
208                 virtual SPositionKey* addPositionKey(SJoint *joint) = 0;\r
209                 //! Adds a new scale key to the mesh, access it as last one\r
210                 virtual SScaleKey* addScaleKey(SJoint *joint) = 0;\r
211                 //! Adds a new rotation key to the mesh, access it as last one\r
212                 virtual SRotationKey* addRotationKey(SJoint *joint) = 0;\r
213 \r
214                 //! Check if the mesh is non-animated\r
215                 virtual bool isStatic()=0;\r
216         };\r
217 \r
218 } // end namespace scene\r
219 } // end namespace irr\r
220 \r
221 #endif\r
222 \r