PeriDyno 1.0.0
Loading...
Searching...
No Matches
ArticulatedBody.h
Go to the documentation of this file.
1
16#pragma once
17#include "RigidBodySystem.h"
18
20
21#include "Topology/TriangleSet.h"
23
24#include "FilePath.h"
25
26namespace dyno
27{
28 template<typename TDataType>
29 class ArticulatedBody : virtual public ParametricModel<TDataType>, virtual public RigidBodySystem<TDataType>
30 {
31 public:
32 typedef typename TDataType::Real Real;
33 typedef typename TDataType::Coord Coord;
34 typedef typename TDataType::Matrix Matrix;
35 typedef typename ::dyno::Pair<uint, uint> BindingPair;
36
38 ~ArticulatedBody() override;
39
40 void bind(std::shared_ptr<PdActor> actor, Pair<uint, uint> shapeId);
41
42 public:
44
48 DEF_VAR(std::vector<Transform3f>, VehiclesTransform, std::vector<Transform3f>{Transform3f()}, "");
49
50 DEF_INSTANCE_STATE(TextureMesh, TextureMesh, "Texture mesh of the vechicle");
51
52 public:
53 DEF_ARRAYLIST_STATE(Transform3f, InstanceTransform, DeviceType::GPU, "Instance transforms");
54
55 DEF_ARRAY_STATE(BindingPair, BindingPair, DeviceType::GPU, "");
56
57 DEF_ARRAY_STATE(int, BindingTag, DeviceType::GPU, "");
58
59 protected:
60 void resetStates() override;
61
62 void updateStates() override;
63
65
67
68 void transform();
69
70 void varChanged();
71
72 protected:
73
74 std::vector<Quat<Real>> getInstanceRotation()
75 {
76 std::vector<Quat<Real>> instanceQ;
77
78 auto instances = this->varVehiclesTransform()->getValue();
79
80 for (auto it : instances)
81 {
82 auto rot = it.rotation();
83 instanceQ.push_back(Quat<Real>(rot));
84 }
85
86 return instanceQ;
87 }
88
89
90 private:
91 std::vector<Pair<uint, uint>> mBindingPair;
92
93 std::vector<std::shared_ptr<PdActor>> mActors;
94 };
95
96
97}
~ArticulatedBody() override
TDataType::Coord Coord
std::vector< Pair< uint, uint > > mBindingPair
DEF_ARRAYLIST_STATE(Transform3f, InstanceTransform, DeviceType::GPU, "Instance transforms")
std::vector< Quat< Real > > getInstanceRotation()
::dyno::Pair< uint, uint > BindingPair
DEF_VAR(std::vector< Transform3f >, VehiclesTransform, std::vector< Transform3f >{Transform3f()}, "")
Creates multiple vehicles and specifies the transformations for each vehicle.
void bind(std::shared_ptr< PdActor > actor, Pair< uint, uint > shapeId)
DEF_INSTANCE_STATE(TextureMesh, TextureMesh, "Texture mesh of the vechicle")
DEF_VAR(FilePath, FilePath, "", "")
DEF_ARRAY_STATE(int, BindingTag, DeviceType::GPU, "")
void resetStates() override
void updateStates() override
TDataType::Matrix Matrix
DEF_ARRAY_STATE(BindingPair, BindingPair, DeviceType::GPU, "")
std::vector< std::shared_ptr< PdActor > > mActors
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
Transform< float, 3 > Transform3f