Nirtcpp 2.1.0
Nirtcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
ISkinnedMesh.hpp
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 nirtcpp/nirtcpp.hpp
4
5#ifndef NIRT_I_SKINNED_MESH_HPP_INCLUDED
6#define NIRT_I_SKINNED_MESH_HPP_INCLUDED
7
8#include <nirtcpp/core/engine/irrArray.hpp>
9#include <nirtcpp/core/engine/IBoneSceneNode.hpp>
10#include <nirtcpp/core/engine/IAnimatedMesh.hpp>
11#include <nirtcpp/core/engine/SSkinMeshBuffer.hpp>
12
13namespace nirt
14{
15namespace scene
16{
17
19 {
20 // constant does use the current key-values without interpolation
21 EIM_CONSTANT = 0,
22
23 // linear interpolation
24 EIM_LINEAR,
25
28 };
29
30
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 Nirtcpp yet */
80 virtual bool setHardwareSkinning(bool on) = 0;
81
83 class SWeight
84 {
85 public:
87 u16 buffer_id; //I doubt 32bits is needed
88
90 u32 vertex_id; //Store global ID here
91
94
95 private:
97 friend class CSkinnedMesh;
98 bool *Moved;
99 core::vector3df StaticPos;
100 core::vector3df StaticNormal;
101 };
102
103
106 {
107 public:
108 f32 frame;
109 core::vector3df position;
110 };
111
114 {
115 public:
116 f32 frame;
117 core::vector3df scale;
118 };
119
122 {
123 public:
124 f32 frame;
125 core::quaternion rotation;
126 };
127
129 class SJoint
130 {
131 public:
132 SJoint() : UseAnimationFrom(0), GlobalSkinningSpace(false),
133 positionHint(-1),scaleHint(-1),rotationHint(-1)
134 {
135 }
136
137 public:
140
143
146
149
152
155
158
161
164 core::matrix4 GlobalAnimatedMatrix;
165 core::matrix4 LocalAnimatedMatrix;
166 core::vector3df Animatedposition;
167 core::vector3df Animatedscale;
168 core::quaternion Animatedrotation;
169
170 core::matrix4 GlobalInversedMatrix; //the x format pre-calculates this
171
172 private:
174 friend class CSkinnedMesh;
175
176 SJoint *UseAnimationFrom;
177 bool GlobalSkinningSpace;
178
179 s32 positionHint;
180 s32 scaleHint;
181 s32 rotationHint;
182 };
183
184
185 //Interface for the mesh loaders (finalize should lock these functions, and they should have some prefix like loader_
186
187 //these functions will use the needed arrays, set values, etc to help the loaders
188
191
194
196 virtual const core::array<SJoint*>& getAllJoints() const = 0;
197
199 virtual void finalize() = 0;
200
203
205 virtual SJoint* addJoint(SJoint *parent=0) = 0;
206
208 virtual SWeight* addWeight(SJoint *joint) = 0;
209
211 virtual SPositionKey* addPositionKey(SJoint *joint) = 0;
213 virtual SScaleKey* addScaleKey(SJoint *joint) = 0;
215 virtual SRotationKey* addRotationKey(SJoint *joint) = 0;
216
218 virtual bool isStatic()=0;
219 };
220
221} // end namespace scene
222} // end namespace nirt
223
224#endif
4x4 matrix. Mostly used as transformation matrix for 3d calculations.
Definition matrix4.hpp:49
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
Quaternion class for representing rotations.
Definition quaternion.hpp:32
Interface for an animated mesh.
Definition IAnimatedMesh.hpp:21
Joints.
Definition ISkinnedMesh.hpp:130
core::stringc Name
The name of this joint.
Definition ISkinnedMesh.hpp:139
core::array< SScaleKey > ScaleKeys
Animation keys causing scale change.
Definition ISkinnedMesh.hpp:154
core::matrix4 GlobalMatrix
Unnecessary for loaders, will be overwritten on finalize.
Definition ISkinnedMesh.hpp:163
core::array< SWeight > Weights
Skin weights.
Definition ISkinnedMesh.hpp:160
core::array< u32 > AttachedMeshes
List of attached meshes.
Definition ISkinnedMesh.hpp:148
friend class CSkinnedMesh
Internal members used by CSkinnedMesh.
Definition ISkinnedMesh.hpp:174
core::array< SPositionKey > PositionKeys
Animation keys causing translation change.
Definition ISkinnedMesh.hpp:151
core::array< SRotationKey > RotationKeys
Animation keys causing rotation change.
Definition ISkinnedMesh.hpp:157
core::matrix4 LocalMatrix
Local matrix of this joint.
Definition ISkinnedMesh.hpp:142
core::array< SJoint * > Children
List of child joints.
Definition ISkinnedMesh.hpp:145
Animation keyframe which describes a new position.
Definition ISkinnedMesh.hpp:106
Animation keyframe which describes a new rotation.
Definition ISkinnedMesh.hpp:122
Animation keyframe which describes a new scale.
Definition ISkinnedMesh.hpp:114
A vertex weight.
Definition ISkinnedMesh.hpp:84
f32 strength
Weight Strength/Percentage (0-1)
Definition ISkinnedMesh.hpp:93
friend class CSkinnedMesh
Internal members used by CSkinnedMesh.
Definition ISkinnedMesh.hpp:97
u32 vertex_id
Index of the vertex.
Definition ISkinnedMesh.hpp:90
u16 buffer_id
Index of the mesh buffer.
Definition ISkinnedMesh.hpp:87
Interface for using some special functions of Skinned meshes.
Definition ISkinnedMesh.hpp:33
virtual u32 getJointCount() const =0
Gets joint count.
virtual bool setHardwareSkinning(bool on)=0
Allows to enable hardware skinning.
virtual SScaleKey * addScaleKey(SJoint *joint)=0
Adds a new scale key to the mesh, access it as last one.
virtual bool isStatic()=0
Check if the mesh is non-animated.
virtual s32 getJointNumber(const c8 *name) const =0
Gets a joint number from its name.
virtual core::array< SSkinMeshBuffer * > & getMeshBuffers()=0
exposed for loaders: to add mesh buffers
virtual core::array< SJoint * > & getAllJoints()=0
exposed for loaders: joints list
virtual SSkinMeshBuffer * addMeshBuffer()=0
Adds a new meshbuffer to the mesh, access it as last one.
virtual void updateNormalsWhenAnimating(bool on)=0
Update Normals when Animating.
virtual void convertMeshToTangents()=0
converts the vertex type of all meshbuffers to tangents.
virtual bool useAnimationFrom(const ISkinnedMesh *mesh)=0
Use animation from another mesh.
virtual const c8 * getJointName(u32 number) const =0
Gets the name of a joint.
virtual SWeight * addWeight(SJoint *joint)=0
Adds a new weight to the mesh, access it as last one.
virtual void animateMesh(f32 frame, f32 blend)=0
Animates this mesh's joints based on frame input.
virtual SRotationKey * addRotationKey(SJoint *joint)=0
Adds a new rotation key to the mesh, access it as last one.
virtual const core::array< SJoint * > & getAllJoints() const =0
exposed for loaders: joints list
virtual SPositionKey * addPositionKey(SJoint *joint)=0
Adds a new position key to the mesh, access it as last one.
virtual SJoint * addJoint(SJoint *parent=0)=0
Adds a new joint to the mesh, access it as last one.
virtual void finalize()=0
loaders should call this after populating the mesh
virtual void setInterpolationMode(E_INTERPOLATION_MODE mode)=0
Sets Interpolation Mode.
virtual void skinMesh()=0
Preforms a software skin on this mesh based of joint positions.
A mesh buffer able to choose between S3DVertex2TCoords, S3DVertex and S3DVertexTangents at runtime.
Definition SSkinMeshBuffer.hpp:20
E_INTERPOLATION_MODE
Definition ISkinnedMesh.hpp:19
@ EIM_COUNT
count of all available interpolation modes
Definition ISkinnedMesh.hpp:27
As of Nirtcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11
unsigned short u16
16 bit unsigned variable.
Definition irrTypes.hpp:46
signed int s32
32 bit signed variable.
Definition irrTypes.hpp:72
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.hpp:64
char c8
8 bit character variable.
Definition irrTypes.hpp:37
float f32
32 bit floating point variable.
Definition irrTypes.hpp:110

Nirtcpp    @cppfx.xyz

Esvcpp    esv::print