Commit 0cc87b05 authored by Dirk Wilden's avatar Dirk Wilden

SkeletalAnimation Plugin

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@10505 383ad7c9-94d9-4d36-a494-682f7c89f535
parents
#== SYSTEM PART -- DON'T TOUCH ==============================================
include $(ACGMAKE)/Config
#==============================================================================
SUBDIRS = $(call find-subdirs)
PACKAGES := qt4 glut glew opengl x11 math ACG2 openmesh2
PROJ_LIBS =
MODULES := uic4 moc4 cxxplugin
#== SYSTEM PART -- DON'T TOUCH ==============================================
include $(ACGMAKE)/Rules
#==============================================================================
#include "AnimationToolbox.hh"
#include <QtGui>
AnimationToolboxWidget::AnimationToolboxWidget(QWidget *parent) : QWidget(parent)
{
setupUi(this);
}
#include <ui_animationControls.hh>
#include <QtGui>
class AnimationToolboxWidget : public QWidget, public Ui::AnimationControls
{
Q_OBJECT
public:
AnimationToolboxWidget(QWidget *parent = 0);
};
include (plugin)
openflipper_plugin ()
################################################################################
# Plugin SkeletalAnimation
################################################################################
include( $${TOPDIR}/qmake/all.include )
Plugin()
DIRECTORIES = .
DIRECTORIES += $$files($${TOPDIR}/Plugin-SkeletalAnimation/*)
# Input
HEADERS += $$getFilesFromDir($$DIRECTORIES,*.hh)
SOURCES += $$getFilesFromDir($$DIRECTORIES,*.cc)
FORMS += $$getFilesFromDir($$DIRECTORIES,*.ui)
################################################################################
This diff is collapsed.
#include <QObject>
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/TextureInterface.hh>
#include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
#include <OpenFlipper/BasePlugin/RPCInterface.hh>
#include <ACG/QtWidgets/QtExaminerViewer.hh>
#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include "AnimationToolbox.hh"
#include "ObjectTypes/Skeleton/SkeletonObjectDataT.hh"
#include "ObjectTypes/Skeleton/Skeleton.hh"
#include "ObjectTypes/Skeleton/PoseT.hh"
#include "ObjectTypes/Skeleton/BaseSkin.hh"
/**
* @brief The skeletal animation plugin is used to interact with the skeleton
*
* this plugin controls the playback of skeletal animations
*
*/
class SkeletalAnimationPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, LoadSaveInterface, RPCInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(ToolboxInterface)
Q_INTERFACES(LoggingInterface)
Q_INTERFACES(LoadSaveInterface)
Q_INTERFACES(RPCInterface)
private:
/// Pose typedef
typedef PoseT<Skeleton::Point> Pose;
signals:
void updateView();
void log(Logtype _type, QString _message);
void log(QString _message);
void addEmptyObject(DataType _type, int& _id);
void updatedObject(int _id, const UpdateType _type);
void pluginExists(QString _pluginName, bool &_exists);
void functionExists(QString _pluginName, QString _functionName, bool &_exists);
// ToolboxInterface
void addToolbox( QString _name , QWidget* _widget );
public slots:
// BaseInterface
void slotAllCleared();
void slotObjectUpdated( int _id, const UpdateType _type);
void slotObjectSelectionChanged(int _id);
// LoadSaveInterface
void fileOpened(int _id);
void addedEmptyObject(int _id);
void objectDeleted(int _id);
public slots:
/**
* @name Scripting interface
* Use these methods in the script editor.
*/
//@{
int getNumberOfFrames();
bool attachSkin(int skeletonId, int skinId);
bool detachSkin(int skeletonId);
void setFrame(int _iFrame);
int getFrame();
void changeFPS(int _fps);
void playAnimation();
void pauseAnimation();
void stopAnimation();
void nextFrame();
void prevFrame();
void updateSkin();
//@}
void UpdateUI();
void checkObjectSelection();
private slots:
void setDescriptions();
void initializePlugin();
void pluginsInitialized();
void exit();
void slotBindMesh();
void slotUnbindMesh();
void slotMethodChanged(int _index);
void slotAnimationIndexChanged(int /*_index*/);
void slotFrameChanged(int /*_index*/);
void slotSkipFramesChanged(int _state);
void animate();
public:
SkeletalAnimationPlugin() : pToolbox_(0) {};
QString name();
QString description();
protected:
AnimationHandle currentAnimationHandle();
void UpdateSkin(BaseObjectData *_pSkeletonObject, AnimationHandle &_hAni);
private:
/**
* @name Rigging
*/
//@{
void rig(BaseObjectData *pSkin, BaseObjectData *pSkeleton);
void unrig(BaseObjectData *_pSkeleton);
//@}
protected:
AnimationToolboxWidget *pToolbox_; ///< A pointer to the toolbox widget
private:
BaseSkin::Method method_; ///< The current blending method for the skin
bool bGuiUpdating_; ///< Used to drop a few messages while the gui is being updated
QTimer animationTimer_; ///< Timer used to control animations
QTime animationTime_; ///< Time since the animation was started, used to meet the given fps
int animationOffset_; ///< This frame was selected as the animation was started
std::vector< int > activeSkeletons_;
std::vector< int > activeMeshes_;
};
#include "SkeletalAnimationPlugin.hh"
void SkeletalAnimationPlugin::setDescriptions(){
emit setSlotDescription("attachSkin(int,int)",tr("Attaches a mesh to a skeleton as skin. Each are identified by their objectIds"),
QString(tr("SkeletonObjectId,SkinObjectId")).split(","),
QString(tr("id of the skeleton object, id of the skin object")).split(","));
emit setSlotDescription("detachSkin(int)",tr("Removes a skeleton's skin"),
QStringList(tr("SkeletonObjectId")), QStringList(tr("ID of the skeleton object")));
}
bool SkeletalAnimationPlugin::attachSkin(int skeletonId, int skinId) {
// BaseObjectData* skeleton = NULL;
// if (!PluginFunctions::getObject(skeletonId, skeleton)) {
// emit log(LOGERR, "Could not retrieve skeleton");
// return false;
// }
//
// BaseObjectData* skin = NULL;
// if (!PluginFunctions::getObject(skinId, skin)) {
// emit log(LOGERR, "Could not retrieve skin");
// return false;
// }
//
// rig(skin, skeleton);
//
return true;
}
bool SkeletalAnimationPlugin::detachSkin(int skeletonId) {
// BaseObjectData* skeleton = NULL;
// if (!PluginFunctions::getObject(skeletonId, skeleton)) {
// emit log(LOGERR, "Could not retrieve skeleton");
// return false;
// }
//
// unrig(skeleton);
//
return true;
}
void SkeletalAnimationPlugin::updateSkin(){
// BaseObjectData *pMeshObject = 0, *pSkeletonObject = 0;
// GetSelectedPair(&pMeshObject, &pSkeletonObject);
//
// if (pSkeletonObject != 0){
// AnimationHandle hAni = PluginFunctions::skeletonObject(pSkeletonObject)->skeletonNode()->getActivePose();
// UpdateSkin(pSkeletonObject, hAni);
// }
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AnimationControls</class>
<widget class="QWidget" name="AnimationControls">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>311</width>
<height>283</height>
</rect>
</property>
<property name="windowTitle">
<string>controls</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Animation control</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Animation:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cbAnimation">
<property name="editable">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Method:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="cbMethod"/>
</item>
</layout>
</item>
<item>
<widget class="QSlider" name="hsFrame">
<property name="maximum">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hlPlaybackControls">
<item>
<layout class="QGridLayout" name="glFrameCounter" columnstretch="0,0">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Frame</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="lbFrameNumber">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pbPlay">
<property name="toolTip">
<string comment="Play/Pause" extracomment="Start playback or pause it"/>
</property>
<property name="text">
<string notr="true"></string>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbStop">
<property name="toolTip">
<string comment="Stop" extracomment="Halt playback and go to frame 0"/>
</property>
<property name="text">
<string notr="true"></string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbPrevFrame">
<property name="toolTip">
<string comment="Previous frame" extracomment="Go to the previous frame"/>
</property>
<property name="text">
<string>|◀</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbNextFrame">
<property name="toolTip">
<string comment="Next frame" extracomment="Go to the next frame"/>
</property>
<property name="text">
<string>▶|</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="hlAdvancedPlayback">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="cbSkipFrames">
<property name="text">
<string>Frame skipping</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>10</number>
</property>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>FPS</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbFPS">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>400</number>
</property>
<property name="value">
<number>60</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Rigging</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="pbBindMesh">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Connect Skin and Skeleton</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbUnbindMesh">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Unbind</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>hsFrame</sender>
<signal>sliderMoved(int)</signal>
<receiver>lbFrameNumber</receiver>
<slot>setNum(int)</slot>
<hints>
<hint type="sourcelabel">
<x>168</x>
<y>173</y>
</hint>
<hint type="destinationlabel">
<x>268</x>
<y>146</y>
</hint>
</hints>
</connection>
<connection>
<sender>hsFrame</sender>
<signal>valueChanged(int)</signal>
<receiver>lbFrameNumber</receiver>
<slot>setNum(int)</slot>
<hints>
<hint type="sourcelabel">
<x>168</x>
<y>164</y>
</hint>
<hint type="destinationlabel">
<x>283</x>
<y>138</y>
</hint>
</hints>
</connection>
</connections>
</ui>
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