From 329e8f6c23f66e438ec9b8aa7777e9d03da71b3e Mon Sep 17 00:00:00 2001 From: lukeph Date: Tue, 16 Oct 2007 13:34:07 +0000 Subject: [PATCH] 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 --- include/IAnimatedMeshSceneNode.h | 25 +- include/ISkinnedMesh.h | 10 - source/Irrlicht/CAnimatedMeshSceneNode.cpp | 50 +- source/Irrlicht/CAnimatedMeshSceneNode.h | 6 +- source/Irrlicht/Irrlicht_Win32-gcc.cbp | 4849 +++----------------- 5 files changed, 738 insertions(+), 4202 deletions(-) diff --git a/include/IAnimatedMeshSceneNode.h b/include/IAnimatedMeshSceneNode.h index 4ba2278c..8b855d4d 100644 --- a/include/IAnimatedMeshSceneNode.h +++ b/include/IAnimatedMeshSceneNode.h @@ -15,6 +15,25 @@ namespace irr { 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; //! Callback interface for catching events of ended animations. @@ -174,14 +193,14 @@ namespace scene //! 0-do nothing //! 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() ) - 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) - //! 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; //! 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) virtual void setRenderFromIdentity( bool On )=0; diff --git a/include/ISkinnedMesh.h b/include/ISkinnedMesh.h index 4b474969..b58a60a0 100644 --- a/include/ISkinnedMesh.h +++ b/include/ISkinnedMesh.h @@ -68,16 +68,6 @@ namespace scene //! Preforms a software skin on this mesh based of joint positions virtual void skinMesh() = 0; - //!Recovers the joints from the mesh - virtual void recoverJointsFromMesh(core::array &JointChildSceneNodes) = 0; - - //!Tranfers the joint data to the mesh - virtual void transferJointsToMesh(const core::array &JointChildSceneNodes) = 0; - - //!Creates an array of joints from this mesh - virtual void createJoints(core::array &JointChildSceneNodes, - IAnimatedMeshSceneNode* AnimatedMeshSceneNode, ISceneManager* SceneManager) = 0; - virtual void convertMeshToTangents() = 0; //! A vertex weight diff --git a/source/Irrlicht/CAnimatedMeshSceneNode.cpp b/source/Irrlicht/CAnimatedMeshSceneNode.cpp index 1e9489ab..d1872cb9 100644 --- a/source/Irrlicht/CAnimatedMeshSceneNode.cpp +++ b/source/Irrlicht/CAnimatedMeshSceneNode.cpp @@ -9,7 +9,7 @@ #include "os.h" #include "CShadowVolumeSceneNode.h" #include "IAnimatedMeshMD3.h" -#include "ISkinnedMesh.h" +#include "CSkinnedMesh.h" #include "IDummyTransformationSceneNode.h" #include "IBoneSceneNode.h" #include "IMaterialRenderer.h" @@ -30,7 +30,7 @@ CAnimatedMeshSceneNode::CAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) : IAnimatedMeshSceneNode(parent, mgr, id, position, rotation, scale), Mesh(0), 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), Looping(true), ReadOnlyMaterials(false), LoopCallBack(0), PassCount(0), Shadow(0), RenderFromIdentity(0) @@ -259,16 +259,16 @@ void CAnimatedMeshSceneNode::render() m = Mesh->getMesh((s32)frame, 255, StartFrame, EndFrame); else { - ISkinnedMesh* skinnedMesh = reinterpret_cast(Mesh); + CSkinnedMesh* skinnedMesh = reinterpret_cast(Mesh); - if (JointMode &2)//write to mesh + if (JointMode == EJUOR_CONTROL)//write to mesh skinnedMesh->transferJointsToMesh(JointChildSceneNodes); else skinnedMesh->animateMesh(frame, 1.0f); skinnedMesh->skinMesh(); - if (JointMode &1)//read from mesh + if (JointMode == EJUOR_READ)//read from mesh { skinnedMesh->recoverJointsFromMesh(JointChildSceneNodes); @@ -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) -void CAnimatedMeshSceneNode::setJointMode(s32 mode) +void CAnimatedMeshSceneNode::setJointMode(E_JOINT_UPDATE_ON_RENDER mode) { checkJoints(); - if (mode<0) mode=0; - if (mode>3) mode=3; + //if (mode<0) mode=0; + //if (mode>3) mode=3; JointMode=mode; } @@ -868,11 +868,12 @@ void CAnimatedMeshSceneNode::setJointMode(s32 mode) //! you must call animateJoints(), or the mesh will not animate void CAnimatedMeshSceneNode::setTransitionTime(f32 time) { - if (time != 0.f) + if (time != 0.0f) + { checkJoints(); - if (!(JointMode & 0x2)) - setJointMode(2); - TransitionTime = (u32)core::floor32(time*1000.0f); + setJointMode(EJUOR_CONTROL); + TransitionTime = (u32)core::floor32(time*1000.0f); + } } //! render mesh ignoring it's transformation. Used with ragdolls. (culling is unaffected) @@ -884,7 +885,7 @@ void CAnimatedMeshSceneNode::setRenderFromIdentity( bool On ) //! updates the joint positions of this mesh -void CAnimatedMeshSceneNode::animateJoints() +void CAnimatedMeshSceneNode::animateJoints(bool CalculateAbsolutePositions) { checkJoints(); @@ -894,18 +895,21 @@ void CAnimatedMeshSceneNode::animateJoints() { f32 frame = getFrameNr(); //old? - ISkinnedMesh* skinnedMesh=(ISkinnedMesh*)Mesh; + CSkinnedMesh* skinnedMesh=reinterpret_cast(Mesh); skinnedMesh->animateMesh(frame, 1.0f); skinnedMesh->recoverJointsFromMesh( JointChildSceneNodes); - //---slow--- - for (u32 n=0;ngetParent()==this) - { - JointChildSceneNodes[n]->updateAbsolutePositionOfAllChildren(); //temp, should be an option - } + if (CalculateAbsolutePositions) + { + //---slow--- + for (u32 n=0;ngetParent()==this) + { + JointChildSceneNodes[n]->updateAbsolutePositionOfAllChildren(); //temp, should be an option + } + } //----------------------------------------- // Transition @@ -970,11 +974,11 @@ void CAnimatedMeshSceneNode::checkJoints() { //Create joints for SkinnedMesh - ((ISkinnedMesh*)Mesh)->createJoints(JointChildSceneNodes, this, SceneManager); - ((ISkinnedMesh*)Mesh)->recoverJointsFromMesh(JointChildSceneNodes); + ((CSkinnedMesh*)Mesh)->createJoints(JointChildSceneNodes, this, SceneManager); + ((CSkinnedMesh*)Mesh)->recoverJointsFromMesh(JointChildSceneNodes); JointsUsed=true; - JointMode=1; + JointMode=EJUOR_READ; } } diff --git a/source/Irrlicht/CAnimatedMeshSceneNode.h b/source/Irrlicht/CAnimatedMeshSceneNode.h index 3d5b9353..8e9b26ce 100644 --- a/source/Irrlicht/CAnimatedMeshSceneNode.h +++ b/source/Irrlicht/CAnimatedMeshSceneNode.h @@ -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) - 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) //! you must call animateJoints(), or the mesh will not animate virtual void setTransitionTime(f32 Time); //! 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) virtual void setRenderFromIdentity( bool On ); @@ -166,7 +166,7 @@ namespace scene f32 FramesPerSecond; 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; u32 TransitionTime; //Transition time in millisecs diff --git a/source/Irrlicht/Irrlicht_Win32-gcc.cbp b/source/Irrlicht/Irrlicht_Win32-gcc.cbp index 5aad5ddf..ae47fef9 100644 --- a/source/Irrlicht/Irrlicht_Win32-gcc.cbp +++ b/source/Irrlicht/Irrlicht_Win32-gcc.cbp @@ -1,4331 +1,854 @@ - - + - + -