载入中...
搜索中...
未找到
Skeleton2D.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "ik.hpp"
6
7namespace eve::ik {
8
15public:
17 Skeleton2D();
19 ~Skeleton2D() = default;
20
21 Skeleton2D(const Skeleton2D &) = delete;
22 Skeleton2D &operator=(const Skeleton2D &) = delete;
23
25 int createBone(int parentId, float length = 1.f);
26
28 int getBoneCount() const;
30 int getRootId() const { return 0; }
32 int getParent(int boneId) const;
34 int getChildCount(int boneId) const;
36 int getChild(int boneId, int childIndex) const;
37
39 float getLength(int boneId) const;
41 void setLength(int boneId, float length);
42
44 void setPosition(int boneId, float x, float y);
46 float getX(int boneId) const;
48 float getY(int boneId) const;
49
51 void setOrientation(int boneId, float x, float y);
53 float getOrientationX(int boneId) const;
55 float getOrientationY(int boneId) const;
56
58 void setRotation(int boneId, float angle);
60 float getRotation(int boneId) const;
61
63 void setConstraints(int boneId, float minAngle, float maxAngle);
65 void clearConstraints(int boneId);
67 bool hasConstraints(int boneId) const;
68
70 void initStraightPose(float rootX = 0.f, float rootY = 0.f);
72 void bind();
74 void forwardKinematics();
76 void updateRotations();
77
79 float totalLengthTo(int boneId) const;
80
81 ::ik::skeleton2d &native() { return sk_; }
82 ::ik::ecs2d &state() { return state_; }
83 const ::ik::skeleton2d &native() const { return sk_; }
84 const ::ik::ecs2d &state() const { return state_; }
85
86private:
87 void ensureSorted();
88 void ensureStateSize();
89 ::ik::bone2d *boneAt(int boneId) const;
90 void requireBone(int boneId) const;
91
92 ::ik::skeleton2d sk_;
93 ::ik::ecs2d state_;
94};
95
96} // namespace eve::ik
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float length
Definition CaveMesh.cpp:94
std::uint64_t parentId
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
float angle
Script-facing 2D skeleton + pose state (ik::skeleton2d + ik::ecs2d). Bone indices are stable after ea...
Definition Skeleton2D.h:14
int getRootId() const
Root bone id (always 0).
Definition Skeleton2D.h:30
::ik::skeleton2d & native()
Definition Skeleton2D.h:81
::ik::ecs2d & state()
Definition Skeleton2D.h:82
Skeleton2D & operator=(const Skeleton2D &)=delete
const ::ik::skeleton2d & native() const
Definition Skeleton2D.h:83
~Skeleton2D()=default
Releases skeleton and pose state.
const ::ik::ecs2d & state() const
Definition Skeleton2D.h:84
Skeleton2D(const Skeleton2D &)=delete