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 
53 class AnimationHandle;
54 
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:
150  QString name();
151  QString description();
152 
153 protected:
154 
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:
171  QIcon* toolIcon_;
172 
173 private:
174  Blending::Method method_;
175 
178  QElapsedTimer animationTime_;
180 
181  std::vector< int > activeSkeletons_;
182 };
void slotFrameChanged(int)
Called by the framework when a different frame was selected.
void slotMethodChanged(int _index)
Called as the skin deformation method changed.
void changeFPS(int _fps)
Change the frames per second (FPS)
void addedEmptyObject(int _id)
Update ui when the object is added.
void setComboBoxPosition(unsigned int _animationIndex)
Sets the animations combo box to the right entry.
Plugins can add its own toolbox to the main widget&#39;s toolbox area by using this interface.
void objectDeleted(int _id)
Update ui when the object is deleted.
AnimationToolboxWidget * pToolbox_
A pointer to the toolbox widget.
void pauseAnimation()
Called by the ui and stops the current animation.
void slotSkipFramesChanged(int _state)
Called as the skip frames check box changes state.
Logtype
Log types for Message Window.
int getNumberOfFrames()
Returns the number of frames in the currently active animation.
int animationOffset_
This frame was selected as the animation was started.
QString description()
returns a plugin description
Predefined datatypes.
Definition: DataTypes.hh:83
Interface for all Plugins which do logging to the logging window of the framework.
void exit()
Plugin gets closed.
void slotObjectUpdated(int _id, const UpdateType &_type)
Check activePose if a skeleton was updated.
void UpdateUI()
Called when the active object changes and the interface needs to be updated.
void animate()
Iterates the animation.
AnimationHandle currentAnimationHandle()
Returns a handle describing the current frame in the active animation.
void playAnimation()
Called by the ui and starts an automatic animation.
void slotObjectSelectionChanged(int _id)
Update ui when the object selection changes.
void fileOpened(int _id)
Update ui when the object is loaded.
void checkObjectSelection(const int _objectId)
Check source/target selection of objects.
Interface to call functions across plugins.
Definition: RPCInterface.hh:61
void initializePlugin()
initialize the plugin
Blending::Method method_
The current blending method for the skin.
bool clearSkins(int skeletonId)
Returns the number of frames in the currently active animation.
bool bGuiUpdating_
Used to drop a few messages while the gui is being updated.
Update type class.
Definition: UpdateType.hh:59
QString name()
returns the plugin name
void setFrame(int _iFrame)
Displays the given frame from the current animation and updates the view.
void slotAttachSkin()
Called by Qt as the user is trying to connect a mesh to a skeleton.
void pluginsInitialized()
final initializations
QElapsedTimer animationTime_
Time since the animation was started, used to meet the given fps.
void prevFrame()
Called by the ui and goes to previous frame of the current animation.
void UpdateSkins(BaseObjectData *_pSkeletonObject, AnimationHandle &_hAni)
Changes the mesh&#39;s pose to represent the frame given by the animation handle.
bool detachSkin(int skeletonId, int skinId)
Returns the number of frames in the currently active animation.
void stopAnimation()
Called by the ui and stops the current animation.
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.
int getFrame()
Gets the current frame number.
void slotClearSkins()
Called by Qt as the user is trying to unbind a mesh from as a skeleton.
void nextFrame()
Called by the ui and goes to next frame of the current animation.
The skeletal animation plugin is used to interact with the skeleton.
void slotAllCleared()
clear all occurred
Interface class from which all plugins have to be created.
A handle used to refer to an animation or to a specific frame in an animation.
void updateSkins()
Returns the number of frames in the currently active animation.
QTimer animationTimer_
Timer used to control animations.
Interface for all plugins which want to Load or Save files and create Objects.