2018-10-25 00:19:38 +00:00
|
|
|
#ifndef DUST3D_MOTIONS_GENERATOR_H
|
|
|
|
#define DUST3D_MOTIONS_GENERATOR_H
|
2018-10-23 14:57:47 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
2020-04-07 23:15:20 +00:00
|
|
|
#include "model.h"
|
2018-10-26 23:04:45 +00:00
|
|
|
#include "rigger.h"
|
2018-10-23 14:57:47 +00:00
|
|
|
#include "jointnodetree.h"
|
2018-10-25 00:19:38 +00:00
|
|
|
#include "document.h"
|
2018-11-01 15:24:06 +00:00
|
|
|
#include "poser.h"
|
2018-10-23 14:57:47 +00:00
|
|
|
|
2020-02-19 11:05:16 +00:00
|
|
|
#define ENABLE_PROCEDURAL_DEBUG 1
|
|
|
|
|
2018-10-23 14:57:47 +00:00
|
|
|
class MotionsGenerator : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-11-01 15:24:06 +00:00
|
|
|
MotionsGenerator(RigType rigType,
|
|
|
|
const std::vector<RiggerBone> *rigBones,
|
2018-10-26 23:04:45 +00:00
|
|
|
const std::map<int, RiggerVertexWeights> *rigWeights,
|
2018-10-25 00:19:38 +00:00
|
|
|
const Outcome &outcome);
|
2018-10-23 14:57:47 +00:00
|
|
|
~MotionsGenerator();
|
2019-06-19 12:57:38 +00:00
|
|
|
void addPoseToLibrary(const QUuid &poseId, const std::vector<std::pair<std::map<QString, QString>, std::map<QString, std::map<QString, QString>>>> &frames, float yTranslationScale);
|
2018-10-25 00:19:38 +00:00
|
|
|
void addMotionToLibrary(const QUuid &motionId, const std::vector<MotionClip> &clips);
|
2018-10-23 14:57:47 +00:00
|
|
|
void addRequirement(const QUuid &motionId);
|
2020-04-07 23:15:20 +00:00
|
|
|
std::vector<std::pair<float, Model *>> takeResultPreviewMeshs(const QUuid &motionId);
|
2018-10-23 14:57:47 +00:00
|
|
|
std::vector<std::pair<float, JointNodeTree>> takeResultJointNodeTrees(const QUuid &motionId);
|
|
|
|
const std::set<QUuid> &requiredMotionIds();
|
|
|
|
const std::set<QUuid> &generatedMotionIds();
|
|
|
|
void generate();
|
|
|
|
signals:
|
|
|
|
void finished();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void process();
|
|
|
|
|
|
|
|
private:
|
2019-09-21 14:30:27 +00:00
|
|
|
void generateMotion(const QUuid &motionId, std::set<QUuid> &visited, std::vector<std::pair<float, JointNodeTree>> &outcomes,
|
2020-04-07 23:15:20 +00:00
|
|
|
std::vector<Model *> *previews=nullptr);
|
2018-11-09 03:20:48 +00:00
|
|
|
const JointNodeTree &poseJointNodeTree(const QUuid &poseId, int frame);
|
2018-10-23 14:57:47 +00:00
|
|
|
JointNodeTree generateInterpolation(InterpolationType interpolationType, const JointNodeTree &first, const JointNodeTree &second, float progress);
|
2018-10-25 00:19:38 +00:00
|
|
|
const JointNodeTree *findClipBeginJointNodeTree(const MotionClip &clip);
|
|
|
|
const JointNodeTree *findClipEndJointNodeTree(const MotionClip &clip);
|
|
|
|
std::vector<MotionClip> *findMotionClips(const QUuid &motionId);
|
2018-11-09 03:20:48 +00:00
|
|
|
std::vector<std::pair<std::map<QString, QString>, std::map<QString, std::map<QString, QString>>>> *findPoseFrames(const QUuid &poseId);
|
2020-04-07 23:15:20 +00:00
|
|
|
void generatePreviewsForOutcomes(const std::vector<std::pair<float, JointNodeTree>> &outcomes, std::vector<std::pair<float, Model *>> &previews);
|
2018-10-23 14:57:47 +00:00
|
|
|
float calculateMotionDuration(const QUuid &motionId, std::set<QUuid> &visited);
|
2018-11-09 03:20:48 +00:00
|
|
|
float calculatePoseDuration(const QUuid &poseId);
|
2019-11-09 08:15:49 +00:00
|
|
|
float calculateProceduralAnimationDuration(ProceduralAnimation proceduralAnimation,
|
|
|
|
const JointNodeTree *initialJointNodeTree=nullptr);
|
|
|
|
const std::vector<std::pair<float, JointNodeTree>> &getProceduralAnimation(ProceduralAnimation proceduralAnimation,
|
|
|
|
const JointNodeTree *initialJointNodeTree=nullptr);
|
2018-10-23 14:57:47 +00:00
|
|
|
|
2018-11-01 15:24:06 +00:00
|
|
|
RigType m_rigType = RigType::None;
|
2018-10-26 23:04:45 +00:00
|
|
|
std::vector<RiggerBone> m_rigBones;
|
|
|
|
std::map<int, RiggerVertexWeights> m_rigWeights;
|
2019-09-21 14:30:27 +00:00
|
|
|
std::map<int, std::vector<std::pair<float, JointNodeTree>>> m_proceduralAnimations;
|
2020-02-19 11:05:16 +00:00
|
|
|
#if ENABLE_PROCEDURAL_DEBUG
|
2020-04-07 23:15:20 +00:00
|
|
|
std::map<int, std::vector<Model *>> m_proceduralDebugPreviews;
|
2020-02-19 11:05:16 +00:00
|
|
|
#endif
|
2018-10-25 00:19:38 +00:00
|
|
|
Outcome m_outcome;
|
2018-11-09 03:20:48 +00:00
|
|
|
std::map<QUuid, std::vector<std::pair<std::map<QString, QString>, std::map<QString, std::map<QString, QString>>>>> m_poses;
|
2019-06-19 12:57:38 +00:00
|
|
|
std::map<QUuid, float> m_posesYtranslationScales;
|
2018-10-25 00:19:38 +00:00
|
|
|
std::map<QUuid, std::vector<MotionClip>> m_motions;
|
2018-10-23 14:57:47 +00:00
|
|
|
std::set<QUuid> m_requiredMotionIds;
|
|
|
|
std::set<QUuid> m_generatedMotionIds;
|
2020-04-07 23:15:20 +00:00
|
|
|
std::map<QUuid, std::vector<std::pair<float, Model *>>> m_resultPreviewMeshs;
|
2018-10-23 14:57:47 +00:00
|
|
|
std::map<QUuid, std::vector<std::pair<float, JointNodeTree>>> m_resultJointNodeTrees;
|
2018-11-09 03:20:48 +00:00
|
|
|
std::map<std::pair<QUuid, int>, JointNodeTree> m_poseJointNodeTreeMap;
|
2018-11-01 15:24:06 +00:00
|
|
|
Poser *m_poser = nullptr;
|
2018-10-23 14:57:47 +00:00
|
|
|
int m_fps = 30;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|