载入中...
搜索中...
未找到
Skeleton3D.h
浏览该文件的文档.
1#pragma once
2
3#include "ik.hpp"
4
5namespace eve::ik {
6
12public:
13 Skeleton3D();
14 ~Skeleton3D() = default;
15
16 Skeleton3D(const Skeleton3D &) = delete;
17 Skeleton3D &operator=(const Skeleton3D &) = delete;
18
19 int createBone(int parentId, float length = 1.f);
20
21 int getBoneCount() const;
22 int getRootId() const { return 0; }
23 int getParent(int boneId) const;
24 int getChildCount(int boneId) const;
25 int getChild(int boneId, int childIndex) const;
26
27 float getLength(int boneId) const;
28 void setLength(int boneId, float length);
29
30 void setPosition(int boneId, float x, float y, float z);
31 float getX(int boneId) const;
32 float getY(int boneId) const;
33 float getZ(int boneId) const;
34
35 void setOrientation(int boneId, float x, float y, float z);
36 float getOrientationX(int boneId) const;
37 float getOrientationY(int boneId) const;
38 float getOrientationZ(int boneId) const;
39
40 void setRotation(int boneId, float yaw, float pitch);
41 float getRotationYaw(int boneId) const;
42 float getRotationPitch(int boneId) const;
43
44 void setConstraints(int boneId, float minYaw, float minPitch, float maxYaw,
45 float maxPitch);
46 void clearConstraints(int boneId);
47 bool hasConstraints(int boneId) const;
48
49 void initStraightPose(float rootX = 0.f, float rootY = 0.f, float rootZ = 0.f);
50 void bind();
51 void forwardKinematics();
52 void updateRotations();
53
54 float totalLengthTo(int boneId) const;
55
56 ::ik::skeleton3d &native() { return sk_; }
57 ::ik::ecs3d &state() { return state_; }
58 const ::ik::skeleton3d &native() const { return sk_; }
59 const ::ik::ecs3d &state() const { return state_; }
60
61private:
62 void ensureSorted();
63 void ensureStateSize();
64 ::ik::bone3d *boneAt(int boneId) const;
65 void requireBone(int boneId) const;
66
67 ::ik::skeleton3d sk_;
68 ::ik::ecs3d state_;
69};
70
71} // namespace eve::ik
int y
Definition Grass.cpp:135
int z
Definition Grass.cpp:135
int x
Definition Grass.cpp:135
Script-facing 3D skeleton + pose state (ik::skeleton3d + ik::ecs3d). Local angles are yaw/pitch in th...
Definition Skeleton3D.h:11
void setPosition(int boneId, float x, float y, float z)
void setConstraints(int boneId, float minYaw, float minPitch, float maxYaw, float maxPitch)
float getLength(int boneId) const
::ik::skeleton3d & native()
Definition Skeleton3D.h:56
void setLength(int boneId, float length)
const ::ik::ecs3d & state() const
Definition Skeleton3D.h:59
::ik::ecs3d & state()
Definition Skeleton3D.h:57
int getChildCount(int boneId) const
int createBone(int parentId, float length=1.f)
float getRotationPitch(int boneId) const
void setRotation(int boneId, float yaw, float pitch)
const ::ik::skeleton3d & native() const
Definition Skeleton3D.h:58
Skeleton3D & operator=(const Skeleton3D &)=delete
void setOrientation(int boneId, float x, float y, float z)
void initStraightPose(float rootX=0.f, float rootY=0.f, float rootZ=0.f)
float totalLengthTo(int boneId) const
Skeleton3D(const Skeleton3D &)=delete
float getOrientationZ(int boneId) const
void clearConstraints(int boneId)
float getZ(int boneId) const
float getY(int boneId) const
float getOrientationY(int boneId) const
bool hasConstraints(int boneId) const
float getX(int boneId) const
int getChild(int boneId, int childIndex) const
float getOrientationX(int boneId) const
float getRotationYaw(int boneId) const
int getParent(int boneId) const
int getRootId() const
Definition Skeleton3D.h:22
int getBoneCount() const