Developer Documentation

SkeletalAnimationPlugin.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42
43
44 #include <OpenFlipper/BasePlugin/BaseInterface.hh>
45 #include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
46 #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
47 #include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
48 #include <OpenFlipper/BasePlugin/RPCInterface.hh>
49
50 #include "ObjectTypes/Skeleton/BlendingMethod.hh"
51
52 class AnimationToolboxWidget;
53 class AnimationHandle;
54
61 class SkeletalAnimationPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, LoadSaveInterface, RPCInterface
62 {
63 Q_OBJECT
64 Q_INTERFACES(BaseInterface)
65 Q_INTERFACES(ToolboxInterface)
66 Q_INTERFACES(LoggingInterface)
67 Q_INTERFACES(LoadSaveInterface)
68 Q_INTERFACES(RPCInterface)
69
70 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-SkeletalAnimation")
71
72 private:
73
74
75 signals:
76 void updateView();
77
78 void log(Logtype _type, QString _message);
79 void log(QString _message);
80 void addEmptyObject(DataType _type, int& _id);
81 void updatedObject(int _id, const UpdateType& _type);
82
83 void pluginExists(QString _pluginName, bool &_exists);
84 void functionExists(QString _pluginName, QString _functionName, bool &_exists);
85
86 // ToolboxInterface
87 void addToolbox( QString _name , QWidget* _widget, QIcon* _icon );
88
89 public slots:
90 // BaseInterface
91 void slotAllCleared();
92 void slotObjectUpdated( int _id, const UpdateType& _type);
93 void slotObjectSelectionChanged(int _id);
94 // LoadSaveInterface
95 void fileOpened(int _id);
96 void addedEmptyObject(int _id);
97 void objectDeleted(int _id);
98
99 public slots:
105 int getNumberOfFrames();
106 bool attachSkin(int skeletonId, int skinId);
107 bool detachSkin(int skeletonId, int skinId);
108 bool clearSkins(int skeletonId);
109
110 void setFrame(int _iFrame);
111 int getFrame();
112 void changeFPS(int _fps);
113
114 void playAnimation();
115 void pauseAnimation();
116 void stopAnimation();
117 void nextFrame();
118 void prevFrame();
119
120 void updateSkins();
122
123 void UpdateUI();
124 void setComboBoxPosition(unsigned int _animationIndex);
125 void checkObjectSelection(const int _objectId);
126
127 void slotAnimationNameChanged();
128
129 private slots:
130 void setDescriptions();
131
132 void initializePlugin();
133 void pluginsInitialized();
134
135 void exit();
136
137 void slotAttachSkin();
138 void slotClearSkins();
139 void slotMethodChanged(int _index);
140 void slotAnimationIndexChanged(int /*_index*/);
141 void slotFrameChanged(int /*_index*/);
142 void slotSkipFramesChanged(int _state);
143 void slotAddAnimation();
144 void slotDeleteAnimation();
145
146 void animate();
147
148 public:
149 SkeletalAnimationPlugin();
150 QString name();
151 QString description();
152
153 protected:
154
155 AnimationHandle currentAnimationHandle();
156
157 void UpdateSkins(BaseObjectData *_pSkeletonObject, AnimationHandle &_hAni);
158
159 private:
164 void attachSkin(BaseObjectData *pSkin, BaseObjectData *pSkeleton);
165 void detachSkin(BaseObjectData *pSkin, BaseObjectData *pSkeleton);
166 void clearSkins(BaseObjectData *_pSkeleton);
168
169 protected:
170 AnimationToolboxWidget *pToolbox_;
171 QIcon* toolIcon_;
172
173 private:
174 Blending::Method method_;
175
176 bool bGuiUpdating_;
177 QTimer animationTimer_;
178 QTime animationTime_;
179 int animationOffset_;
180
181 std::vector< int > activeSkeletons_;
182 };
ToolboxInterface.hh
SkeletalAnimationPlugin::slotFrameChanged
void slotFrameChanged(int)
Called by the framework when a different frame was selected.
Definition: SkeletalAnimationPlugin.cc:497
SkeletalAnimationPlugin::slotMethodChanged
void slotMethodChanged(int _index)
Called as the skin deformation method changed.
Definition: SkeletalAnimationPlugin.cc:639
SkeletalAnimationPlugin::changeFPS
void changeFPS(int _fps)
Change the frames per second (FPS)
Definition: SkeletalAnimationPlugin.cc:357
SkeletalAnimationPlugin::addedEmptyObject
void addedEmptyObject(int _id)
Update ui when the object is added.
Definition: SkeletalAnimationPlugin.cc:190
LoadSaveInterface.hh
SkeletalAnimationPlugin::setComboBoxPosition
void setComboBoxPosition(unsigned int _animationIndex)
Sets the animations combo box to the right entry.
Definition: SkeletalAnimationPlugin.cc:1057
ToolboxInterface
Plugins can add its own toolbox to the main widget&#39;s toolbox area by using this interface.
Definition: ToolboxInterface.hh:68
SkeletalAnimationPlugin::objectDeleted
void objectDeleted(int _id)
Update ui when the object is deleted.
Definition: SkeletalAnimationPlugin.cc:200
SkeletalAnimationPlugin::pToolbox_
AnimationToolboxWidget * pToolbox_
A pointer to the toolbox widget.
Definition: SkeletalAnimationPlugin.hh:170
SkeletalAnimationPlugin::pauseAnimation
void pauseAnimation()
Called by the ui and stops the current animation.
Definition: SkeletalAnimationPlugin.cc:547
SkeletalAnimationPlugin::slotSkipFramesChanged
void slotSkipFramesChanged(int _state)
Called as the skip frames check box changes state.
Definition: SkeletalAnimationPlugin.cc:620
Logtype
Logtype
Log types for Message Window.
Definition: LoggingInterface.hh:92
SkeletalAnimationPlugin::getNumberOfFrames
int getNumberOfFrames()
Returns the number of frames in the currently active animation.
Definition: SkeletalAnimationPlugin.cc:311
SkeletalAnimationPlugin::animationTime_
QTime animationTime_
Time since the animation was started, used to meet the given fps.
Definition: SkeletalAnimationPlugin.hh:178
SkeletalAnimationPlugin::animationOffset_
int animationOffset_
This frame was selected as the animation was started.
Definition: SkeletalAnimationPlugin.hh:179
SkeletalAnimationPlugin::description
QString description()
returns a plugin description
Definition: SkeletalAnimationPlugin.cc:86
DataType
Predefined datatypes.
Definition: DataTypes.hh:83
LoggingInterface
Interface for all Plugins which do logging to the logging window of the framework.
Definition: LoggingInterface.hh:112
SkeletalAnimationPlugin::exit
void exit()
Plugin gets closed.
Definition: SkeletalAnimationPlugin.cc:150
AnimationToolboxWidget
Definition: AnimationToolbox.hh:47
LoggingInterface.hh
SkeletalAnimationPlugin::slotObjectUpdated
void slotObjectUpdated(int _id, const UpdateType &_type)
Check activePose if a skeleton was updated.
Definition: SkeletalAnimationPlugin.cc:409
SkeletalAnimationPlugin::UpdateUI
void UpdateUI()
Called when the active object changes and the interface needs to be updated.
Definition: SkeletalAnimationPlugin.cc:690
SkeletalAnimationPlugin::animate
void animate()
Iterates the animation.
Definition: SkeletalAnimationPlugin.cc:592
SkeletalAnimationPlugin::currentAnimationHandle
AnimationHandle currentAnimationHandle()
Returns a handle describing the current frame in the active animation.
Definition: SkeletalAnimationPlugin.cc:1039
SkeletalAnimationPlugin::playAnimation
void playAnimation()
Called by the ui and starts an automatic animation.
Definition: SkeletalAnimationPlugin.cc:528
SkeletalAnimationPlugin::slotObjectSelectionChanged
void slotObjectSelectionChanged(int _id)
Update ui when the object selection changes.
Definition: SkeletalAnimationPlugin.cc:171
SkeletalAnimationPlugin::fileOpened
void fileOpened(int _id)
Update ui when the object is loaded.
Definition: SkeletalAnimationPlugin.cc:181
SkeletalAnimationPlugin::SkeletalAnimationPlugin
SkeletalAnimationPlugin()
Constructor.
Definition: SkeletalAnimationPlugin.cc:63
SkeletalAnimationPlugin::checkObjectSelection
void checkObjectSelection(const int _objectId)
Check source/target selection of objects.
Definition: SkeletalAnimationPlugin.cc:235
RPCInterface
Interface to call functions across plugins.
Definition: RPCInterface.hh:61
SkeletalAnimationPlugin::initializePlugin
void initializePlugin()
initialize the plugin
Definition: SkeletalAnimationPlugin.cc:96
SkeletalAnimationPlugin::method_
Blending::Method method_
The current blending method for the skin.
Definition: SkeletalAnimationPlugin.hh:174
SkeletalAnimationPlugin::clearSkins
bool clearSkins(int skeletonId)
Returns the number of frames in the currently active animation.
Definition: SkeletalAnimationScripting.cc:100
SkeletalAnimationPlugin::bGuiUpdating_
bool bGuiUpdating_
Used to drop a few messages while the gui is being updated.
Definition: SkeletalAnimationPlugin.hh:176
BaseObjectData
Definition: BaseObjectData.hh:102
UpdateType
Update type class.
Definition: UpdateType.hh:60
SkeletalAnimationPlugin::name
QString name()
returns the plugin name
Definition: SkeletalAnimationPlugin.cc:76
SkeletalAnimationPlugin::setFrame
void setFrame(int _iFrame)
Displays the given frame from the current animation and updates the view.
Definition: SkeletalAnimationPlugin.cc:338
SkeletalAnimationPlugin::slotAttachSkin
void slotAttachSkin()
Called by Qt as the user is trying to connect a mesh to a skeleton.
Definition: SkeletalAnimationPlugin.cc:771
SkeletalAnimationPlugin::pluginsInitialized
void pluginsInitialized()
final initializations
Definition: SkeletalAnimationPlugin.cc:140
SkeletalAnimationPlugin::prevFrame
void prevFrame()
Called by the ui and goes to previous frame of the current animation.
Definition: SkeletalAnimationPlugin.cc:569
SkeletalAnimationPlugin::UpdateSkins
void UpdateSkins(BaseObjectData *_pSkeletonObject, AnimationHandle &_hAni)
Changes the mesh&#39;s pose to represent the frame given by the animation handle.
Definition: SkeletalAnimationPlugin.cc:373
SkeletalAnimationPlugin::detachSkin
bool detachSkin(int skeletonId, int skinId)
Returns the number of frames in the currently active animation.
Definition: SkeletalAnimationScripting.cc:81
SkeletalAnimationPlugin::stopAnimation
void stopAnimation()
Called by the ui and stops the current animation.
Definition: SkeletalAnimationPlugin.cc:559
SkeletalAnimationPlugin::slotAnimationIndexChanged
void slotAnimationIndexChanged(int)
Called by the framework when the animation index changed.
Definition: SkeletalAnimationPlugin.cc:445
SkeletalAnimationPlugin::attachSkin
bool attachSkin(int skeletonId, int skinId)
Returns the number of frames in the currently active animation.
Definition: SkeletalAnimationScripting.cc:63
SkeletalAnimationPlugin::getFrame
int getFrame()
Gets the current frame number.
Definition: SkeletalAnimationPlugin.cc:348
RPCInterface.hh
SkeletalAnimationPlugin::slotClearSkins
void slotClearSkins()
Called by Qt as the user is trying to unbind a mesh from as a skeleton.
Definition: SkeletalAnimationPlugin.cc:868
SkeletalAnimationPlugin::nextFrame
void nextFrame()
Called by the ui and goes to next frame of the current animation.
Definition: SkeletalAnimationPlugin.cc:579
SkeletalAnimationPlugin
The skeletal animation plugin is used to interact with the skeleton.
Definition: SkeletalAnimationPlugin.hh:61
SkeletalAnimationPlugin::slotAllCleared
void slotAllCleared()
clear all occurred
Definition: SkeletalAnimationPlugin.cc:159
BaseInterface
Interface class from which all plugins have to be created.
Definition: BaseInterface.hh:65
BaseInterface.hh
AnimationHandle
A handle used to refer to an animation or to a specific frame in an animation.
Definition: AnimationHandle.hh:47
SkeletalAnimationPlugin::updateSkins
void updateSkins()
Returns the number of frames in the currently active animation.
Definition: SkeletalAnimationScripting.cc:112
SkeletalAnimationPlugin::animationTimer_
QTimer animationTimer_
Timer used to control animations.
Definition: SkeletalAnimationPlugin.hh:177
LoadSaveInterface
Interface for all plugins which want to Load or Save files and create Objects.
Definition: LoadSaveInterface.hh:59