载入中...
搜索中...
未找到
SpineSkeleton.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
6
7#include <string>
8#include <vector>
9
10namespace eve::animation {
11
17public:
19 explicit SpineSkeleton(SpineSkeletonData *data);
21 ~SpineSkeleton() = default;
22
23 SpineSkeleton(const SpineSkeleton &) = delete;
25
27 SpineSkeletonData *getData() const { return data_; }
28
30 bool setSkin(const std::string &name);
32 int getSkin() const { return skinIndex_; }
33
35 void setToSetupPose();
37 void updateWorldTransform();
38
40 int getBoneCount() const;
42 float getBoneLocalX(int index) const;
44 float getBoneLocalY(int index) const;
46 float getBoneLocalRotation(int index) const;
48 float getBoneLocalScaleX(int index) const;
50 float getBoneLocalScaleY(int index) const;
51
53 void setBoneLocalX(int index, float x);
55 void setBoneLocalY(int index, float y);
57 void setBoneLocalRotation(int index, float degrees);
59 void setBoneLocalScaleX(int index, float sx);
61 void setBoneLocalScaleY(int index, float sy);
62
64 float getBoneWorldX(int index) const;
66 float getBoneWorldY(int index) const;
68 float getBoneWorldRotation(int index) const;
70 float getBoneWorldScaleX(int index) const;
72 float getBoneWorldScaleY(int index) const;
74 void getBoneWorldMatrix(int index, float &a, float &b, float &c, float &d) const;
75
77 int getSlotCount() const;
79 std::string getSlotAttachmentName(int slotIndex) const;
81 void setSlotAttachmentName(int slotIndex, const std::string &name);
82
84 const SpineSkeletonData::RegionAttachment *getSlotRegion(int slotIndex) const;
85
86private:
87 friend class SpineAnim;
88
89 struct BonePose {
90 float x = 0.f, y = 0.f;
91 float rotation = 0.f;
92 float scaleX = 1.f, scaleY = 1.f;
93 float worldX = 0.f, worldY = 0.f;
94 float worldRot = 0.f;
95 float worldSX = 1.f, worldSY = 1.f;
96 float a = 1.f, b = 0.f, c = 0.f, d = 1.f; // 2x2 world matrix
97 };
98
99 void checkBone(int index) const;
100 void checkSlot(int index) const;
101
102 SpineSkeletonData *data_ = nullptr;
103 int skinIndex_ = 0;
104 std::vector<BonePose> bones_;
105 std::vector<std::string> slotAttachments_;
106};
107
108} // namespace eve::animation
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float degrees
Definition CardTypes.cpp:35
#define EVENGINE_API_WORLD
Definition Export.h:109
std::int32_t c
std::array< float, 4 > rotation
std::string name
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
float d
uint32_t index
Spine animation player + 2D draw collector (region attachments).
Definition SpineAnim.h:35
Spine skeleton JSON data (bones / slots / skins / animations).
Runtime Spine skeleton pose (local + world bone transforms, slot attachments). Script type: SpineSkel...
SpineSkeleton & operator=(const SpineSkeleton &)=delete
SpineSkeleton(const SpineSkeleton &)=delete
int getSkin() const
Returns the skin.
~SpineSkeleton()=default
Spine skeleton.
SpineSkeletonData * getData() const
Returns the data.