Commit daefb226 authored by Dirk Wilden's avatar Dirk Wilden

plugin-skeletonEditing

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@10506 383ad7c9-94d9-4d36-a494-682f7c89f535
parents
include (plugin)
openflipper_plugin (INSTALLDATA Icons)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="svg2"
version="1.1"
inkscape:version="0.47 r22583"
width="48"
height="48"
sodipodi:docname="selection.svg"
inkscape:export-filename="/home/wilden/projects/OpenFlipper-Free/Plugin-SkeletonEditing/Icons/skeleton_selectJoint.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs6">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
id="perspective10" />
<inkscape:perspective
id="perspective2826"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective2822"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<filter
inkscape:collect="always"
id="filter3618">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="0.30508475"
id="feGaussianBlur3620" />
</filter>
</defs>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1154"
id="namedview4"
showgrid="false"
inkscape:zoom="4.9166667"
inkscape:cx="-17.79661"
inkscape:cy="24"
inkscape:window-x="-4"
inkscape:window-y="-3"
inkscape:window-maximized="1"
inkscape:current-layer="svg2" />
<image
y="0.6101703"
x="-0.81355971"
id="image2824"
height="48"
width="48"
xlink:href="file:///data1/home2/wilden/projects/OpenFlipper-Free/Plugin-SkeletonEditing/Icons/bla.png" />
<path
sodipodi:type="arc"
style="fill:#ff0000;fill-opacity:0.84070794;stroke:none"
id="path2828"
sodipodi:cx="-26.745762"
sodipodi:cy="14.338984"
sodipodi:rx="4.3728814"
sodipodi:ry="4.3728814"
d="m -22.37288,14.338984 a 4.3728814,4.3728814 0 1 1 -8.745763,0 4.3728814,4.3728814 0 1 1 8.745763,0 z"
transform="matrix(0.88372093,0,0,0.88372093,36.212062,-9.0106424)" />
<path
style="fill:#ffffff;fill-opacity:0.79227053999999986;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none;opacity:0.80800000000000005;stroke-dashoffset:0;filter:url(#filter3618)"
d="m 14.847458,5.8983049 5.898304,23.3898301 6.305085,-5.898304 12,14.033899 5.288136,-4.474577 -12.20339,-13.220339 6.915255,-5.898305 -24.20339,-7.9322041 z"
id="path2832"
sodipodi:nodetypes="cccccccc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
</svg>
This diff is collapsed.
#ifndef SKELETONEDITINGPLUGIN_HH
#define SKELETONEDITINGPLUGIN_HH
#include <QObject>
#include <QMenuBar>
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/MouseInterface.hh>
#include <OpenFlipper/BasePlugin/KeyInterface.hh>
#include <OpenFlipper/BasePlugin/PickingInterface.hh>
#include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/ScriptInterface.hh>
#include <OpenFlipper/BasePlugin/ToolbarInterface.hh>
#include <OpenFlipper/BasePlugin/ContextMenuInterface.hh>
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
#include <OpenFlipper/BasePlugin/BackupInterface.hh>
#include <OpenFlipper/BasePlugin/RPCInterface.hh>
#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/Skeleton/Skeleton.hh>
#include "SkeletonMarker.hh"
/** Plugin for creating and editing skeletons
*/
class SkeletonEditingPlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, PickingInterface, ToolboxInterface, LoggingInterface, ScriptInterface,ToolbarInterface, ContextMenuInterface, LoadSaveInterface, BackupInterface, RPCInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(MouseInterface)
Q_INTERFACES(KeyInterface)
Q_INTERFACES(PickingInterface)
Q_INTERFACES(ToolboxInterface)
Q_INTERFACES(LoggingInterface)
Q_INTERFACES(ContextMenuInterface)
Q_INTERFACES(ScriptInterface)
Q_INTERFACES(ToolbarInterface)
Q_INTERFACES(LoadSaveInterface)
Q_INTERFACES(BackupInterface)
Q_INTERFACES(RPCInterface)
signals:
// BaseInterface
void updateView();
void updatedObject(int, const UpdateType _type);
void nodeVisibilityChanged(int);
// PickingInterface
void addPickMode( const std::string _mode );
void addHiddenPickMode( const std::string _mode );
void setPickModeMouseTracking (const std::string _mode, bool _mouseTracking);
void setPickModeToolbar (const std::string _mode, QToolBar * _toolbar);
// ContextMenuInterface
void addContextMenuItem(QAction* _action , ContextMenuType _type);
// LoggingInterface
void log(Logtype _type, QString _message);
void log(QString _message);
// ScriptInterface
void scriptInfo( QString _functionName );
void setSlotDescription(QString _slotName, QString _slotDescription,
QStringList _parameters, QStringList _descriptions);
// ToolbarInterface
void addToolbar(QToolBar* _toolbar);
void getToolBar( QString _name, QToolBar*& _toolbar);
// KeyInterface
void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse = false);
// ToolboxInterface
void addToolbox( QString _name , QWidget* _widget );
// LoadSaveInterface
void addEmptyObject(DataType _type, int& _id);
void deleteObject( int _id);
// BackupInterface
void createBackup( int _objectid, QString _name);
private slots :
// BaseInterface
void initializePlugin();
void pluginsInitialized();
void slotObjectUpdated( int _id, const UpdateType _type);
// MouseInterface
void slotMouseWheelEvent(QWheelEvent * _event, const std::string & _mode);
void slotMouseEvent( QMouseEvent* _event );
// KeyInterface
void slotKeyEvent (QKeyEvent* _event);
void slotKeyReleaseEvent (QKeyEvent* _event);
// PickingInterface
void slotPickModeChanged( const std::string& _mode);
private:
void moveJoint(QMouseEvent* _event);
void insertJoint(QMouseEvent* _event);
void cancelJointInsertion();
void deleteJoint(QMouseEvent* _event);
void selectJoint(QMouseEvent* _event);
Skeleton::Pose* activePose(SkeletonObject* _skeletonObj);
void setJointPosition(SkeletonObject* _skeletonObj, Skeleton::Joint* _joint, ACG::Vec3d& _position);
OpenMesh::Vec3d getNearestJoint(SkeletonObject* _skeletonObj, OpenMesh::Vec3d &_hitPoint, int& _bestJointID);
public:
/// Default Constructor
SkeletonEditingPlugin();
/// Destructor
~SkeletonEditingPlugin();
/// Name of the Plugin
QString name(){ return (QString("Skeleton Editing")); };
/// Description of the Plugin
QString description() { return (QString(tr("Create and edit skeletons"))); };
//===========================================================================
/** @name Scriptable Functions
* @{ */
//===========================================================================
public slots:
/// insert a joint in the middle of a bone given by its (unique) tailJoint
void splitBone( int _objectId, int _tailJoint);
/// add joint to the skeleton
void addJoint( int _objectId, int _parent, Vector _position );
/// delete joint from the skeleton
void deleteJoint( int _objectId , int _jointId );
/// transform joint with given matrix
void transformJoint( int _objectId , int _jointId, Matrix4x4 _matrix );
/// get global matrix of a joint in the active pose
Matrix4x4 globalMatrix(int _objectId, int _jointId);
/// get local matrix of a joint in the active pose
Matrix4x4 localMatrix(int _objectId, int _jointId);
/// get global translation of a joint in the active pose
Vector globalTranslation(int _objectId, int _jointId);
/// get local translation of a joint in the active pose
Vector localTranslation(int _objectId, int _jointId);
/// get the number of animations
int animationCount(int _objectId);
/// get the number of frames
int frameCount(int _objectId, int _animationIndex);
/// get active animation
int activeAnimation(int _objectId);
/// get active frame
int activeFrame(int _objectId);
/// set active pose
void setActivePose(int _objectId, int _animationIndex, int _frame);
/// add animation
void addAnimation(int _objectId, QString _name, int _frames);
/** @} */
public slots:
QString version() { return QString("1.0"); };
private slots:
void slotSetEditingMode(QAction* _action);
void slotPickToolbarAction(QAction* _action);
void setDescriptions();
private:
QToolBar* toolbar_;
QActionGroup* toolBarActions_;
QAction* skeletonEditingAction_;
QToolBar* pickToolbar_;
QActionGroup* pickToolBarActions_;
QAction* selectJointAction_;
QAction* insertJointAction_;
QAction* deleteJointAction_;
QAction* moveJointAction_;
QAction* transformChildManipAction_;
QAction* transformAllManipAction_;
QAction* rotateManipAction_;
int currentSkeleton_;
int currentJoint_;
bool jointPreview_;
bool transformChildJoints_;
bool transformAllFrames_;
private:
// object ids of all objects with active Manipulator
std::vector< int > activeManipulators_;
// Size for the manipulators
double manip_size_;
// Modifier for the Size (changed by Mousewheel Events)
double manip_size_modifier_;
// Object marker to dimm Objects during manipulator transformation
SkeletonMarker objectMarker_;
private:
/// Place and show the Manipulator
void placeManip(QMouseEvent* _event);
/// Show/Hide active manipulators
void showManipulators();
/// make sure the manipulator is positioned on a joint
void updateManipulatorPosition(BaseObjectData* _skeletonObj);
private slots:
/// move the object when its manipulator moves
void manipulatorMoved( QtTranslationManipulatorNode* _node , QMouseEvent* _event);
/// update object when its manipulator changes position
void ManipulatorPositionChanged(QtTranslationManipulatorNode* _node );
void slotRotateManipulator(bool _toggled);
};
#endif //SKELETONEDITINGPLUGIN_HH
This diff is collapsed.
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2010 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 10296 $ *
* $LastChangedBy: moebius $ *
* $Date: 2010-11-25 08:28:35 +0100 (Thu, 25 Nov 2010) $ *
* *
\*===========================================================================*/
#include <OpenFlipper/common/Types.hh>
#include <OpenFlipper/common/BaseObjectData.hh>
#include "SkeletonMarker.hh"
//******************************************************************************
const ACG::Vec4f base_color (0.4,0.4,0.4,1.0);
//******************************************************************************
bool SkeletonMarker::stencilRefForObject(BaseObjectData * _obj, GLuint & _reference)
{
_reference = 1;
return true;
}
bool SkeletonMarker::blendForStencilRefNumber(GLuint _reference, GLenum & _src, GLenum & _dst, ACG::Vec4f & _color)
{
if (_reference != 1)
return false;
_src = GL_ZERO;
_dst = GL_SRC_COLOR;
_color = base_color;
return true;
}
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2010 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 10296 $ *
* $LastChangedBy: moebius $ *
* $Date: 2010-11-25 08:28:35 +0100 (Thu, 25 Nov 2010) $ *
* *
\*===========================================================================*/
#ifndef SKELETONMARKER_HH
#define SKELETONMARKER_HH
#include <OpenFlipper/common/ViewObjectMarker.hh>
/** Object marker to dim all Objects during Maipulator transformation
*/
class SkeletonMarker : public ViewObjectMarker
{
public:
bool stencilRefForObject (BaseObjectData *_obj, GLuint &_reference);
bool blendForStencilRefNumber (GLuint _reference, GLenum &_src, GLenum &_dst, ACG::Vec4f &_color);
};
#endif //SKELETONMARKER_HH
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