PeriDyno 1.2.1
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 "Field/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 //Bind rigid body to a shape in TextureMesh
41 void bindShape(std::shared_ptr<PdActor> actor, Pair<uint, uint> shapeId);
42
43 public:
45
49 DEF_VAR(std::vector<Transform3f>, VehiclesTransform, std::vector<Transform3f>{Transform3f()}, "");
50
51 DEF_INSTANCE_STATE(TextureMesh, TextureMesh, "Texture mesh of the vechicle");
52
53 public:
54 DEF_ARRAYLIST_STATE(Transform3f, InstanceTransform, DeviceType::GPU, "Instance transforms");
55
56 DEF_ARRAY_STATE(BindingPair, BindingPair, DeviceType::GPU, "");
57
58 DEF_ARRAY_STATE(int, BindingTag, DeviceType::GPU, "");
59
60 protected:
61 void resetStates() override;
62
63 void updateStates() override;
64
66
68
69 void transform();
70
71 void varChanged();
72
73 protected:
74
75 std::vector<Quat<Real>> getInstanceRotation()
76 {
77 std::vector<Quat<Real>> instanceQ;
78
79 auto instances = this->varVehiclesTransform()->getValue();
80
81 for (auto it : instances)
82 {
83 auto rot = it.rotation();
84 instanceQ.push_back(Quat<Real>(rot));
85 }
86
87 return instanceQ;
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.
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
void bindShape(std::shared_ptr< PdActor > actor, Pair< uint, uint > shapeId)
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