diff options
Diffstat (limited to 'src/content_cao.cpp')
-rw-r--r-- | src/content_cao.cpp | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/src/content_cao.cpp b/src/content_cao.cpp index 4df238b24..1cd3926ca 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -924,7 +924,6 @@ public: m_visuals_expired = false; removeFromScene(); addToScene(m_smgr, m_gamedef->tsrc(), m_irr); - updateAnimations(); } if(m_prop.physical){ @@ -1137,22 +1136,34 @@ public: } } - void updateAnimations() + void updateAnimations(int frame_start, int frame_end, float frame_speed, float frame_blend) { if(!m_animated_meshnode) return; - m_animated_meshnode->setFrameLoop(m_prop.animation_frames.X, m_prop.animation_frames.Y); - m_animated_meshnode->setAnimationSpeed(m_prop.animation_speed); - m_animated_meshnode->setTransitionTime(m_prop.animation_blend); + m_animated_meshnode->setFrameLoop(frame_start, frame_end); + m_animated_meshnode->setAnimationSpeed(frame_speed); + m_animated_meshnode->setTransitionTime(frame_blend); - for(std::map<std::string, v3f>::const_iterator ii = m_prop.animation_bone_position.begin(); ii != m_prop.animation_bone_position.end(); ++ii){ - if((*ii).second.X || (*ii).second.Y || (*ii).second.Z) { } - // Bone positioning code will go here + if(m_prop.animation_bone_position.size() > 0) + { + for(std::map<std::string, v3f>::const_iterator ii = m_prop.animation_bone_position.begin(); ii != m_prop.animation_bone_position.end(); ++ii){ + m_animated_meshnode->setJointMode(irr::scene::EJUOR_CONTROL); // To write positions to the mesh on render + std::string bone_name = (*ii).first; + v3f bone_pos = (*ii).second; + irr::scene::IBoneSceneNode* bone = m_animated_meshnode->getJointNode(bone_name.c_str()); + bone->setPosition(bone_pos); + } } - for(std::map<std::string, v3f>::const_iterator ii = m_prop.animation_bone_rotation.begin(); ii != m_prop.animation_bone_rotation.end(); ++ii){ - if((*ii).second.X || (*ii).second.Y || (*ii).second.Z) { } - // Bone rotation code will go here + if(m_prop.animation_bone_rotation.size() > 0) + { + for(std::map<std::string, v3f>::const_iterator ii = m_prop.animation_bone_rotation.begin(); ii != m_prop.animation_bone_rotation.end(); ++ii){ + m_animated_meshnode->setJointMode(irr::scene::EJUOR_CONTROL); // To write positions to the mesh on render + std::string bone_name = (*ii).first; + v3f bone_rot = (*ii).second; + irr::scene::IBoneSceneNode* bone = m_animated_meshnode->getJointNode(bone_name.c_str()); + bone->setRotation(bone_rot); + } } } @@ -1223,6 +1234,15 @@ public: updateTexturePos(); } + else if(cmd == GENERIC_CMD_SET_ANIMATIONS) + { + int frame_start = readU16(is); + int frame_end = readU16(is); + float frame_speed = readF1000(is); + float frame_blend = readF1000(is); + + updateAnimations(frame_start, frame_end, frame_speed, frame_blend); + } else if(cmd == GENERIC_CMD_PUNCHED) { /*s16 damage =*/ readS16(is); |