Commit 329e8f6c authored by lukeph's avatar lukeph

added enum E_JOINT_UPDATE_ON_RENDER, for IAnimatedMeshSceneNode::setJointMode

changed IAnimatedMeshSceneNode::animateJoints() to animateJoints(bool CalculateAbsolutePositions=true)

removed ISkinnedMesh::recoverJointsFromMesh, transferJointsToMesh, and createJoints from interface.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1027 dfc29bdd-3216-0410-991c-e03cc46cb475
parent ce4a3002
...@@ -15,6 +15,25 @@ namespace irr ...@@ -15,6 +15,25 @@ namespace irr
{ {
namespace scene namespace scene
{ {
enum E_JOINT_UPDATE_ON_RENDER
{
// do nothing
EJUOR_NONE = 0,
// get joints positions from the mesh (for attached nodes, etc)
EJUOR_READ,
// control joint positions in the mesh (eg. ragdolls, or set the animation from animateJoints() )
EJUOR_CONTROL,
//! count of all available interpolation modes
EJUOR_COUNT
};
class IAnimatedMeshSceneNode; class IAnimatedMeshSceneNode;
//! Callback interface for catching events of ended animations. //! Callback interface for catching events of ended animations.
...@@ -174,14 +193,14 @@ namespace scene ...@@ -174,14 +193,14 @@ namespace scene
//! 0-do nothing //! 0-do nothing
//! 1-get joints positions from the mesh (for attached nodes, etc) //! 1-get joints positions from the mesh (for attached nodes, etc)
//! 2-control joint positions in the mesh (eg. ragdolls, or set the animation from animateJoints() ) //! 2-control joint positions in the mesh (eg. ragdolls, or set the animation from animateJoints() )
virtual void setJointMode(s32 mode)=0; virtual void setJointMode(E_JOINT_UPDATE_ON_RENDER mode)=0;
//! Sets the transition time in seconds (note: This needs to enable joints, and setJointmode maybe set to 2) //! Sets the transition time in seconds (note: This needs to enable joints, and setJointmode maybe set to 2)
//! you must call animateJoints(), or the mesh will not animate //! you must call animateJoints(), or the mesh will not ani\mate
virtual void setTransitionTime(f32 Time) =0; virtual void setTransitionTime(f32 Time) =0;
//! animates the joints in the mesh based on the current frame (also takes in to account transitions) //! animates the joints in the mesh based on the current frame (also takes in to account transitions)
virtual void animateJoints() = 0; virtual void animateJoints(bool CalculateAbsolutePositions=true) = 0;
//! render mesh ignoring it's transformation. Used with ragdolls. (culling is unaffected) //! render mesh ignoring it's transformation. Used with ragdolls. (culling is unaffected)
virtual void setRenderFromIdentity( bool On )=0; virtual void setRenderFromIdentity( bool On )=0;
......
...@@ -68,16 +68,6 @@ namespace scene ...@@ -68,16 +68,6 @@ 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;
//!Recovers the joints from the mesh
virtual void recoverJointsFromMesh(core::array<IBoneSceneNode*> &JointChildSceneNodes) = 0;
//!Tranfers the joint data to the mesh
virtual void transferJointsToMesh(const core::array<IBoneSceneNode*> &JointChildSceneNodes) = 0;
//!Creates an array of joints from this mesh
virtual void createJoints(core::array<IBoneSceneNode*> &JointChildSceneNodes,
IAnimatedMeshSceneNode* AnimatedMeshSceneNode, ISceneManager* SceneManager) = 0;
virtual void convertMeshToTangents() = 0; virtual void convertMeshToTangents() = 0;
//! A vertex weight //! A vertex weight
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "os.h" #include "os.h"
#include "CShadowVolumeSceneNode.h" #include "CShadowVolumeSceneNode.h"
#include "IAnimatedMeshMD3.h" #include "IAnimatedMeshMD3.h"
#include "ISkinnedMesh.h" #include "CSkinnedMesh.h"
#include "IDummyTransformationSceneNode.h" #include "IDummyTransformationSceneNode.h"
#include "IBoneSceneNode.h" #include "IBoneSceneNode.h"
#include "IMaterialRenderer.h" #include "IMaterialRenderer.h"
...@@ -30,7 +30,7 @@ CAnimatedMeshSceneNode::CAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* ...@@ -30,7 +30,7 @@ CAnimatedMeshSceneNode::CAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode*
const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale)
: IAnimatedMeshSceneNode(parent, mgr, id, position, rotation, scale), Mesh(0), : IAnimatedMeshSceneNode(parent, mgr, id, position, rotation, scale), Mesh(0),
BeginFrameTime(0), StartFrame(0), EndFrame(0), FramesPerSecond(25.f / 1000.f ), BeginFrameTime(0), StartFrame(0), EndFrame(0), FramesPerSecond(25.f / 1000.f ),
CurrentFrameNr(0.f), JointMode(0), JointsUsed(false), CurrentFrameNr(0.f), JointMode(EJUOR_NONE), JointsUsed(false),
TransitionTime(0), Transiting(0.f), TransitingBlend(0.f), TransitionTime(0), Transiting(0.f), TransitingBlend(0.f),
Looping(true), ReadOnlyMaterials(false), Looping(true), ReadOnlyMaterials(false),
LoopCallBack(0), PassCount(0), Shadow(0), RenderFromIdentity(0) LoopCallBack(0), PassCount(0), Shadow(0), RenderFromIdentity(0)
...@@ -259,16 +259,16 @@ void CAnimatedMeshSceneNode::render() ...@@ -259,16 +259,16 @@ void CAnimatedMeshSceneNode::render()
m = Mesh->getMesh((s32)frame, 255, StartFrame, EndFrame); m = Mesh->getMesh((s32)frame, 255, StartFrame, EndFrame);
else else
{ {
ISkinnedMesh* skinnedMesh = reinterpret_cast<ISkinnedMesh*>(Mesh); CSkinnedMesh* skinnedMesh = reinterpret_cast<CSkinnedMesh*>(Mesh);
if (JointMode &2)//write to mesh if (JointMode == EJUOR_CONTROL)//write to mesh
skinnedMesh->transferJointsToMesh(JointChildSceneNodes); skinnedMesh->transferJointsToMesh(JointChildSceneNodes);
else else
skinnedMesh->animateMesh(frame, 1.0f); skinnedMesh->animateMesh(frame, 1.0f);
skinnedMesh->skinMesh(); skinnedMesh->skinMesh();
if (JointMode &1)//read from mesh if (JointMode == EJUOR_READ)//read from mesh
{ {
skinnedMesh->recoverJointsFromMesh(JointChildSceneNodes); skinnedMesh->recoverJointsFromMesh(JointChildSceneNodes);
...@@ -853,12 +853,12 @@ void CAnimatedMeshSceneNode::updateAbsolutePosition() ...@@ -853,12 +853,12 @@ void CAnimatedMeshSceneNode::updateAbsolutePosition()
} }
//! Set the joint update mode (0-unused, 1-get joints only, 2-set joints only, 3-move and set) //! Set the joint update mode (0-unused, 1-get joints only, 2-set joints only, 3-move and set)
void CAnimatedMeshSceneNode::setJointMode(s32 mode) void CAnimatedMeshSceneNode::setJointMode(E_JOINT_UPDATE_ON_RENDER mode)
{ {
checkJoints(); checkJoints();
if (mode<0) mode=0; //if (mode<0) mode=0;
if (mode>3) mode=3; //if (mode>3) mode=3;
JointMode=mode; JointMode=mode;
} }
...@@ -868,11 +868,12 @@ void CAnimatedMeshSceneNode::setJointMode(s32 mode) ...@@ -868,11 +868,12 @@ void CAnimatedMeshSceneNode::setJointMode(s32 mode)
//! you must call animateJoints(), or the mesh will not animate //! you must call animateJoints(), or the mesh will not animate
void CAnimatedMeshSceneNode::setTransitionTime(f32 time) void CAnimatedMeshSceneNode::setTransitionTime(f32 time)
{ {
if (time != 0.f) if (time != 0.0f)
{
checkJoints(); checkJoints();
if (!(JointMode & 0x2)) setJointMode(EJUOR_CONTROL);
setJointMode(2); TransitionTime = (u32)core::floor32(time*1000.0f);
TransitionTime = (u32)core::floor32(time*1000.0f); }
} }
//! render mesh ignoring it's transformation. Used with ragdolls. (culling is unaffected) //! render mesh ignoring it's transformation. Used with ragdolls. (culling is unaffected)
...@@ -884,7 +885,7 @@ void CAnimatedMeshSceneNode::setRenderFromIdentity( bool On ) ...@@ -884,7 +885,7 @@ void CAnimatedMeshSceneNode::setRenderFromIdentity( bool On )
//! updates the joint positions of this mesh //! updates the joint positions of this mesh
void CAnimatedMeshSceneNode::animateJoints() void CAnimatedMeshSceneNode::animateJoints(bool CalculateAbsolutePositions)
{ {
checkJoints(); checkJoints();
...@@ -894,18 +895,21 @@ void CAnimatedMeshSceneNode::animateJoints() ...@@ -894,18 +895,21 @@ void CAnimatedMeshSceneNode::animateJoints()
{ {
f32 frame = getFrameNr(); //old? f32 frame = getFrameNr(); //old?
ISkinnedMesh* skinnedMesh=(ISkinnedMesh*)Mesh; CSkinnedMesh* skinnedMesh=reinterpret_cast<CSkinnedMesh*>(Mesh);
skinnedMesh->animateMesh(frame, 1.0f); skinnedMesh->animateMesh(frame, 1.0f);
skinnedMesh->recoverJointsFromMesh( JointChildSceneNodes); skinnedMesh->recoverJointsFromMesh( JointChildSceneNodes);
//---slow--- if (CalculateAbsolutePositions)
for (u32 n=0;n<JointChildSceneNodes.size();++n) {
if (JointChildSceneNodes[n]->getParent()==this) //---slow---
{ for (u32 n=0;n<JointChildSceneNodes.size();++n)
JointChildSceneNodes[n]->updateAbsolutePositionOfAllChildren(); //temp, should be an option if (JointChildSceneNodes[n]->getParent()==this)
} {
JointChildSceneNodes[n]->updateAbsolutePositionOfAllChildren(); //temp, should be an option
}
}
//----------------------------------------- //-----------------------------------------
// Transition // Transition
...@@ -970,11 +974,11 @@ void CAnimatedMeshSceneNode::checkJoints() ...@@ -970,11 +974,11 @@ void CAnimatedMeshSceneNode::checkJoints()
{ {
//Create joints for SkinnedMesh //Create joints for SkinnedMesh
((ISkinnedMesh*)Mesh)->createJoints(JointChildSceneNodes, this, SceneManager); ((CSkinnedMesh*)Mesh)->createJoints(JointChildSceneNodes, this, SceneManager);
((ISkinnedMesh*)Mesh)->recoverJointsFromMesh(JointChildSceneNodes); ((CSkinnedMesh*)Mesh)->recoverJointsFromMesh(JointChildSceneNodes);
JointsUsed=true; JointsUsed=true;
JointMode=1; JointMode=EJUOR_READ;
} }
} }
......
...@@ -138,14 +138,14 @@ namespace scene ...@@ -138,14 +138,14 @@ namespace scene
//! Set the joint update mode (0-unused, 1-get joints only, 2-set joints only, 3-move and set) //! Set the joint update mode (0-unused, 1-get joints only, 2-set joints only, 3-move and set)
virtual void setJointMode(s32 mode); virtual void setJointMode(E_JOINT_UPDATE_ON_RENDER mode);
//! Sets the transition time in seconds (note: This needs to enable joints, and setJointmode maybe set to 2) //! Sets the transition time in seconds (note: This needs to enable joints, and setJointmode maybe set to 2)
//! you must call animateJoints(), or the mesh will not animate //! you must call animateJoints(), or the mesh will not animate
virtual void setTransitionTime(f32 Time); virtual void setTransitionTime(f32 Time);
//! updates the joint positions of this mesh //! updates the joint positions of this mesh
virtual void animateJoints(); virtual void animateJoints(bool CalculateAbsolutePositions=true);
//! render mesh ignoring it's transformation. Used with ragdolls. (culling is unaffected) //! render mesh ignoring it's transformation. Used with ragdolls. (culling is unaffected)
virtual void setRenderFromIdentity( bool On ); virtual void setRenderFromIdentity( bool On );
...@@ -166,7 +166,7 @@ namespace scene ...@@ -166,7 +166,7 @@ namespace scene
f32 FramesPerSecond; f32 FramesPerSecond;
f32 CurrentFrameNr; f32 CurrentFrameNr;
s32 JointMode; //0-unused, 1-get joints only, 2-set joints only, 3-move and set E_JOINT_UPDATE_ON_RENDER JointMode; //0-unused, 1-get joints only, 2-set joints only, 3-move and set
bool JointsUsed; bool JointsUsed;
u32 TransitionTime; //Transition time in millisecs u32 TransitionTime; //Transition time in millisecs
......
This diff is collapsed.
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