PeriDyno 0.8.2
SkeletonLoader.h
Go to the documentation of this file.
1
16#pragma once
17#include "Node.h"
18
20#include "Topology/DiscreteElements.h"
21#include "Topology/JointTree.h"
22
23#include "FilePath.h"
24
25#include "ofbx.h"
26
27namespace dyno
28{
33 template<typename TDataType>
34 class SkeletonLoader : public Node
35 {
37 public:
38 typedef typename TDataType::Real Real;
39 typedef typename TDataType::Coord Coord;
40
41 typedef std::vector<std::shared_ptr<JointTree<typename TDataType>>> JointList;
42
44 virtual ~SkeletonLoader();
45
46 void setJointMap(JointList &jointMap) { m_jointMap = jointMap; }
49 // DEF_VAR(std::string, FileName, "", "");
50
51 bool translate(Coord t);
52 bool scale(Real s);
53
54 void loadFBX();
55 bool initFBX(const char* filepath);
56 void getNodes(const ofbx::IScene& scene);
57
58 void getModelProperties(const ofbx::Object& object, std::shared_ptr<JointTree<TDataType>> cur);
59 void getAnimationCurve(const ofbx::Object& object, std::shared_ptr<JointTree<TDataType>> parent);
60 void getLimbNode(const ofbx::Object& object, std::shared_ptr<JointTree<TDataType>> parent);
61
62 // 需要根据模型与骨骼的坐标关系来改变
63 void copyVec(Coord &dest, ofbx::Vec3 src){dest = Coord(src.x, src.y, src.z);}
64 void copyVecR(Coord &dest, ofbx::Vec3 src){dest = Coord(src.x, src.y, src.z);}
65 void copyVecT(Coord &dest, ofbx::Vec3 src){dest = Coord(src.x, src.y, src.z);}
66
67 public:
68 DEF_VAR(Real, Radius, 0.0075 , " Radius of Capsule")
72 DEF_INSTANCE_STATE(TopologyModule, Topology, "Topology");
73
74 DEF_ARRAY_OUT(JCapsule, Capsule, DeviceType::GPU, "Capsule <V, U> Detail");
75
76 // DEF_ARRAY_OUT(Coord, Velocity, DeviceType::GPU, "Capsule Velocity");
77 // DEF_ARRAY_OUT(Coord, AngularVelocity, DeviceType::GPU, "Capsule AngularVelocity");
78 DEF_ARRAY_OUT(Quat<Real>, Rotate, DeviceType::GPU, "Capsule Rotate");
79 DEF_ARRAY_OUT(Quat<Real>, Translate, DeviceType::GPU, "Capsule Translate");
80
81 // 动画插值的骨骼位置
82 DEF_ARRAY_OUT(Coord, PosV, DeviceType::GPU, "Capsule <V, U> V position");
83 DEF_ARRAY_OUT(Coord, PosU, DeviceType::GPU, "Capsule <V, U> U position");
84
88 DEF_VAR(FilePath, FileName, "", "");
89
91
92
93 std::vector<JCapsule> m_capLists;
94 std::vector<Quat<Real>> m_T;
95 std::vector<Quat<Real>> m_R;
96
97 std::vector<Capsule3D> mHostCap3D;
98 // DArray<Capsule3D> mDeviceCaps;
99
100
101 int m_numCaps = 0;
102 int m_numjoints = 0;
103
104 protected:
105 void resetStates() override;
106 void updateTopology() override;
107
108 ofbx::IScene* g_scene = nullptr;
109 };
110}
#define DECLARE_TCLASS(name, T1)
Definition: Object.h:87
DeviceType
Definition: Platform.h:42
@ GPU
Definition: Platform.h:44
double Real
Definition: Typedef.inl:23
A JointTree(Skeleton) represents a hierarchical tree structure of joints.
Definition: JointTree.h:31
ofbx::IScene * g_scene
std::vector< Capsule3D > mHostCap3D
DEF_INSTANCE_STATE(TopologyModule, Topology, "Topology")
Capsule Topology.
void setJointMap(JointList &jointMap)
std::vector< std::shared_ptr< JointTree< typename TDataType > > > JointList
void resetStates() override
void getCenterQuat(Coord v0, Coord v1, Quat< Real > &T, Quat< Real > &R)
std::vector< Quat< Real > > m_R
void getAnimationCurve(const ofbx::Object &object, std::shared_ptr< JointTree< TDataType > > parent)
bool initFBX(const char *filepath)
void copyVec(Coord &dest, ofbx::Vec3 src)
void getNodes(const ofbx::IScene &scene)
void updateTopology() override
TDataType::Coord Coord
void copyVecT(Coord &dest, ofbx::Vec3 src)
TDataType::Real Real
std::vector< Quat< Real > > m_T
void copyVecR(Coord &dest, ofbx::Vec3 src)
DEF_ARRAY_OUT(JCapsule, Capsule, DeviceType::GPU, "Capsule <V, U> Detail")
DEF_VAR(FilePath, FileName, "", "")
FBX file.
void getModelProperties(const ofbx::Object &object, std::shared_ptr< JointTree< TDataType > > cur)
void getLimbNode(const ofbx::Object &object, std::shared_ptr< JointTree< TDataType > > parent)
JointList getJointMap()
std::vector< JCapsule > m_capLists
#define V(a, b, c)
#define T(t)
This is an implementation of AdditiveCCD based on peridyno.
Definition: Array.h:24
fs::path FilePath
Definition: FilePath.h:6
Definition: ofbx.cpp:14
double y
Definition: ofbx.h:43
double z
Definition: ofbx.h:43
double x
Definition: ofbx.h:43