Commit e138121a authored by cutealien's avatar cutealien

CAnimatedMeshSceneNode::setMesh does now set the animation speed again to that of the mesh.

.x meshloader regards now AnimTicksPerSecond (thx @qian for a test-model and bugreport).
CAnimatedMeshSceneNode::setMesh had commented-out the setAnimationSpeed line in version r3526 which was about a joint-cache fix for skinned meshes. But there was no comment about why that line had to be removed or commented out, so my guess is that this was only a test (I hope). And it caused animation-speed values for the meshes to be ignored unless user specified it explicitly while animation range was still changed in setMesh.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5097 dfc29bdd-3216-0410-991c-e03cc46cb475
parent a5911bc7
-------------------------- --------------------------
Changes in 1.9 (not yet released) Changes in 1.9 (not yet released)
- CAnimatedMeshSceneNode::setMesh does now set the animation speed again to that of the mesh (had been changed in 1.7, but not for obvious reasons)
- .x meshloader regards now AnimTicksPerSecond (thx @qian for a test-model and bugreport)
- Interface getMeshType moved from IAnimatedMesh up to IMesh. - Interface getMeshType moved from IAnimatedMesh up to IMesh.
- Add b3d mesh-writer. Static writer written by Hendu, support for animated meshes added by JLouisB, testing and bugfixes by CuteAlien. - Add b3d mesh-writer. Static writer written by Hendu, support for animated meshes added by JLouisB, testing and bugfixes by CuteAlien.
- Node-collision functions of SceneCollisionManager like getSceneNodeFromScreenCoordinatesBB will now ignore collisions against empty boundingboxes. - Node-collision functions of SceneCollisionManager like getSceneNodeFromScreenCoordinatesBB will now ignore collisions against empty boundingboxes.
......
...@@ -239,7 +239,6 @@ void loadModel(const c8* fn) ...@@ -239,7 +239,6 @@ void loadModel(const c8* fn)
else else
{ {
scene::IAnimatedMeshSceneNode* animModel = Device->getSceneManager()->addAnimatedMeshSceneNode(m); scene::IAnimatedMeshSceneNode* animModel = Device->getSceneManager()->addAnimatedMeshSceneNode(m);
animModel->setAnimationSpeed(30);
Model = animModel; Model = animModel;
} }
Model->setMaterialFlag(video::EMF_LIGHTING, UseLight); Model->setMaterialFlag(video::EMF_LIGHTING, UseLight);
......
...@@ -849,7 +849,7 @@ void CAnimatedMeshSceneNode::setMesh(IAnimatedMesh* mesh) ...@@ -849,7 +849,7 @@ void CAnimatedMeshSceneNode::setMesh(IAnimatedMesh* mesh)
} }
// get start and begin time // get start and begin time
// setAnimationSpeed(Mesh->getAnimationSpeed()); setAnimationSpeed(Mesh->getAnimationSpeed()); // NOTE: This had been commented out (but not removed!) in r3526. Which caused meshloader-values for speed to be ignored unless users specified explicitly. Missing a test-case where this could go wrong so I put the code back in.
setFrameLoop(0, Mesh->getFrameCount()); setFrameLoop(0, Mesh->getFrameCount());
} }
......
...@@ -47,6 +47,7 @@ namespace scene ...@@ -47,6 +47,7 @@ namespace scene
//! sets the frames between the animation is looped. //! sets the frames between the animation is looped.
//! the default is 0 - MaximalFrameCount of the mesh. //! the default is 0 - MaximalFrameCount of the mesh.
//! NOTE: setMesh will also change this value and set it to the full range of animations of the mesh
virtual bool setFrameLoop(s32 begin, s32 end) _IRR_OVERRIDE_; virtual bool setFrameLoop(s32 begin, s32 end) _IRR_OVERRIDE_;
//! Sets looping mode which is on by default. If set to false, //! Sets looping mode which is on by default. If set to false,
...@@ -61,6 +62,7 @@ namespace scene ...@@ -61,6 +62,7 @@ namespace scene
virtual void setAnimationEndCallback(IAnimationEndCallBack* callback=0) _IRR_OVERRIDE_; virtual void setAnimationEndCallback(IAnimationEndCallBack* callback=0) _IRR_OVERRIDE_;
//! sets the speed with which the animation is played //! sets the speed with which the animation is played
//! NOTE: setMesh will also change this value and set it to the default speed of the mesh
virtual void setAnimationSpeed(f32 framesPerSecond) _IRR_OVERRIDE_; virtual void setAnimationSpeed(f32 framesPerSecond) _IRR_OVERRIDE_;
//! gets the speed with which the animation is played //! gets the speed with which the animation is played
......
...@@ -520,6 +520,11 @@ bool CXMeshFileLoader::parseDataObject() ...@@ -520,6 +520,11 @@ bool CXMeshFileLoader::parseDataObject()
return parseDataObjectAnimationSet(); return parseDataObjectAnimationSet();
} }
else else
if (objectName == "AnimTicksPerSecond")
{
return parseDataObjectAnimationTicksPerSecond();
}
else
if (objectName == "Material") if (objectName == "Material")
{ {
// template materials now available thanks to joeWright // template materials now available thanks to joeWright
...@@ -1607,6 +1612,39 @@ bool CXMeshFileLoader::parseDataObjectAnimationSet() ...@@ -1607,6 +1612,39 @@ bool CXMeshFileLoader::parseDataObjectAnimationSet()
return true; return true;
} }
bool CXMeshFileLoader::parseDataObjectAnimationTicksPerSecond()
{
#ifdef _XREADER_DEBUG
os::Printer::log("CXFileReader: reading AnimationTicksPerSecond", ELL_DEBUG);
#endif
if (!readHeadOfDataObject())
{
os::Printer::log("No opening brace in Animation found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
return false;
}
const u32 ticks = readInt();
if (!checkForOneFollowingSemicolons())
{
os::Printer::log("No closing semicolon in AnimationTicksPerSecond in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
return false;
}
if (!checkForClosingBrace())
{
os::Printer::log("No closing brace in AnimationTicksPerSecond in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
return false;
}
AnimatedMesh->setAnimationSpeed(ticks);
return true;
}
bool CXMeshFileLoader::parseDataObjectAnimation() bool CXMeshFileLoader::parseDataObjectAnimation()
{ {
......
...@@ -118,6 +118,8 @@ private: ...@@ -118,6 +118,8 @@ private:
bool parseDataObjectAnimationSet(); bool parseDataObjectAnimationSet();
bool parseDataObjectAnimationTicksPerSecond();
bool parseDataObjectAnimation(); bool parseDataObjectAnimation();
bool parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint); bool parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint);
......
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