Commit b6cb0226 authored by Dirk Wilden's avatar Dirk Wilden

movePlugin now able to move whole skeletons and single skeleton-joints. also added some nice icons.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9439 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 85bcaa4d
...@@ -8,4 +8,8 @@ if (EXISTS ${CMAKE_SOURCE_DIR}/ObjectTypes/TSplineMesh) ...@@ -8,4 +8,8 @@ if (EXISTS ${CMAKE_SOURCE_DIR}/ObjectTypes/TSplineMesh)
add_definitions (-DENABLE_TSPLINEMESH_SUPPORT) add_definitions (-DENABLE_TSPLINEMESH_SUPPORT)
endif () endif ()
if (EXISTS ${CMAKE_SOURCE_DIR}/ObjectTypes/Skeleton)
add_definitions (-DENABLE_SKELETON_SUPPORT)
endif ()
openflipper_plugin ( TSplineMesh TRANSLATION_LANGUAGES de_DE INSTALLDATA Icons ) openflipper_plugin ( TSplineMesh TRANSLATION_LANGUAGES de_DE INSTALLDATA Icons )
Plugin-Move/Icons/move-objects.png

3.39 KB | W: | H:

Plugin-Move/Icons/move-objects.png

3.15 KB | W: | H:

Plugin-Move/Icons/move-objects.png
Plugin-Move/Icons/move-objects.png
Plugin-Move/Icons/move-objects.png
Plugin-Move/Icons/move-objects.png
  • 2-up
  • Swipe
  • Onion skin
Plugin-Move/Icons/move-selections.png

3.43 KB | W: | H:

Plugin-Move/Icons/move-selections.png

3.26 KB | W: | H:

Plugin-Move/Icons/move-selections.png
Plugin-Move/Icons/move-selections.png
Plugin-Move/Icons/move-selections.png
Plugin-Move/Icons/move-selections.png
  • 2-up
  • Swipe
  • Onion skin
