Commit 01c4563a authored by Dirk Wilden's avatar Dirk Wilden
Browse files

now using skeletonTransform class

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@10030 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 931e5d84
...@@ -49,6 +49,9 @@ ...@@ -49,6 +49,9 @@
#ifdef ENABLE_TSPLINEMESH_SUPPORT #ifdef ENABLE_TSPLINEMESH_SUPPORT
#include <ObjectTypes/TSplineMesh/TSplineMesh.hh> #include <ObjectTypes/TSplineMesh/TSplineMesh.hh>
#endif #endif
#ifdef ENABLE_SKELETON_SUPPORT
#include <ObjectTypes/Skeleton/SkeletonTransform.hh>
#endif
#include <MeshTools/MeshFunctions.hh> #include <MeshTools/MeshFunctions.hh>
...@@ -850,9 +853,9 @@ void MovePlugin::transformSkeletonJoint( int _objectId , Matrix4x4 _matrix ){ ...@@ -850,9 +853,9 @@ void MovePlugin::transformSkeletonJoint( int _objectId , Matrix4x4 _matrix ){
Skeleton::Pose* activePose; Skeleton::Pose* activePose;
if ( !handle.isValid() ) if ( !handle.isValid() ){
activePose = skeleton->getReferencePose(); activePose = skeleton->getReferencePose();
else{ }else{
activePose = skeleton->getAnimation( handle.getAnimation() )->getPose( handle.getFrame() ); activePose = skeleton->getAnimation( handle.getAnimation() )->getPose( handle.getFrame() );
...@@ -869,84 +872,27 @@ void MovePlugin::transformSkeletonJoint( int _objectId , Matrix4x4 _matrix ){ ...@@ -869,84 +872,27 @@ void MovePlugin::transformSkeletonJoint( int _objectId , Matrix4x4 _matrix ){
_matrix = mat; _matrix = mat;
} }
Matrix4x4 transform;
transform.identity();
Skeleton::Joint* joint = skeleton->getJoint( skeletonObj->manipulatorNode()->getData().toInt() ); Skeleton::Joint* joint = skeleton->getJoint( skeletonObj->manipulatorNode()->getData().toInt() );
if (joint == 0) SkeletonTransform transformer(*skeleton);
return;
//get transformation matrix
Skeleton::Joint* parent = joint->getParent();
if ( parent != 0 ) if ( handle.isValid() )
// new GlobalMatrix after application of _matrix is: newGlobal = _matrix * activePose->getGlobal( joint ) //we are in an animation pose -> only rotation allowed
// new LocalMatrix : activePose->getGlobalInv( parent->getID() ) * newGlobal transformer.rotateJoint(joint, activePose, _matrix, !transformCurrentPose_);
// Transformation from LocalMatrix to new LocalMatrix:
transform = activePose->getGlobalInv( parent->getID() ) * _matrix * activePose->getGlobal( joint->getID() ) * activePose->getLocalInv( joint->getID() );
else else
// the transformation for the root joint has to be applied directly //we are in the refPose apply full transformation
// _matrix defines a post-multiplication but we need a pre-multiplication matrix X in order to apply transformer.transformJoint(joint, _matrix, recursiveJointTransformation);
// the transformation to all frames: _matrix * Global = Global * X --> X = GlobalInverse * _matrix * global
transform = activePose->getGlobalInv( joint->getID() ) * _matrix * activePose->getGlobal( joint->getID() ); // //if we are in refPose update segmentation
// if ( !handle.isValid() ){
// apply transformation to all frames of all animations // //tell segmenation plugin to update the segmentation
for (unsigned long a=0; a < skeleton->getNumberOfAnimations(); a++) // bool exists = false;
for (unsigned long iFrame = 0; iFrame < skeleton->getAnimation(a)->getFrameCount(); iFrame++){ //
// emit functionExists("segmentationplugin", "updateSegmentation()", exists);
//if transformCurrentPose is true skip all other poses //
if (transformCurrentPose_ && ( (handle.getAnimation() != a) || (handle.getFrame() != iFrame) )) // if (exists)
continue; // RPC::callFunction("segmentationplugin", "updateSegmentation");
// }
Skeleton::Pose* pose = skeleton->getAnimation(a)->getPose( iFrame );
if ( parent != 0 ){
//transform the local matrix
Matrix4x4 newMatrix = transform * pose->getLocal( joint->getID() );
pose->setLocal( joint->getID(), newMatrix, !recursiveJointTransformation);
} else {
//directly apply the global transformation
Matrix4x4 newMatrix = pose->getGlobal( joint->getID() ) * transform;
pose->setLocal( joint->getID(), newMatrix, !recursiveJointTransformation);
}
}
// only apply to refPose if we either are in refPose or if refPoseTransformation is enabled
if ( (!transformCurrentPose_ && transformRefPose_) || !handle.isValid() ){
//transform refPose
Skeleton::Pose* pose = skeleton->getReferencePose();
if ( parent != 0 ){
//transform all selected joints
Matrix4x4 newMatrix = transform * pose->getLocal( joint->getID() );
pose->setLocal( joint->getID(), newMatrix, !recursiveJointTransformation);
} else {
//directly apply the global transformation
Matrix4x4 newMatrix = pose->getGlobal( joint->getID() ) * transform;
pose->setLocal( joint->getID(), newMatrix, !recursiveJointTransformation);
}
//tell segmenation plugin to update the segmentation
bool exists = false;
emit functionExists("segmentationplugin", "updateSegmentation()", exists);
if (exists)
RPC::callFunction("segmentationplugin", "updateSegmentation");
}
//update the skin //update the skin
bool exists = false; bool exists = false;
...@@ -956,9 +902,9 @@ void MovePlugin::transformSkeletonJoint( int _objectId , Matrix4x4 _matrix ){ ...@@ -956,9 +902,9 @@ void MovePlugin::transformSkeletonJoint( int _objectId , Matrix4x4 _matrix ){
if (exists) if (exists)
RPC::callFunction("skeletonplugin", "updateSkin"); RPC::callFunction("skeletonplugin", "updateSkin");
emit updatedObject(_objectId, UPDATE_GEOMETRY); emit updatedObject(_objectId, UPDATE_GEOMETRY);
QString matString; QString matString;
for (int i=0; i < 4; i++) for (int i=0; i < 4; i++)
for (int j=0; j < 4; j++) for (int j=0; j < 4; j++)
matString += " , " + QString::number( _matrix(i,j) ); matString += " , " + QString::number( _matrix(i,j) );
......
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