PeriDyno 1.0.0
Loading...
Searching...
No Matches
JointTree.h
Go to the documentation of this file.
1#pragma once
3
4#include "AnimationCurve.h"
5#include <iterator>
6#include <random>
7
8#include "Quat.h"
9namespace dyno
10{
11
12 struct JCapsule
13 {
14 typedef typename DataType3f::Coord Coord;
16 int id_cap;
18
19 DYN_FUNC JCapsule(){};
20 DYN_FUNC JCapsule(int id1, int id2, Coord a0, Coord a1):
21 id_joint(id1), id_cap(id2), v0(a0), v1(a1){};
22 DYN_FUNC ~JCapsule(){};
23 };
24
29 template<typename TDataType>
31 {
32 DECLARE_TCLASS(JointTree, TDataType)
33 private:
34 std::default_random_engine generator;
35 std::normal_distribution<double> dist;
36
37
38 public:
39 typedef typename TDataType::Real Real;
40 typedef typename TDataType::Coord Coord;
41 typedef typename TDataType::Matrix Matrix;
42 typedef typename ::dyno::Mat4f Mat;
43
44 JointTree();
45 ~JointTree();
46
47 void copyFrom(JointTree<TDataType> jointTree);
48
49 void scale(Real s);
50 void translate(Coord t);
51 void getGlobalTransform();
52 Mat getTransform(Coord & T, Coord& R, Coord& S);
53 void getQuat(Coord &T, Coord &R, float &S);
54 void getGlobalQuat();
57
58 void getGlobalCoord();
59
63 }
64 void setAnimRotation(std::shared_ptr<AnimationCurve<TDataType>> r) {
65 AnimRotation = r;
66 AnimTranslation->setInitVal(LclRotation);
67 }
68 void setAnimScaling(std::shared_ptr<AnimationCurve<TDataType>> s) {
69 AnimScaling = s;
70 AnimScaling->setInitVal(LclScaling);
71 }
72
73 // 更新动画
74 void applyAnimationByOne(Coord& init, Coord& cur, std::shared_ptr<AnimationCurve<TDataType>>& anim, Real ptime);
75 void applyAnimationAll(Real ptime);
76
77 unsigned long long id;
78 // 用于对整个模型进行调整
82
84
85 Coord LclTranslation; // Local Joint's coord
88
89 std::shared_ptr<AnimationCurve<TDataType>> AnimTranslation; // Local Animation
90 std::shared_ptr<AnimationCurve<TDataType>> AnimRotation;
91 std::shared_ptr<AnimationCurve<TDataType>> AnimScaling;
92
93 Coord CurTranslation; // Current Joint's Transform (Animation)
96
97 Coord GlCoord; // Global Joint's coord
101
105 std::vector<std::shared_ptr<JointTree>> children;
106 std::shared_ptr<JointTree> parent;
107 };
108}
#define DECLARE_TCLASS(name, T1)
Definition Object.h:87
Implementation of quaternion.
double Real
Definition Typedef.inl:23
Coord PreRotation
Definition JointTree.h:79
std::default_random_engine generator
Definition JointTree.h:34
TDataType::Coord Coord
Definition JointTree.h:40
unsigned long long id
Definition JointTree.h:77
Mat getTransform(Coord &T, Coord &R, Coord &S)
Definition JointTree.cpp:40
void applyAnimationAll(Real ptime)
void scale(Real s)
std::shared_ptr< AnimationCurve< TDataType > > AnimTranslation
Definition JointTree.h:89
void applyAnimationByOne(Coord &init, Coord &cur, std::shared_ptr< AnimationCurve< TDataType > > &anim, Real ptime)
void setAnimRotation(std::shared_ptr< AnimationCurve< TDataType > > r)
Definition JointTree.h:64
std::shared_ptr< AnimationCurve< TDataType > > AnimScaling
Definition JointTree.h:91
Coord getCoordByMatrix(Coord X)
void setAnimTranslation(std::shared_ptr< AnimationCurve< TDataType > > t)
Definition JointTree.h:60
void getQuat(Coord &T, Coord &R, float &S)
TDataType::Real Real
Definition JointTree.h:39
void getGlobalCoord()
Coord PreTranslation
Definition JointTree.h:81
::dyno::Mat4f Mat
Definition JointTree.h:42
std::vector< std::shared_ptr< JointTree > > children
Definition JointTree.h:105
Quat< Real > GlR
Definition JointTree.h:103
Coord getCoordByQuat(Coord X)
void getGlobalTransform()
Definition JointTree.cpp:82
std::normal_distribution< double > dist
Definition JointTree.h:35
Coord CurRotation
Definition JointTree.h:94
Quat< Real > GlT
Definition JointTree.h:102
void translate(Coord t)
std::shared_ptr< AnimationCurve< TDataType > > AnimRotation
Definition JointTree.h:90
TDataType::Matrix Matrix
Definition JointTree.h:41
Coord LclTranslation
Definition JointTree.h:85
void setAnimScaling(std::shared_ptr< AnimationCurve< TDataType > > s)
Definition JointTree.h:68
Coord CurTranslation
Definition JointTree.h:93
void copyFrom(JointTree< TDataType > jointTree)
std::shared_ptr< JointTree > parent
Definition JointTree.h:106
Coord LclRotation
Definition JointTree.h:86
#define T(t)
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
DYN_FUNC JCapsule(int id1, int id2, Coord a0, Coord a1)
Definition JointTree.h:20
DYN_FUNC ~JCapsule()
Definition JointTree.h:22
DataType3f::Coord Coord
Definition JointTree.h:14
DYN_FUNC JCapsule()
Definition JointTree.h:19