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
49
50#include "ObjectTypes/Skeleton/BlendingMethod.hh"
51
52#include <QTimer>
53#include <QElapsedTimer>
54
56class AnimationHandle;
57
65{
66 Q_OBJECT
67 Q_INTERFACES(BaseInterface)
68 Q_INTERFACES(ToolboxInterface)
69 Q_INTERFACES(LoggingInterface)
70 Q_INTERFACES(LoadSaveInterface)
71 Q_INTERFACES(RPCInterface)
72
73 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-SkeletalAnimation")
74
75private:
76
77
78signals:
79 void updateView();
80
81 void log(Logtype _type, QString _message);
82 void log(QString _message);
83 void addEmptyObject(DataType _type, int& _id);
84 void updatedObject(int _id, const UpdateType& _type);
85
86 void pluginExists(QString _pluginName, bool &_exists);
87 void functionExists(QString _pluginName, QString _functionName, bool &_exists);
88
89 // ToolboxInterface
90 void addToolbox( QString _name , QWidget* _widget, QIcon* _icon );
91
92public slots:
93 // BaseInterface
94 void slotAllCleared();
95 void slotObjectUpdated( int _id, const UpdateType& _type);
96 void slotObjectSelectionChanged(int _id);
97 // LoadSaveInterface
98 void fileOpened(int _id);
99 void addedEmptyObject(int _id);
100 void objectDeleted(int _id);
101
102public slots:
108 int getNumberOfFrames();
109 bool attachSkin(int skeletonId, int skinId);
110 bool detachSkin(int skeletonId, int skinId);
111 bool clearSkins(int skeletonId);
112
113 void setFrame(int _iFrame);
114 int getFrame();
115 void changeFPS(int _fps);
116
117 void playAnimation();
118 void pauseAnimation();
119 void stopAnimation();
120 void nextFrame();
121 void prevFrame();
122
123 void updateSkins();
125
126 void UpdateUI();
127 void setComboBoxPosition(unsigned int _animationIndex);
128 void checkObjectSelection(const int _objectId);
129
131
132private slots:
133 void setDescriptions();
134
135 void initializePlugin();
136 void pluginsInitialized();
137
138 void exit();
139
140 void slotAttachSkin();
141 void slotClearSkins();
142 void slotMethodChanged(int _index);
143 void slotAnimationIndexChanged(int /*_index*/);
144 void slotFrameChanged(int /*_index*/);
145 void slotSkipFramesChanged(int _state);
146 void slotAddAnimation();
147 void slotDeleteAnimation();
148
149 void animate();
150
151public:
154 QString name();
155 QString description();
156
157protected:
158
160
161 void UpdateSkins(BaseObjectData *_pSkeletonObject, AnimationHandle &_hAni);
162
163private:
168 void attachSkin(BaseObjectData *pSkin, BaseObjectData *pSkeleton);
169 void detachSkin(BaseObjectData *pSkin, BaseObjectData *pSkeleton);
170 void clearSkins(BaseObjectData *_pSkeleton);
172
173protected:
175 QIcon* toolIcon_;
176
177private:
178 Blending::Method method_;
179
182 QElapsedTimer animationTime_;
184
185 std::vector< int > activeSkeletons_;
186};
Logtype
Log types for Message Window.
A handle used to refer to an animation or to a specific frame in an animation.
Interface class from which all plugins have to be created.
Predefined datatypes.
Definition: DataTypes.hh:83
Interface for all plugins which want to Load or Save files and create Objects.
Interface for all Plugins which do logging to the logging window of the framework.
Interface to call functions across plugins.
Definition: RPCInterface.hh:61
The skeletal animation plugin is used to interact with the skeleton.
void exit()
Plugin gets closed.
bool bGuiUpdating_
Used to drop a few messages while the gui is being updated.
void slotAddAnimation()
Returns the number of frames in the currently active animation.
void playAnimation()
Called by the ui and starts an automatic animation.
int getFrame()
Gets the current frame number.
int animationOffset_
This frame was selected as the animation was started.
std::vector< int > activeSkeletons_
A pointer to the toolbox widget.
void slotObjectUpdated(int _id, const UpdateType &_type)
Check activePose if a skeleton was updated.
QString name()
returns the plugin name
void stopAnimation()
Called by the ui and stops the current animation.
void setFrame(int _iFrame)
Displays the given frame from the current animation and updates the view.
void pauseAnimation()
Called by the ui and stops the current animation.
void addedEmptyObject(int _id)
Update ui when the object is added.
QElapsedTimer animationTime_
Time since the animation was started, used to meet the given fps.
void slotAttachSkin()
Called by Qt as the user is trying to connect a mesh to a skeleton.
void slotSkipFramesChanged(int _state)
Called as the skip frames check box changes state.
void initializePlugin()
initialize the plugin
bool clearSkins(int skeletonId)
Returns the number of frames in the currently active animation.
void UpdateUI()
Called when the active object changes and the interface needs to be updated.
void pluginsInitialized()
final initializations
void slotAnimationNameChanged()
Returns the number of frames in the currently active animation.
void setDescriptions()
Returns the number of frames in the currently active animation.
void slotMethodChanged(int _index)
Called as the skin deformation method changed.
void slotDeleteAnimation()
Returns the number of frames in the currently active animation.
void slotAllCleared()
clear all occurred
void slotObjectSelectionChanged(int _id)
Update ui when the object selection changes.
void UpdateSkins(BaseObjectData *_pSkeletonObject, AnimationHandle &_hAni)
Changes the mesh's pose to represent the frame given by the animation handle.
void setComboBoxPosition(unsigned int _animationIndex)
Sets the animations combo box to the right entry.
void checkObjectSelection(const int _objectId)
Check source/target selection of objects.
void slotClearSkins()
Called by Qt as the user is trying to unbind a mesh from as a skeleton.
void prevFrame()
Called by the ui and goes to previous frame of the current animation.
~SkeletalAnimationPlugin()
Returns the number of frames in the currently active animation.
Blending::Method method_
The current blending method for the skin.
void changeFPS(int _fps)
Change the frames per second (FPS)
void fileOpened(int _id)
Update ui when the object is loaded.
void animate()
Iterates the animation.
AnimationHandle currentAnimationHandle()
Returns a handle describing the current frame in the active animation.
void objectDeleted(int _id)
Update ui when the object is deleted.
bool detachSkin(int skeletonId, int skinId)
Returns the number of frames in the currently active animation.
bool attachSkin(int skeletonId, int skinId)
Returns the number of frames in the currently active animation.
QTimer animationTimer_
Timer used to control animations.
QString description()
returns a plugin description
AnimationToolboxWidget * pToolbox_
A pointer to the toolbox widget.
void nextFrame()
Called by the ui and goes to next frame of the current animation.
void updateSkins()
Returns the number of frames in the currently active animation.
void slotAnimationIndexChanged(int)
Called by the framework when the animation index changed.
void slotFrameChanged(int)
Called by the framework when a different frame was selected.
QIcon * toolIcon_
A pointer to the toolbox widget.
int getNumberOfFrames()
Returns the number of frames in the currently active animation.
Plugins can add its own toolbox to the main widget's toolbox area by using this interface.
Update type class.
Definition: UpdateType.hh:59