Commit de25913b authored by Matthias Möller's avatar Matthias Möller

removed function and Button: "rotate local Coord System"

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13156 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 280a4c0e
......@@ -20,7 +20,6 @@ SkeletonEditingPlugin::SkeletonEditingPlugin()
transformChildJoints_(false),
transformAllFrames_(true),
inverseKinematic_(false),
rotateCoordSystem_(false),
dblClick_(false),
lastRenderer_(""),
rendererChanged_(false)
......@@ -150,15 +149,6 @@ void SkeletonEditingPlugin::pluginsInitialized() {
inverseKinematicAction_->setChecked(inverseKinematic_);
pickToolbar_->addAction(inverseKinematicAction_);
rotateCoordSystemAction_ = new QAction(tr("Rotate local coordinate system"), pickToolBarActions_);
rotateCoordSystemAction_->setStatusTip(tr(""));
rotateCoordSystemAction_->setToolTip(tr("<B></B><br>."));
rotateCoordSystemAction_->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"skeleton_invkinematic.png") );
rotateCoordSystemAction_->setCheckable(true);
rotateCoordSystemAction_->setChecked(rotateCoordSystem_);
pickToolbar_->addAction(rotateCoordSystemAction_);
connect(pickToolBarActions_, SIGNAL(triggered(QAction*)), this, SLOT(slotPickToolbarAction(QAction*)) );
emit setPickModeToolbar("MoveJoints", pickToolbar_);
......@@ -355,8 +345,6 @@ void SkeletonEditingPlugin::slotPickToolbarAction(QAction* _action)
transformChildJoints_ = transformChildManipAction_->isChecked();
else if (_action == inverseKinematicAction_)
inverseKinematic_ = inverseKinematicAction_->isChecked();
else if (_action == rotateCoordSystemAction_)
rotateCoordSystem_ = rotateCoordSystemAction_->isChecked();
moveJointAction_->setChecked( _action == moveJointAction_);
insertJointAction_->setChecked( _action == insertJointAction_ );
......@@ -584,50 +572,6 @@ void SkeletonEditingPlugin::placeManip(QMouseEvent * _event) {
object->manipulatorNode()->apply_transformation(false);
//deactivate unused rotation axes
//and set the direction correctly
if (rotateCoordSystem_)
{
// Get parent and child joints if they exist.
Skeleton::Joint* parentJoint = pickedJoint->parent();
Skeleton::Joint* childJoint = pickedJoint->child(0);
// Root joint uses the local joint coordinate system
if ( parentJoint == 0 ) {
} else if ( childJoint == 0) { // Leaf joint, only the previous axis is important
Vector prevAxis = currentPose->globalTranslation(pickedJoint->id()) - currentPose->globalTranslation(parentJoint->id());
prevAxis.normalize();
// Create a local coordinate system based on the axis and an arbitrary right vector
Vector cross = ACG::Geometry::perpendicular(prevAxis);
cross.normalize();
object->manipulatorNode()->set_direction(prevAxis,cross);
// As we only allow rotations around the main axis, we disable the others
//object->manipulatorNode()->enable_rotations(QtTranslationManipulatorNode::X_AXIS);
} else { //Joint in between, use both to estimate a good orientation of the manipulator
Vector prevAxis = currentPose->globalTranslation(pickedJoint->id()) - currentPose->globalTranslation(parentJoint->id());
Vector nextAxis = currentPose->globalTranslation(childJoint->id()) - currentPose->globalTranslation(pickedJoint->id());
prevAxis.normalize();
nextAxis.normalize();
// Create a local coordinate system based on the axis and an right vector depending on the bone positions
Vector right = prevAxis % nextAxis;
right.normalize();
object->manipulatorNode()->set_direction(prevAxis,right);
// As we only allow rotations around the main axis, we disable the others
//object->manipulatorNode()->enable_rotations(QtTranslationManipulatorNode::X_AXIS);
}
}
// Disconnect a previously connected Signal
disconnect(object->manipulatorNode() , SIGNAL(manipulatorMoved(QtTranslationManipulatorNode*,QMouseEvent*)),
......@@ -766,75 +710,6 @@ void SkeletonEditingPlugin::manipulatorMoved( QtTranslationManipulatorNode* _nod
BaseObjectData* object = 0;
PluginFunctions::getObject(objectId, object);
if(rotateCoordSystem_)
{
Skeleton* skeleton = PluginFunctions::skeleton( object );
if (skeleton == 0)
return;
Skeleton::Joint* pickedJoint = skeleton->joint( _node->getData().toInt() );
if (!pickedJoint)
return;
Skeleton::Pose* currentPose = activePose(PluginFunctions::skeletonObject(object));
// we compute the rotation angle by applying the
// rotation matrix from the manipulator to an arbitrary point
ACG::Vec3d tmpVec = ACG::Vec3d( 1.0, 1.0, 1.0 ).normalize();
ACG::Vec3d tmpRotVec = mat.transform_point( tmpVec ).normalize();
const ACG::Vec3d rotation_axis = cross(tmpVec,tmpRotVec).normalize();
const ACG::Vec3d right = cross(tmpVec, rotation_axis).normalize();
double angle = acos( dot(tmpVec , tmpRotVec) );
if (angle != angle) // NaN?
return;
// compute the direction of the rotation
if (dot(right, tmpRotVec) < 0)
angle = -angle;
// count all joints from including the picked joint to the selected joint
Skeleton::Joint* iter = pickedJoint;
unsigned int count_joint = 0;
while(iter && ((!iter->selected() && !iter->isRoot()) || iter == pickedJoint))
{
++count_joint;
iter = iter->parent();
}
// the weight of our rotation
// the first joint gets rotated by 100%
double weight = 1.0;
// rotate the joints including the picked joints and its children
// until the selected joint
// with the given angle and the given weight
// iter can be NULL, when pickedJoint == Root
iter = pickedJoint;
while(iter && ((!iter->selected() && !iter->isRoot()) || iter == pickedJoint))
{
unsigned int id = iter->id();
// get our rotation axis. notice: vector given back by "localTranslation" is in localMatrix space
ACG::Vec3d axis = currentPose->localTranslation(id);
ACG::Quaterniond quaternion(axis, weight*angle);
// rotate the joint around its own axis
ACG::Matrix4x4d newLocalMatrix = currentPose->localMatrix(id) * quaternion.rotation_matrix();
currentPose->setLocalMatrix(id, newLocalMatrix, true);
iter = iter->parent();
// interpolate the weight of the rotation between the joints
weight -= 1.0/count_joint;
}
}
if(inverseKinematic_)
{
Skeleton* skeleton = PluginFunctions::skeleton( object );
......
......@@ -206,7 +206,6 @@ class SkeletonEditingPlugin : public QObject, BaseInterface, MouseInterface, Key
QAction* transformAllManipAction_;
QAction* rotateManipAction_;
QAction* inverseKinematicAction_;
QAction* rotateCoordSystemAction_;
int currentSkeleton_;
int currentJoint_;
......@@ -215,7 +214,6 @@ class SkeletonEditingPlugin : public QObject, BaseInterface, MouseInterface, Key
bool transformChildJoints_;
bool transformAllFrames_;
bool inverseKinematic_;
bool rotateCoordSystem_;
bool dblClick_;
......
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