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