-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue #1 - added AnimationEditor and AnimationPlayer
AnimationEditor: - edit Marker ID in one or more frames - save Animation AnimationPlayer: - next/previous Frame - play/pause Animation - seek
- Loading branch information
Showing
21 changed files
with
452 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>AnimationEditor</class> | ||
<widget class="QMainWindow" name="AnimationEditor"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>528</width> | ||
<height>331</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>MainWindow</string> | ||
</property> | ||
<widget class="QWidget" name="centralwidget"> | ||
<widget class="QListWidget" name="pointList"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>240</x> | ||
<y>50</y> | ||
<width>256</width> | ||
<height>192</height> | ||
</rect> | ||
</property> | ||
</widget> | ||
<widget class="QLineEdit" name="idEdit"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>50</x> | ||
<y>70</y> | ||
<width>113</width> | ||
<height>27</height> | ||
</rect> | ||
</property> | ||
</widget> | ||
<widget class="QCheckBox" name="checkBox"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>60</x> | ||
<y>120</y> | ||
<width>121</width> | ||
<height>22</height> | ||
</rect> | ||
</property> | ||
<property name="text"> | ||
<string>All next frames</string> | ||
</property> | ||
</widget> | ||
</widget> | ||
<widget class="QMenuBar" name="menubar"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>528</width> | ||
<height>27</height> | ||
</rect> | ||
</property> | ||
</widget> | ||
<widget class="QStatusBar" name="statusbar"/> | ||
<widget class="QToolBar" name="toolBar"> | ||
<property name="windowTitle"> | ||
<string>toolBar</string> | ||
</property> | ||
<attribute name="toolBarArea"> | ||
<enum>TopToolBarArea</enum> | ||
</attribute> | ||
<attribute name="toolBarBreak"> | ||
<bool>false</bool> | ||
</attribute> | ||
<addaction name="actionSave_Animation"/> | ||
</widget> | ||
<action name="actionSave_Animation"> | ||
<property name="text"> | ||
<string>Save Animation</string> | ||
</property> | ||
<property name="toolTip"> | ||
<string>Save animation</string> | ||
</property> | ||
</action> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#include "animationeditor.h" | ||
#include "ui_animationeditor.h" | ||
|
||
#include <QFileDialog> | ||
|
||
#include "openglscene.h" | ||
|
||
AnimationEditor::AnimationEditor(QWidget *parent) : | ||
QMainWindow(parent), | ||
m_ui(new Ui::AnimationEditor) | ||
{ | ||
m_ui->setupUi(this); | ||
|
||
//setup animation player | ||
m_player = new AnimationPlayer(this); | ||
this->addDockWidget(Qt::DockWidgetArea::BottomDockWidgetArea, m_player, Qt::Orientation::Horizontal); | ||
connect(m_player, &AnimationPlayer::frameChanged, this, &AnimationEditor::setFrame); | ||
|
||
//actions | ||
connect(m_ui->actionSave_Animation, &QAction::triggered, this, &AnimationEditor::saveAnimation); | ||
|
||
//tools | ||
connect(m_ui->idEdit, &QLineEdit::textEdited, this, &AnimationEditor::editMarkerId); | ||
} | ||
|
||
AnimationEditor::~AnimationEditor() | ||
{ | ||
delete m_ui; | ||
} | ||
Animation *AnimationEditor::animation() const | ||
{ | ||
return m_animation; | ||
} | ||
|
||
void AnimationEditor::setAnimation(Animation *animation) | ||
{ | ||
m_animation = animation; | ||
|
||
if(m_animation->length() > 0) | ||
{ | ||
OpenGlScene::getInstance()->setFrame(m_animation->frames()[0]); | ||
m_player->setActualAnimation(m_animation); | ||
} | ||
} | ||
|
||
void AnimationEditor::setFrame(int i) | ||
{ | ||
if(i >= m_animation->frames().size()) return; | ||
|
||
const Frame &frame = m_animation->frames()[i]; | ||
|
||
m_currentFrameId = i; | ||
|
||
m_ui->pointList->clear(); | ||
|
||
for(const Marker &marker : frame.markers()) | ||
{ | ||
m_ui->pointList->addItem(QString::number(marker.id())); | ||
} | ||
} | ||
|
||
void AnimationEditor::saveAnimation() | ||
{ | ||
QString filename = QFileDialog::getSaveFileName(this,tr("Save Animation"),m_animation->name()+".fbx" , tr(".fbx Files (*.fbx)")); | ||
|
||
if(filename != "") | ||
{ | ||
m_animation->save(filename); | ||
} | ||
} | ||
|
||
void AnimationEditor::editMarkerId(const QString &newId) | ||
{ | ||
if(! m_ui->pointList->currentItem()) return; | ||
|
||
if(m_ui->checkBox->isChecked()) | ||
{ | ||
for(int i = m_currentFrameId; i < m_animation->frames().size(); ++i) | ||
{ | ||
Frame &frame = m_animation->frames()[i]; | ||
if(! frame.changeMarkerId(m_ui->pointList->currentItem()->text().toInt(), newId.toInt())) | ||
{ | ||
break; | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
Frame &frame = m_animation->frames()[m_currentFrameId]; | ||
frame.changeMarkerId(m_ui->pointList->currentItem()->text().toInt(), newId.toInt()); | ||
} | ||
|
||
OpenGlScene::getInstance()->setFrame(m_animation->frames()[m_currentFrameId]); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#ifndef ANIMATIONEDITOR_H | ||
#define ANIMATIONEDITOR_H | ||
|
||
#include <QMainWindow> | ||
|
||
#include "animationplayer.h" | ||
#include "animation.h" | ||
|
||
namespace Ui { | ||
class AnimationEditor; | ||
} | ||
|
||
class AnimationEditor : public QMainWindow | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit AnimationEditor(QWidget *parent = 0); | ||
~AnimationEditor(); | ||
|
||
Animation *animation() const; | ||
void setAnimation(Animation *animation); | ||
|
||
public slots: | ||
void setFrame(int i); | ||
|
||
void saveAnimation(); | ||
void editMarkerId(const QString &newId); | ||
|
||
private: | ||
Ui::AnimationEditor *m_ui; | ||
|
||
AnimationPlayer *m_player; | ||
|
||
int m_currentFrameId = -1; | ||
Animation *m_animation = nullptr; | ||
}; | ||
|
||
#endif // ANIMATIONEDITOR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,6 @@ DEPENDPATH += $$PWD/../WebCamCapPrimitives | |
|
||
FORMS += \ | ||
animationplayer.ui | ||
|
||
RESOURCES += \ | ||
webcamcapgui.qrc |
Oops, something went wrong.