This diff is collapsed.
...@@ -62,6 +62,10 @@ ...@@ -62,6 +62,10 @@
#include <ObjectTypes/Plane/Plane.hh> #include <ObjectTypes/Plane/Plane.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh> #include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
#ifdef ENABLE_SKELETON_SUPPORT
#include <ObjectTypes/Skeleton/Skeleton.hh>
#endif
#include "MoveToolbar.hh" #include "MoveToolbar.hh"
#include "MoveProps.hh" #include "MoveProps.hh"
#include "MoveObjectMarker.hh" #include "MoveObjectMarker.hh"
...@@ -224,6 +228,10 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, ...@@ -224,6 +228,10 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface,
template <typename MeshType> template <typename MeshType>
OpenMesh::Vec3d getNearestFace(MeshType* _mesh, uint _fh, OpenMesh::Vec3d& _hitPoint); OpenMesh::Vec3d getNearestFace(MeshType* _mesh, uint _fh, OpenMesh::Vec3d& _hitPoint);
#ifdef ENABLE_SKELETON_SUPPORT
OpenMesh::Vec3d getNearestJoint(Skeleton* _skeleton, OpenMesh::Vec3d &_hitPoint);
#endif
/// True if the toolbox widget is active /// True if the toolbox widget is active
bool toolboxActive_; bool toolboxActive_;
...@@ -240,7 +248,8 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, ...@@ -240,7 +248,8 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface,
private : private :
QAction* moveAction_; QAction* moveAction_;
QAction* moveSelectionAction_; QAction* moveSelectionAction_;
QAction* moveSkeletonAction_;
QActionGroup* toolBarActions_; QActionGroup* toolBarActions_;
QToolBar* toolbar_; QToolBar* toolbar_;
...@@ -268,6 +277,8 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, ...@@ -268,6 +277,8 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface,
QAction* biggerManipAction_; QAction* biggerManipAction_;
QAction* smallerManipAction_; QAction* smallerManipAction_;
QAction* fixChildManipAction_;
QAction* placeAndSnapAction_; QAction* placeAndSnapAction_;
QActionGroup* pickToolBarActions_; QActionGroup* pickToolBarActions_;
...@@ -305,7 +316,11 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, ...@@ -305,7 +316,11 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface,
#ifdef ENABLE_POLYLINE_SUPPORT #ifdef ENABLE_POLYLINE_SUPPORT
///Transform a polyline with the given transformation matrix ///Transform a polyline with the given transformation matrix
template< class PolyLineT > template< class PolyLineT >
void transformPolyLine( ACG::Matrix4x4d _mat , PolyLineT& _polyLine ); void transformPolyLine( ACG::Matrix4x4d _mat , PolyLineT& _polyLine );
#endif
#ifdef ENABLE_SKELETON_SUPPORT
void transformSkeleton(ACG::Matrix4x4d _mat , Skeleton& _skeleton );
#endif #endif
/** Get the Matrix of the last active Manipulator ( Identity if not found or hidden Manipulator ) /** Get the Matrix of the last active Manipulator ( Identity if not found or hidden Manipulator )
...@@ -350,10 +365,18 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, ...@@ -350,10 +365,18 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface,
/// Move selection on an object with given id /// Move selection on an object with given id
void moveSelection(ACG::Matrix4x4d mat, int _id); void moveSelection(ACG::Matrix4x4d mat, int _id);
/// Move joint of a skeleton
void moveSkeletonJoint(ACG::Matrix4x4d mat, int _id);
/// Object marker to dimm Objects during manipulator transformation /// Object marker to dimm Objects during manipulator transformation
MoveObjectMarker objectMarker_; MoveObjectMarker objectMarker_;
#ifdef ENABLE_SKELETON_SUPPORT
/// make sure the manipulator is positioned on a joint
void moveManipulatorOnSkeleton(BaseObjectData* _skeletonObj);
#endif
private: private:
/// Holds the current manipulator mode /// Holds the current manipulator mode
...@@ -457,6 +480,9 @@ public slots : ...@@ -457,6 +480,9 @@ public slots :
/// transform current selection of an Object by a given matrix /// transform current selection of an Object by a given matrix
void transformEdgeSelection( int _objectId , Matrix4x4 _matrix ); void transformEdgeSelection( int _objectId , Matrix4x4 _matrix );
/// transform selected joint with given matrix
void transformSkeletonJoint( int _objectId , Matrix4x4 _matrix );
/// Set the position of the manipulator /// Set the position of the manipulator
void setManipulatorPosition( int _objectId , Vector _position ); void setManipulatorPosition( int _objectId , Vector _position );
...@@ -485,6 +511,8 @@ public slots : ...@@ -485,6 +511,8 @@ public slots :
bool allTargets_; bool allTargets_;
bool placeMode_; bool placeMode_;
bool recursiveJointTransformation_;
}; };
#endif //MOVEPLUGIN_HH #endif //MOVEPLUGIN_HH
...@@ -783,6 +783,76 @@ void MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){ ...@@ -783,6 +783,76 @@ void MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){
emit scriptInfo( "transformEdgeSelection( ObjectId , Matrix4x4(" + matString + " ) )" ); emit scriptInfo( "transformEdgeSelection( ObjectId , Matrix4x4(" + matString + " ) )" );
} }
//------------------------------------------------------------------------------
#ifdef ENABLE_SKELETON_SUPPORT
/** \brief transform selected joints with given matrix
*
* when a manipulator is placed on a joint, the selection of the skeleton
* is cleared and only that joint is selected
* the selection is used here to find the joint to be deformed
*
* @param _objectId id of an object
* @param _matrix transformation matrix
*/
void MovePlugin::transformSkeletonJoint( int _objectId , Matrix4x4 _matrix ){
BaseObjectData* obj = 0;
PluginFunctions::getObject(_objectId, obj);
if (obj == 0){
emit log(LOGERR, tr("Unable to get object"));
return;
}
Skeleton* skeleton = PluginFunctions::skeleton(obj);
if (skeleton == 0){
emit log(LOGERR, tr("Unable to get skeleton"));
return;
}
AnimationHandle handle = skeleton->getCurrentAnimation();
if ( !handle.isValid() ){
//no current animation found -> transform the reference Pose
Skeleton::Pose* pose = skeleton->getReferencePose();
//transform all selected joints
for (unsigned long joint = 0; joint < skeleton->getJointCount(); joint++){
if ( skeleton->getJoint(joint)->selected() ){
Matrix4x4 transform = _matrix * pose->getGlobal( joint );
pose->setGlobal( joint, transform, recursiveJointTransformation_);
}
}
} else {
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++){
if ( skeleton->getJoint(joint)->selected() ){
Matrix4x4 transform = _matrix * pose->getGlobal( joint );
pose->setGlobal( joint, transform, 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