Commit 77d2cf92 authored by Dirk Wilden's avatar Dirk Wilden

move skeleton joints in all animations

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9477 383ad7c9-94d9-4d36-a494-682f7c89f535
parent c6090563
......@@ -541,8 +541,7 @@ void MovePlugin::moveSelection(ACG::Matrix4x4d mat, int _id) {
void MovePlugin::moveSkeletonJoint(ACG::Matrix4x4d mat, int _id) {
transformSkeletonJoint( _id , mat );
emit updatedObject(_id, UPDATE_GEOMETRY);
// emit createBackup(_id,"MoveSkeleton");
}
#endif
......@@ -673,8 +672,12 @@ void MovePlugin::manipulatorMoved( QtTranslationManipulatorNode* _node , QMouseE
moveSelection( mat, objectId );
#ifdef ENABLE_SKELETON_SUPPORT
else if (PluginFunctions::pickMode() == "MoveSkeleton")
else if (PluginFunctions::pickMode() == "MoveSkeleton"){
moveSkeletonJoint( mat, objectId );
if (_event->type() == QEvent::MouseButtonRelease)
emit updatedObject(objectId, UPDATE_GEOMETRY);
}
#endif
// move all other targets without manipulator
......@@ -690,8 +693,12 @@ void MovePlugin::manipulatorMoved( QtTranslationManipulatorNode* _node , QMouseE
moveSelection( mat, o_it->id() );
#ifdef ENABLE_SKELETON_SUPPORT
else if (PluginFunctions::pickMode() == "MoveSkeleton")
else if (PluginFunctions::pickMode() == "MoveSkeleton"){
moveSkeletonJoint( mat, o_it->id() );
if (_event->type() == QEvent::MouseButtonRelease)
emit updatedObject(objectId, UPDATE_GEOMETRY);
}
#endif
}
}
......@@ -768,10 +775,12 @@ void MovePlugin::placeManip(QMouseEvent * _event, bool _snap) {
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it)
o_it->enablePicking( true );
if ( object->dataType(DATA_SKELETON) ) {
if ( successfullyPicked && object->dataType(DATA_SKELETON) ) {
hitPoint = getNearestJoint(PluginFunctions::skeletonObject(object), hitPoint);
PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::WIREFRAME);
} else {
successfullyPicked = false;
}
......
......@@ -822,41 +822,68 @@ void MovePlugin::transformSkeletonJoint( int _objectId , Matrix4x4 _matrix ){
AnimationHandle handle = skeletonObj->skeletonNode()->getActivePose();
if ( !handle.isValid() ){
//no current animation found -> transform the reference Pose
Skeleton::Pose* pose = skeleton->getReferencePose();
Skeleton::Pose* activePose;
if ( !handle.isValid() )
activePose = skeleton->getReferencePose();
else
activePose = skeleton->getAnimation( handle.getAnimation() )->getPose( handle.getFrame() );
Matrix4x4 transform;
transform.identity();
//get transformation matrix
for (unsigned long joint = 0; joint < skeleton->getJointCount(); joint++){
if ( skeleton->getJoint(joint)->selected() ){
Skeleton::Joint* parent = skeleton->getJoint( joint )->getParent();
if ( parent != 0 )
// new GlobalMatrix after application of _matrix is: newLocal = _matrix * activePose->getGlobal( joint )
// new LocalMatrix : activePose->getGlobalInv( parent->getID() ) * newLocal
// Transformation from LocalMatrix to new LocalMatrix:
transform = activePose->getGlobalInv( parent->getID() ) * _matrix * activePose->getGlobal( joint ) * activePose->getLocalInv( joint );
else
transform = _matrix * activePose->getGlobal( joint ) * activePose->getLocalInv( joint );
break; // there should only be one joint selected
}
}
// apply transformation to all frames of all animations
for (unsigned long a=0; a < skeleton->getNumberOfAnimations(); a++)
for (unsigned long iFrame = 0; iFrame < skeleton->getAnimation(a)->getFrameCount(); iFrame++){
Skeleton::Pose* pose = skeleton->getAnimation(a)->getPose( iFrame );
//transform all selected joints
for (unsigned long joint = 0; joint < skeleton->getJointCount(); joint++){
if ( skeleton->getJoint(joint)->selected() ){
Matrix4x4 newMatrix = transform * pose->getLocal( joint );
Matrix4x4 transform = _matrix * pose->getGlobal( joint );
pose->setGlobal( joint, transform, recursiveJointTransformation_);
pose->setLocal( joint, newMatrix, !recursiveJointTransformation_);
}
}
}
} else {
//transform refPose
Skeleton::Pose* pose = skeleton->getReferencePose();
Skeleton::Animation* animation = skeleton->getAnimation(handle);
Skeleton::Pose* pose = animation->getPose( handle.getFrame() );
//transform all selected joints
for (unsigned long joint = 0; joint < skeleton->getJointCount(); joint++){
//transform all selected joints
for (unsigned long joint = 0; joint < skeleton->getJointCount(); joint++){
if ( skeleton->getJoint(joint)->selected() ){
if ( skeleton->getJoint(joint)->selected() ){
Matrix4x4 transform = _matrix * pose->getGlobal( joint );
pose->setGlobal( joint, transform, recursiveJointTransformation_);
}
Matrix4x4 newMatrix = transform * pose->getLocal( joint );
pose->setLocal( joint, newMatrix, !recursiveJointTransformation_);
}
}
}
#endif
......
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