Commit 5ecaaedb authored by lukeph's avatar lukeph

added ISkinnedMesh::setHardwareSkinning(bool on),

right now this only disables software skinning so that hardware skinning can be done externally

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1076 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 968c611d
...@@ -68,8 +68,12 @@ namespace scene ...@@ -68,8 +68,12 @@ namespace scene
//! Preforms a software skin on this mesh based of joint positions //! Preforms a software skin on this mesh based of joint positions
virtual void skinMesh() = 0; virtual void skinMesh() = 0;
//! converts the vertex type of all meshbuffers to tangents. eg for bumpmapping
virtual void convertMeshToTangents() = 0; virtual void convertMeshToTangents() = 0;
//! (This feature is not implementated in irrlicht yet)
virtual bool setHardwareSkinning(bool on) = 0;
//! A vertex weight //! A vertex weight
struct SWeight struct SWeight
{ {
......
...@@ -10,10 +10,8 @@ ...@@ -10,10 +10,8 @@
#include "IAnimatedMeshSceneNode.h" #include "IAnimatedMeshSceneNode.h"
#include "os.h" #include "os.h"
/*
#warning iostream
#include "iostream"
*/
namespace irr namespace irr
{ {
...@@ -25,7 +23,7 @@ namespace scene ...@@ -25,7 +23,7 @@ namespace scene
CSkinnedMesh::CSkinnedMesh() CSkinnedMesh::CSkinnedMesh()
: SkinningBuffers(0), HasAnimation(0), PreparedForSkinning(0), : SkinningBuffers(0), HasAnimation(0), PreparedForSkinning(0),
AnimationFrames(0.f), lastAnimatedFrame(0.f), lastSkinnedFrame(0.f), AnimationFrames(0.f), lastAnimatedFrame(0.f), lastSkinnedFrame(0.f),
BoneControlUsed(false), AnimateNormals(0), InterpolationMode(EIM_LINEAR) BoneControlUsed(false), AnimateNormals(0), HardwareSkinning(0), InterpolationMode(EIM_LINEAR)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CSkinnedMesh"); setDebugName("CSkinnedMesh");
...@@ -152,9 +150,10 @@ void CSkinnedMesh::buildAll_LocalAnimatedMatrices() ...@@ -152,9 +150,10 @@ void CSkinnedMesh::buildAll_LocalAnimatedMatrices()
Joint->UseAnimationFrom->RotationKeys.size() )) Joint->UseAnimationFrom->RotationKeys.size() ))
{ {
Joint->LocalAnimatedMatrix=Joint->Animatedrotation.getMatrix(); Joint->LocalAnimatedMatrix=Joint->Animatedrotation.getMatrix();
// --- Joint->LocalAnimatedMatrix *= Joint->Animatedrotation.getMatrix() ---
f32 *m1 = Joint->LocalAnimatedMatrix.pointer(); f32 *m1 = Joint->LocalAnimatedMatrix.pointer();
core::vector3df &Pos = Joint->Animatedposition; core::vector3df &Pos = Joint->Animatedposition;
m1[0] += Pos.X*m1[3]; m1[0] += Pos.X*m1[3];
m1[1] += Pos.Y*m1[3]; m1[1] += Pos.Y*m1[3];
m1[2] += Pos.Z*m1[3]; m1[2] += Pos.Z*m1[3];
...@@ -167,16 +166,19 @@ void CSkinnedMesh::buildAll_LocalAnimatedMatrices() ...@@ -167,16 +166,19 @@ void CSkinnedMesh::buildAll_LocalAnimatedMatrices()
m1[12] += Pos.X*m1[15]; m1[12] += Pos.X*m1[15];
m1[13] += Pos.Y*m1[15]; m1[13] += Pos.Y*m1[15];
m1[14] += Pos.Z*m1[15]; m1[14] += Pos.Z*m1[15];
// -----------------------------------
Joint->GlobalSkinningSpace=false; Joint->GlobalSkinningSpace=false;
if (Joint->ScaleKeys.size()) if (Joint->ScaleKeys.size())
{ {
/* /*
core::matrix4 scaleMatrix; core::matrix4 scaleMatrix;
scaleMatrix.setScale(Joint->Animatedscale); scaleMatrix.setScale(Joint->Animatedscale);
Joint->LocalAnimatedMatrix *= scaleMatrix; Joint->LocalAnimatedMatrix *= scaleMatrix;
*/ */
// -------- Joint->LocalAnimatedMatrix *= scaleMatrix -----------------
f32 *m1 = Joint->LocalAnimatedMatrix.pointer(); f32 *m1 = Joint->LocalAnimatedMatrix.pointer();
m1[0] *= Joint->Animatedscale.X; m1[0] *= Joint->Animatedscale.X;
m1[1] *= Joint->Animatedscale.X; m1[1] *= Joint->Animatedscale.X;
...@@ -191,6 +193,8 @@ void CSkinnedMesh::buildAll_LocalAnimatedMatrices() ...@@ -191,6 +193,8 @@ void CSkinnedMesh::buildAll_LocalAnimatedMatrices()
m1[10] *= Joint->Animatedscale.Z; m1[10] *= Joint->Animatedscale.Z;
m1[11] *= Joint->Animatedscale.Z; m1[11] *= Joint->Animatedscale.Z;
m1[12] *= Joint->Animatedscale.X; m1[12] *= Joint->Animatedscale.X;
// -----------------------------------
} }
} }
else else
...@@ -438,13 +442,11 @@ void CSkinnedMesh::skinMesh() ...@@ -438,13 +442,11 @@ void CSkinnedMesh::skinMesh()
//----------------- //-----------------
if (!HardwareSkinning)
{
//Software skin.... //Software skin....
u32 i; u32 i;
//rigid animation //rigid animation
for (i=0; i<AllJoints.size(); ++i) for (i=0; i<AllJoints.size(); ++i)
{ {
...@@ -456,15 +458,16 @@ void CSkinnedMesh::skinMesh() ...@@ -456,15 +458,16 @@ void CSkinnedMesh::skinMesh()
} }
//clear skinning helper array //clear skinning helper array
for (i=0; i<Vertices_Moved.size(); ++i) for (i=0; i<Vertices_Moved.size(); ++i)
for (u32 j=0; j<Vertices_Moved[i].size(); ++j) for (u32 j=0; j<Vertices_Moved[i].size(); ++j)
Vertices_Moved[i][j]=false; Vertices_Moved[i][j]=false;
//skin starting with the root joints //skin starting with the root joints
for (i=0; i<RootJoints.size(); ++i) for (i=0; i<RootJoints.size(); ++i)
SkinJoint(RootJoints[i], 0); SkinJoint(RootJoints[i], 0);
}
} }
void CSkinnedMesh::SkinJoint(SJoint *Joint, SJoint *ParentJoint) void CSkinnedMesh::SkinJoint(SJoint *Joint, SJoint *ParentJoint)
...@@ -519,6 +522,16 @@ void CSkinnedMesh::SkinJoint(SJoint *Joint, SJoint *ParentJoint) ...@@ -519,6 +522,16 @@ void CSkinnedMesh::SkinJoint(SJoint *Joint, SJoint *ParentJoint)
} }
E_ANIMATED_MESH_TYPE CSkinnedMesh::getMeshType() const E_ANIMATED_MESH_TYPE CSkinnedMesh::getMeshType() const
{ {
return EAMT_SKINNED; return EAMT_SKINNED;
...@@ -671,6 +684,37 @@ const core::array<CSkinnedMesh::SJoint*> &CSkinnedMesh::getAllJoints() const ...@@ -671,6 +684,37 @@ const core::array<CSkinnedMesh::SJoint*> &CSkinnedMesh::getAllJoints() const
} }
//! (This feature is not implementated in irrlicht yet)
bool CSkinnedMesh::setHardwareSkinning(bool on)
{
if (HardwareSkinning!=on)
{
if (on)
{
//set mesh to static pose...
for (u32 i=0; i<AllJoints.size(); ++i)
{
SJoint *Joint=AllJoints[i];
for (u32 j=0; j<Joint->Weights.size(); ++j)
{
const u16 buffer_id=Joint->Weights[j].buffer_id;
const u32 vertex_id=Joint->Weights[j].vertex_id;
LocalBuffers[buffer_id]->getVertex(vertex_id)->Pos = Joint->Weights[j].StaticPos;
LocalBuffers[buffer_id]->getVertex(vertex_id)->Normal = Joint->Weights[j].StaticNormal;
}
}
}
HardwareSkinning=on;
}
}
void CSkinnedMesh::CalculateGlobalMatrixes(SJoint *Joint,SJoint *ParentJoint) void CSkinnedMesh::CalculateGlobalMatrixes(SJoint *Joint,SJoint *ParentJoint)
{ {
if (!Joint && ParentJoint) // bit of protection from endless loops if (!Joint && ParentJoint) // bit of protection from endless loops
......
...@@ -106,6 +106,11 @@ namespace scene ...@@ -106,6 +106,11 @@ namespace scene
virtual void convertMeshToTangents(); virtual void convertMeshToTangents();
//! Does the mesh have non animation
virtual bool isStatic();
//! (This feature is not implementated in irrlicht yet)
virtual bool setHardwareSkinning(bool on);
...@@ -127,8 +132,6 @@ namespace scene ...@@ -127,8 +132,6 @@ namespace scene
virtual void finalize(); virtual void finalize();
virtual SSkinMeshBuffer *createBuffer(); virtual SSkinMeshBuffer *createBuffer();
virtual SJoint *createJoint(SJoint *parent=0); virtual SJoint *createJoint(SJoint *parent=0);
...@@ -140,7 +143,7 @@ namespace scene ...@@ -140,7 +143,7 @@ namespace scene
virtual SWeight *createWeight(SJoint *joint); virtual SWeight *createWeight(SJoint *joint);
virtual bool isStatic();
private: private:
...@@ -186,6 +189,9 @@ private: ...@@ -186,6 +189,9 @@ private:
bool AnimateNormals; bool AnimateNormals;
bool HardwareSkinning;
E_INTERPOLATION_MODE InterpolationMode; E_INTERPOLATION_MODE InterpolationMode;
core::aabbox3d<f32> BoundingBox; core::aabbox3d<f32> BoundingBox;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment