2007-09-04 11:51:42 -07:00
|
|
|
// Copyright (C) 2002-2006 Nikolaus Gebhardt
|
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
|
|
|
#ifndef __I_SKINNED_MESH_H_INCLUDED__
|
|
|
|
#define __I_SKINNED_MESH_H_INCLUDED__
|
|
|
|
|
|
|
|
#include "irrArray.h"
|
|
|
|
#include "IBoneSceneNode.h"
|
|
|
|
#include "IAnimatedMesh.h"
|
|
|
|
#include "SSkinMeshBuffer.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace scene
|
|
|
|
{
|
|
|
|
|
|
|
|
enum E_INTERPOLATION_MODE
|
|
|
|
{
|
|
|
|
// constant interpolation
|
|
|
|
EIM_CONSTANT = 0,
|
|
|
|
|
|
|
|
// linear interpolation
|
|
|
|
EIM_LINEAR,
|
|
|
|
|
|
|
|
//! count of all available interpolation modes
|
|
|
|
EIM_COUNT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//! Interface for using some special functions of Skinned meshes
|
|
|
|
class ISkinnedMesh : public IAnimatedMesh
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! Gets joint count.
|
|
|
|
//! \return Returns amount of joints in the skeletal animated mesh.
|
2007-09-17 09:09:50 -07:00
|
|
|
virtual u32 getJointCount() const = 0;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
//! Gets the name of a joint.
|
2007-09-09 15:04:52 -07:00
|
|
|
//! \param number: Zero based index of joint. The last joint
|
|
|
|
//! has the number getJointCount()-1;
|
2007-09-04 11:51:42 -07:00
|
|
|
//! \return Returns name of joint and null if an error happened.
|
2007-09-17 09:09:50 -07:00
|
|
|
virtual const c8* getJointName(u32 number) const = 0;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
//! Gets a joint number from its name
|
|
|
|
//! \param name: Name of the joint.
|
|
|
|
//! \return Returns the number of the joint or -1 if not found.
|
|
|
|
virtual s32 getJointNumber(const c8* name) const = 0;
|
|
|
|
|
|
|
|
//! uses animation from another mesh
|
|
|
|
//! the animation is linked (not copied) based on joint names (so make sure they are unique)
|
|
|
|
//! \return Returns true if all joints in this mesh were matched up (empty names will not be matched, and it's case sensitive)
|
|
|
|
//! unmatched joints will not be animated
|
2007-09-17 09:09:50 -07:00
|
|
|
virtual bool useAnimationFrom(const ISkinnedMesh *mesh) = 0;
|
2007-09-04 11:51:42 -07:00
|
|
|
|
|
|
|
//!Update Normals when Animating
|
|
|
|
//!False= Don't (default)
|
|
|
|
//!True= Update normals, slower
|
|
|
|
virtual void updateNormalsWhenAnimating(bool on) = 0;
|
|
|
|
|
|
|
|
//!Sets Interpolation Mode
|
|
|
|
virtual void setInterpolationMode(E_INTERPOLATION_MODE mode) = 0;
|
|
|
|
|
|
|
|
//! Animates this mesh's joints based on frame input
|
|
|
|
virtual void animateMesh(f32 frame, f32 blend)=0;
|
|
|
|
|
|
|
|
//! Preforms a software skin on this mesh based of joint positions
|
|
|
|
virtual void skinMesh() = 0;
|
|
|
|
|
2007-12-01 19:36:11 -08:00
|
|
|
//! converts the vertex type of all meshbuffers to tangents. eg for bumpmapping
|
2007-09-04 11:51:42 -07:00
|
|
|
virtual void convertMeshToTangents() = 0;
|
|
|
|
|
2007-12-01 19:36:11 -08:00
|
|
|
//! (This feature is not implementated in irrlicht yet)
|
|
|
|
virtual bool setHardwareSkinning(bool on) = 0;
|
|
|
|
|
2007-09-04 11:51:42 -07:00
|
|
|
//! A vertex weight
|
|
|
|
struct SWeight
|
|
|
|
{
|
|
|
|
//! Index of the mesh buffer
|
|
|
|
u16 buffer_id; //I doubt 32bits is needed
|
|
|
|
|
|
|
|
//! Index of the vertex
|
|
|
|
u32 vertex_id; //Store global ID here
|
|
|
|
|
|
|
|
//! Weight Strength/Percentage (0-1)
|
|
|
|
f32 strength;
|
|
|
|
|
|
|
|
private:
|
|
|
|
//! Internal members used by CSkinnedMesh
|
|
|
|
friend class CSkinnedMesh;
|
|
|
|
bool *Moved;
|
|
|
|
core::vector3df StaticPos;
|
|
|
|
core::vector3df StaticNormal;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//! Animation keyframe which describes a new position, scale or rotation
|
|
|
|
struct SPositionKey
|
|
|
|
{
|
|
|
|
f32 frame;
|
|
|
|
core::vector3df position;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SScaleKey
|
|
|
|
{
|
|
|
|
f32 frame;
|
|
|
|
core::vector3df scale;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SRotationKey
|
|
|
|
{
|
|
|
|
f32 frame;
|
|
|
|
core::quaternion rotation;
|
|
|
|
};
|
|
|
|
|
|
|
|
//! Joints
|
|
|
|
struct SJoint
|
|
|
|
{
|
2007-10-01 21:01:08 -07:00
|
|
|
SJoint() : UseAnimationFrom(0), LocalAnimatedMatrix_Animated(false), GlobalSkinningSpace(false),
|
2007-09-12 10:46:58 -07:00
|
|
|
positionHint(-1),scaleHint(-1),rotationHint(-1)
|
2007-09-04 11:51:42 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//! The name of this joint
|
|
|
|
core::stringc Name;
|
|
|
|
|
|
|
|
//! Local matrix of this joint
|
|
|
|
core::matrix4 LocalMatrix;
|
|
|
|
|
|
|
|
//! List of child joints
|
|
|
|
core::array<SJoint*> Children;
|
|
|
|
|
2007-09-17 19:51:06 -07:00
|
|
|
//! List of attached meshes
|
2007-09-17 04:09:07 -07:00
|
|
|
core::array<u32> AttachedMeshes;
|
|
|
|
|
2007-09-04 11:51:42 -07:00
|
|
|
//! Animation keys causing translation change
|
|
|
|
core::array<SPositionKey> PositionKeys;
|
|
|
|
|
|
|
|
//! Animation keys causing scale change
|
|
|
|
core::array<SScaleKey> ScaleKeys;
|
|
|
|
|
|
|
|
//! Animation keys causing rotation change
|
|
|
|
core::array<SRotationKey> RotationKeys;
|
|
|
|
|
|
|
|
//! Skin weights
|
|
|
|
core::array<SWeight> Weights;
|
|
|
|
|
|
|
|
//! Unnecessary for loaders, will be overwritten on finalize
|
|
|
|
core::matrix4 GlobalMatrix;
|
|
|
|
core::matrix4 GlobalAnimatedMatrix;
|
|
|
|
core::matrix4 LocalAnimatedMatrix;
|
|
|
|
core::vector3df Animatedposition;
|
|
|
|
core::vector3df Animatedscale;
|
|
|
|
core::quaternion Animatedrotation;
|
|
|
|
|
2007-10-01 21:01:08 -07:00
|
|
|
|
|
|
|
|
2007-09-04 11:51:42 -07:00
|
|
|
core::matrix4 GlobalInversedMatrix; //the x format pre-calculates this
|
|
|
|
|
|
|
|
private:
|
|
|
|
//! Internal members used by CSkinnedMesh
|
|
|
|
friend class CSkinnedMesh;
|
|
|
|
|
|
|
|
SJoint *UseAnimationFrom;
|
|
|
|
bool LocalAnimatedMatrix_Animated;
|
|
|
|
|
2007-10-01 21:01:08 -07:00
|
|
|
bool GlobalSkinningSpace;
|
|
|
|
|
2007-09-04 11:51:42 -07:00
|
|
|
s32 positionHint;
|
|
|
|
s32 scaleHint;
|
|
|
|
s32 rotationHint;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//Interface for the mesh loaders (finalize should lock these functions, and they should have some prefix like loader_
|
|
|
|
|
2007-09-17 09:09:50 -07:00
|
|
|
//these functions will use the needed arrays, set values, etc to help the loaders
|
2007-09-04 11:51:42 -07:00
|
|
|
|
2007-09-05 05:35:19 -07:00
|
|
|
//! exposed for loaders: to add mesh buffers
|
2007-09-04 11:51:42 -07:00
|
|
|
virtual core::array<SSkinMeshBuffer*> &getMeshBuffers() = 0;
|
|
|
|
|
2007-09-05 05:35:19 -07:00
|
|
|
//! exposed for loaders: joints list
|
2007-09-04 11:51:42 -07:00
|
|
|
virtual core::array<SJoint*> &getAllJoints() = 0;
|
|
|
|
|
2007-09-17 09:09:50 -07:00
|
|
|
//! exposed for loaders: joints list
|
|
|
|
virtual const core::array<SJoint*> &getAllJoints() const = 0;
|
|
|
|
|
2007-09-04 11:51:42 -07:00
|
|
|
//! loaders should call this after populating the mesh
|
|
|
|
virtual void finalize() = 0;
|
|
|
|
|
|
|
|
|
|
|
|
virtual SSkinMeshBuffer *createBuffer() = 0;
|
|
|
|
|
|
|
|
virtual SJoint *createJoint(SJoint *parent=0) = 0;
|
|
|
|
|
|
|
|
virtual SPositionKey *createPositionKey(SJoint *joint) = 0;
|
|
|
|
virtual SScaleKey *createScaleKey(SJoint *joint) = 0;
|
|
|
|
virtual SRotationKey *createRotationKey(SJoint *joint) = 0;
|
|
|
|
|
|
|
|
virtual SWeight *createWeight(SJoint *joint) = 0;
|
2007-11-13 23:35:40 -08:00
|
|
|
|
|
|
|
|
|
|
|
virtual bool isStatic()=0;
|
|
|
|
|
|
|
|
|
2007-09-04 11:51:42 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace scene
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|