1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-22 17:18:39 +00:00

Joint positioning and rotation code, and fix a problem related to their lua API

Attempt to move the animation system to a more correct implementation, rather than using object properties. Incomplete and breaks functionality
This commit is contained in:
MirceaKitsune 2012-10-26 11:46:46 +03:00 committed by Perttu Ahola
parent fb0c431864
commit ba4d93027f
9 changed files with 86 additions and 50 deletions

View file

@ -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);