Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 };
Method
Possible deformation methods.
Definition: BaseSkin.hh:109
void stopAnimation()
Called by the ui and stops the current animation.
Interface class from which all plugins have to be created.
BaseSkin::Method method_
The current blending method for the skin.
void pauseAnimation()
Called by the ui and stops the current animation.
void updateSkins()
Returns the number of frames in the currently active animation.
QString description()
returns a plugin description
void initializePlugin()
initialize the plugin
QString name()
returns the plugin name
Logtype
Log types for Message Window.
void objectDeleted(int _id)
Update ui when the object is deleted.
void pluginsInitialized()
final initializations
void slotFrameChanged(int)
Called by the framework when a different frame was selected.
void slotMethodChanged(int _index)
Called as the skin deformation method changed.
bool attachSkin(int skeletonId, int skinId)
Returns the number of frames in the currently active animation.
Update type class.
Definition: UpdateType.hh:70
void slotObjectUpdated(int _id, const UpdateType &_type)
Check activePose if a skeleton was updated.
void exit()
Plugin gets closed.
void UpdateSkins(BaseObjectData *_pSkeletonObject, AnimationHandle &_hAni)
Changes the mesh's pose to represent the frame given by the animation handle.
void fileOpened(int _id)
Update ui when the object is loaded.
A general pose, used to store the frames of the animation.
Definition: PoseT.hh:68
Interface for all Plugins which do logging to the logging window of the framework.
void slotObjectSelectionChanged(int _id)
Update ui when the object selection changes.
void nextFrame()
Called by the ui and goes to next frame of the current animation.
void checkObjectSelection(const int _objectId)
Check source/target selection of objects.
Interface to call functions across plugins.
Definition: RPCInterface.hh:71
int animationOffset_
This frame was selected as the animation was started.
void slotAllCleared()
clear all occurred
void addedEmptyObject(int _id)
Update ui when the object is added.
PoseT< Skeleton::Point > Pose
Pose typedef.
void prevFrame()
Called by the ui and goes to previous frame of the current animation.
void slotSkipFramesChanged(int _state)
Called as the skip frames check box changes state.
void setComboBoxPosition(unsigned int _animationIndex)
Sets the animations combo box to the right entry.
QTime animationTime_
Time since the animation was started, used to meet the given fps.
Interface for all plugins which want to Load or Save files and create Objects.
int getFrame()
Gets the current frame number.
The skeletal animation plugin is used to interact with the skeleton.
bool detachSkin(int skeletonId, int skinId)
Returns the number of frames in the currently active animation.
void slotAnimationIndexChanged(int)
Called by the framework when the animation index changed.
void setFrame(int _iFrame)
Displays the given frame from the current animation and updates the view.
A handle used to refer to an animation or to a specific frame in an animation.
AnimationHandle currentAnimationHandle()
Returns a handle describing the current frame in the active animation.
void changeFPS(int _fps)
Change the frames per second (FPS)
void UpdateUI()
Called when the active object changes and the interface needs to be updated.
Plugins can add its own toolbox to the main widget's toolbox area by using this interface.
Predefined datatypes.
Definition: DataTypes.hh:96
bool bGuiUpdating_
Used to drop a few messages while the gui is being updated.
void slotAttachSkin()
Called by Qt as the user is trying to connect a mesh to a skeleton.
void slotClearSkins()
Called by Qt as the user is trying to unbind a mesh from as a skeleton.
bool clearSkins(int skeletonId)
Returns the number of frames in the currently active animation.
int getNumberOfFrames()
Returns the number of frames in the currently active animation.
void animate()
Iterates the animation.
QTimer animationTimer_
Timer used to control animations.
void playAnimation()
Called by the ui and starts an automatic animation.
AnimationToolboxWidget * pToolbox_
A pointer to the toolbox widget.