载入中...
搜索中...
未找到
Skeleton3D.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "ik.hpp"
6
7namespace eve::ik {
8
14public:
16 Skeleton3D();
18 ~Skeleton3D() = default;
19
20 Skeleton3D(const Skeleton3D &) = delete;
21 Skeleton3D &operator=(const Skeleton3D &) = delete;
22
24 int createBone(int parentId, float length = 1.f);
25
27 int getBoneCount() const;
29 int getRootId() const { return 0; }
31 int getParent(int boneId) const;
33 int getChildCount(int boneId) const;
35 int getChild(int boneId, int childIndex) const;
36
38 float getLength(int boneId) const;
40 void setLength(int boneId, float length);
41
43 void setPosition(int boneId, float x, float y, float z);
45 float getX(int boneId) const;
47 float getY(int boneId) const;
49 float getZ(int boneId) const;
50
52 void setOrientation(int boneId, float x, float y, float z);
54 float getOrientationX(int boneId) const;
56 float getOrientationY(int boneId) const;
58 float getOrientationZ(int boneId) const;
59
61 void setRotation(int boneId, float yaw, float pitch);
63 float getRotationYaw(int boneId) const;
65 float getRotationPitch(int boneId) const;
66
68 void setConstraints(int boneId, float minYaw, float minPitch, float maxYaw,
69 float maxPitch);
71 void clearConstraints(int boneId);
73 bool hasConstraints(int boneId) const;
74
76 void initStraightPose(float rootX = 0.f, float rootY = 0.f, float rootZ = 0.f);
78 void bind();
80 void forwardKinematics();
82 void updateRotations();
83
85 float totalLengthTo(int boneId) const;
86
87 ::ik::skeleton3d &native() { return sk_; }
88 ::ik::ecs3d &state() { return state_; }
89 const ::ik::skeleton3d &native() const { return sk_; }
90 const ::ik::ecs3d &state() const { return state_; }
91
92private:
93 void ensureSorted();
94 void ensureStateSize();
95 ::ik::bone3d *boneAt(int boneId) const;
96 void requireBone(int boneId) const;
97
98 ::ik::skeleton3d sk_;
99 ::ik::ecs3d state_;
100};
101
102} // namespace eve::ik
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float z
Definition AnimClip.cpp:738
float length
Definition CaveMesh.cpp:94
std::uint64_t parentId
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
Script-facing 3D skeleton + pose state (ik::skeleton3d + ik::ecs3d). Local angles are yaw/pitch in th...
Definition Skeleton3D.h:13
::ik::skeleton3d & native()
Definition Skeleton3D.h:87
const ::ik::ecs3d & state() const
Definition Skeleton3D.h:90
::ik::ecs3d & state()
Definition Skeleton3D.h:88
~Skeleton3D()=default
Releases skeleton and pose state.
const ::ik::skeleton3d & native() const
Definition Skeleton3D.h:89
Skeleton3D & operator=(const Skeleton3D &)=delete
Skeleton3D(const Skeleton3D &)=delete
int getRootId() const
Root bone id (always 0).
Definition Skeleton3D.h:29