PeriDyno 1.2.1
Loading...
Searching...
No Matches
AnimationDriver.h
Go to the documentation of this file.
1
16#pragma once
18#include "Topology/DiscreteElements.h"
20#include "Field/VehicleInfo.h"
21
22namespace dyno
23{
24
25
26
27 template<typename TDataType>
29 {
31 public:
32 typedef typename TDataType::Real Real;
33 typedef typename TDataType::Coord Coord;
34 typedef typename TDataType::Matrix Matrix;
35
36 typedef typename ::dyno::BallAndSocketJoint<Real> BallAndSocketJoint;
37 typedef typename ::dyno::SliderJoint<Real> SliderJoint;
38 typedef typename ::dyno::HingeJoint<Real> HingeJoint;
39 typedef typename ::dyno::FixedJoint<Real> FixedJoint;
40 typedef typename ::dyno::PointJoint<Real> PointJoint;
41 typedef typename dyno::Quat<Real> TQuat;
42
44 ~AnimationDriver() override {};
45
46
47
48 DEF_VAR(Real, Speed,4,"Speed");
49
50 DEF_VAR(std::vector<Animation2JointConfig>, BindingConfiguration, std::vector<Animation2JointConfig>(), "Animation Joint Config");
51
54 DEF_VAR_IN(Real, DeltaTime,"");
55
56
57 public:
58
59
60
61 protected:
62
63 void onEvent(PKeyboardEvent event) override;
64
65 void getFrameAndWeight(float time,Vec3i& keyFrame,Vec3f& weight, std::vector<std::vector<Real>*> animTime)
66 {
67 for (size_t channel = 0; channel < 3; channel++)
68 {
69 float tempTime = std::fmod(time, (*animTime[channel]).back());
70
71 std::vector<Real>& animData = *animTime[channel];
72 for (size_t j = 0; j < animData.size() - 1; j++)
73 {
74 if (tempTime > animData[j] && tempTime <= animData[j + 1])
75 {
76 float v = (tempTime - animData[j]) / (animData[j + 1] - animData[j]);
77 weight[channel] = v;
78 keyFrame[channel] = j;
79 break;
80 }
81
82 }
83 }
84
85
86 }
87
88
89
90 private:
91
92 float move = 0;
93 };
94}
DEF_INSTANCE_IN(JointAnimationInfo, JointAnimationInfo,"Animation objects")
void onEvent(PKeyboardEvent event) override
DEF_VAR_IN(Real, DeltaTime,"")
::dyno::FixedJoint< Real > FixedJoint
void getFrameAndWeight(float time, Vec3i &keyFrame, Vec3f &weight, std::vector< std::vector< Real > * > animTime)
::dyno::PointJoint< Real > PointJoint
::dyno::BallAndSocketJoint< Real > BallAndSocketJoint
::dyno::SliderJoint< Real > SliderJoint
TDataType::Coord Coord
TDataType::Matrix Matrix
::dyno::HingeJoint< Real > HingeJoint
dyno::Quat< Real > TQuat
DEF_VAR(Real, Speed, 4,"Speed")
DEF_VAR(std::vector< Animation2JointConfig >, BindingConfiguration, std::vector< Animation2JointConfig >(), "Animation Joint Config")
DECLARE_TCLASS(AnimationDriver, TDataType)
DEF_INSTANCE_IN(DiscreteElements< TDataType >, Topology, "Topology")
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
Vector< int, 3 > Vec3i
Definition Vector3D.h:95
Vector< float, 3 > Vec3f
Definition Vector3D.h:93