mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[godot] Formatting
This commit is contained in:
parent
0b0800143a
commit
5ec5544132
@ -25,7 +25,9 @@ spotless {
|
|||||||
'spine-sfml/**/*.cpp',
|
'spine-sfml/**/*.cpp',
|
||||||
'spine-sfml/**/*.h',
|
'spine-sfml/**/*.h',
|
||||||
'spine-ue4/**/*.cpp',
|
'spine-ue4/**/*.cpp',
|
||||||
'spine-ue4/**/*.h'
|
'spine-ue4/**/*.h',
|
||||||
|
'spine-godot/spine_godot/**.h',
|
||||||
|
'spine-godot/spine_godot/**.cpp'
|
||||||
clangFormat("12.0.1").pathToExe("$System.env.CLANGFORMAT").style('file')
|
clangFormat("12.0.1").pathToExe("$System.env.CLANGFORMAT").style('file')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,39 +38,39 @@ spine::SpineExtension *spine::getDefaultExtension() {
|
|||||||
return new GodotSpineExtension();
|
return new GodotSpineExtension();
|
||||||
}
|
}
|
||||||
|
|
||||||
GodotSpineExtension::GodotSpineExtension(){}
|
GodotSpineExtension::GodotSpineExtension() {}
|
||||||
GodotSpineExtension::~GodotSpineExtension(){}
|
GodotSpineExtension::~GodotSpineExtension() {}
|
||||||
|
|
||||||
void *GodotSpineExtension::_alloc(size_t size, const char *file, int line){
|
void *GodotSpineExtension::_alloc(size_t size, const char *file, int line) {
|
||||||
return memalloc(size);
|
return memalloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *GodotSpineExtension::_calloc(size_t size, const char *file, int line){
|
void *GodotSpineExtension::_calloc(size_t size, const char *file, int line) {
|
||||||
auto p = memalloc(size);
|
auto p = memalloc(size);
|
||||||
memset(p, 0, size);
|
memset(p, 0, size);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *GodotSpineExtension::_realloc(void *ptr, size_t size, const char *file, int line){
|
void *GodotSpineExtension::_realloc(void *ptr, size_t size, const char *file, int line) {
|
||||||
return memrealloc(ptr, size);
|
return memrealloc(ptr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GodotSpineExtension::_free(void *mem, const char *file, int line){
|
void GodotSpineExtension::_free(void *mem, const char *file, int line) {
|
||||||
memfree(mem);
|
memfree(mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *GodotSpineExtension::_readFile(const spine::String &path, int *length){
|
char *GodotSpineExtension::_readFile(const spine::String &path, int *length) {
|
||||||
Error error;
|
Error error;
|
||||||
auto res = FileAccess::get_file_as_array(String(path.buffer()), &error);
|
auto res = FileAccess::get_file_as_array(String(path.buffer()), &error);
|
||||||
|
|
||||||
if (error != OK){
|
if (error != OK) {
|
||||||
if(length) *length = 0;
|
if (length) *length = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(length) *length = res.size();
|
if (length) *length = res.size();
|
||||||
auto r = alloc<char>(res.size(), __FILE__, __LINE__);
|
auto r = alloc<char>(res.size(), __FILE__, __LINE__);
|
||||||
for(size_t i=0;i<res.size();++i)
|
for (size_t i = 0; i < res.size(); ++i)
|
||||||
r[i] = res[i];
|
r[i] = res[i];
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -51,7 +51,4 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif//GODOT_SPINEEXTENSION_H
|
||||||
|
|
||||||
|
|
||||||
#endif //GODOT_SPINEEXTENSION_H
|
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include "PackedSpineSkinResource.h"
|
#include "PackedSpineSkinResource.h"
|
||||||
|
|
||||||
void PackedSpineSkinResource::_bind_methods(){
|
void PackedSpineSkinResource::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_skin_name", "v"), &PackedSpineSkinResource::set_skin_name);
|
ClassDB::bind_method(D_METHOD("set_skin_name", "v"), &PackedSpineSkinResource::set_skin_name);
|
||||||
ClassDB::bind_method(D_METHOD("get_skin_name"), &PackedSpineSkinResource::get_skin_name);
|
ClassDB::bind_method(D_METHOD("get_skin_name"), &PackedSpineSkinResource::get_skin_name);
|
||||||
ClassDB::bind_method(D_METHOD("set_sub_skin_names", "v"), &PackedSpineSkinResource::set_sub_skin_names);
|
ClassDB::bind_method(D_METHOD("set_sub_skin_names", "v"), &PackedSpineSkinResource::set_sub_skin_names);
|
||||||
@ -41,21 +41,21 @@ void PackedSpineSkinResource::_bind_methods(){
|
|||||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "sub_skin_names"), "set_sub_skin_names", "get_sub_skin_names");
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "sub_skin_names"), "set_sub_skin_names", "get_sub_skin_names");
|
||||||
}
|
}
|
||||||
|
|
||||||
PackedSpineSkinResource::PackedSpineSkinResource():skin_name("custom_skin_name"){}
|
PackedSpineSkinResource::PackedSpineSkinResource() : skin_name("custom_skin_name") {}
|
||||||
PackedSpineSkinResource::~PackedSpineSkinResource(){}
|
PackedSpineSkinResource::~PackedSpineSkinResource() {}
|
||||||
|
|
||||||
void PackedSpineSkinResource::set_skin_name(const String &v){
|
void PackedSpineSkinResource::set_skin_name(const String &v) {
|
||||||
skin_name = v;
|
skin_name = v;
|
||||||
emit_signal("property_changed");
|
emit_signal("property_changed");
|
||||||
}
|
}
|
||||||
String PackedSpineSkinResource::get_skin_name(){
|
String PackedSpineSkinResource::get_skin_name() {
|
||||||
return skin_name;
|
return skin_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackedSpineSkinResource::set_sub_skin_names(Array v){
|
void PackedSpineSkinResource::set_sub_skin_names(Array v) {
|
||||||
sub_skin_names = v;
|
sub_skin_names = v;
|
||||||
emit_signal("property_changed");
|
emit_signal("property_changed");
|
||||||
}
|
}
|
||||||
Array PackedSpineSkinResource::get_sub_skin_names(){
|
Array PackedSpineSkinResource::get_sub_skin_names() {
|
||||||
return sub_skin_names;
|
return sub_skin_names;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
#include "SpineSkin.h"
|
#include "SpineSkin.h"
|
||||||
|
|
||||||
class PackedSpineSkinResource : public Resource{
|
class PackedSpineSkinResource : public Resource {
|
||||||
GDCLASS(PackedSpineSkinResource, Resource);
|
GDCLASS(PackedSpineSkinResource, Resource);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -53,7 +53,6 @@ public:
|
|||||||
|
|
||||||
void set_sub_skin_names(Array v);
|
void set_sub_skin_names(Array v);
|
||||||
Array get_sub_skin_names();
|
Array get_sub_skin_names();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_PACKEDSPINESKINRESOURCE_H
|
#endif//GODOT_PACKEDSPINESKINRESOURCE_H
|
||||||
|
|||||||
@ -34,7 +34,7 @@ RES ResourceFormatLoaderSpineAtlas::load(const String &p_path, const String &p_o
|
|||||||
Ref<SpineAtlasResource> atlas = memnew(SpineAtlasResource);
|
Ref<SpineAtlasResource> atlas = memnew(SpineAtlasResource);
|
||||||
atlas->load_from_file(p_path);
|
atlas->load_from_file(p_path);
|
||||||
|
|
||||||
if(r_error){
|
if (r_error) {
|
||||||
*r_error = OK;
|
*r_error = OK;
|
||||||
}
|
}
|
||||||
return atlas;
|
return atlas;
|
||||||
@ -42,7 +42,7 @@ RES ResourceFormatLoaderSpineAtlas::load(const String &p_path, const String &p_o
|
|||||||
|
|
||||||
void ResourceFormatLoaderSpineAtlas::get_recognized_extensions(List<String> *r_extensions) const {
|
void ResourceFormatLoaderSpineAtlas::get_recognized_extensions(List<String> *r_extensions) const {
|
||||||
const char atlas_ext[] = "spatlas";
|
const char atlas_ext[] = "spatlas";
|
||||||
if(!r_extensions->find(atlas_ext)) {
|
if (!r_extensions->find(atlas_ext)) {
|
||||||
r_extensions->push_back(atlas_ext);
|
r_extensions->push_back(atlas_ext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,8 +32,9 @@
|
|||||||
|
|
||||||
#include "core/io/resource_loader.h"
|
#include "core/io/resource_loader.h"
|
||||||
|
|
||||||
class ResourceFormatLoaderSpineAtlas : public ResourceFormatLoader{
|
class ResourceFormatLoaderSpineAtlas : public ResourceFormatLoader {
|
||||||
GDCLASS(ResourceFormatLoaderSpineAtlas, ResourceFormatLoader);
|
GDCLASS(ResourceFormatLoaderSpineAtlas, ResourceFormatLoader);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual RES load(const String &p_path, const String &p_original_path, Error *r_error = NULL);
|
virtual RES load(const String &p_path, const String &p_original_path, Error *r_error = NULL);
|
||||||
virtual void get_recognized_extensions(List<String> *r_extensions) const;
|
virtual void get_recognized_extensions(List<String> *r_extensions) const;
|
||||||
@ -42,4 +43,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //GODOT_RESOURCEFORMATLOADERSPINEATLAS_H
|
#endif//GODOT_RESOURCEFORMATLOADERSPINEATLAS_H
|
||||||
|
|||||||
@ -34,7 +34,7 @@ RES ResourceFormatLoaderSpineSkeletonJsonData::load(const String &p_path, const
|
|||||||
Ref<SpineSkeletonJsonDataResource> skeleton = memnew(SpineSkeletonJsonDataResource);
|
Ref<SpineSkeletonJsonDataResource> skeleton = memnew(SpineSkeletonJsonDataResource);
|
||||||
skeleton->load_from_file(p_path);
|
skeleton->load_from_file(p_path);
|
||||||
|
|
||||||
if(r_error){
|
if (r_error) {
|
||||||
*r_error = OK;
|
*r_error = OK;
|
||||||
}
|
}
|
||||||
return skeleton;
|
return skeleton;
|
||||||
@ -42,7 +42,7 @@ RES ResourceFormatLoaderSpineSkeletonJsonData::load(const String &p_path, const
|
|||||||
|
|
||||||
void ResourceFormatLoaderSpineSkeletonJsonData::get_recognized_extensions(List<String> *r_extensions) const {
|
void ResourceFormatLoaderSpineSkeletonJsonData::get_recognized_extensions(List<String> *r_extensions) const {
|
||||||
const char json_ext[] = "spjson";
|
const char json_ext[] = "spjson";
|
||||||
if(!r_extensions->find(json_ext)) {
|
if (!r_extensions->find(json_ext)) {
|
||||||
r_extensions->push_back(json_ext);
|
r_extensions->push_back(json_ext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
class ResourceFormatLoaderSpineSkeletonJsonData : public ResourceFormatLoader {
|
class ResourceFormatLoaderSpineSkeletonJsonData : public ResourceFormatLoader {
|
||||||
GDCLASS(ResourceFormatLoaderSpineSkeletonJsonData, ResourceFormatLoader);
|
GDCLASS(ResourceFormatLoaderSpineSkeletonJsonData, ResourceFormatLoader);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual RES load(const String &p_path, const String &p_original_path, Error *r_error = NULL);
|
virtual RES load(const String &p_path, const String &p_original_path, Error *r_error = NULL);
|
||||||
virtual void get_recognized_extensions(List<String> *r_extensions) const;
|
virtual void get_recognized_extensions(List<String> *r_extensions) const;
|
||||||
@ -41,4 +42,4 @@ public:
|
|||||||
virtual String get_resource_type(const String &p_path) const;
|
virtual String get_resource_type(const String &p_path) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_RESOURCEFORMATLOADERSPINESKELETONJSONDATA_H
|
#endif//GODOT_RESOURCEFORMATLOADERSPINESKELETONJSONDATA_H
|
||||||
|
|||||||
@ -32,8 +32,9 @@
|
|||||||
|
|
||||||
#include "core/io/resource_saver.h"
|
#include "core/io/resource_saver.h"
|
||||||
|
|
||||||
class ResourceFormatSaverSpineAtlas : public ResourceFormatSaver{
|
class ResourceFormatSaverSpineAtlas : public ResourceFormatSaver {
|
||||||
GDCLASS(ResourceFormatSaverSpineAtlas, ResourceFormatSaver);
|
GDCLASS(ResourceFormatSaverSpineAtlas, ResourceFormatSaver);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0) override;
|
Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0) override;
|
||||||
void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const override;
|
void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const override;
|
||||||
@ -41,4 +42,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //GODOT_RESOURCEFORMATSAVERSPINEATLAS_H
|
#endif//GODOT_RESOURCEFORMATSAVERSPINEATLAS_H
|
||||||
|
|||||||
@ -32,8 +32,9 @@
|
|||||||
|
|
||||||
#include "core/io/resource_saver.h"
|
#include "core/io/resource_saver.h"
|
||||||
|
|
||||||
class ResourceFormatSaverSpineSkeletonJsonData : public ResourceFormatSaver{
|
class ResourceFormatSaverSpineSkeletonJsonData : public ResourceFormatSaver {
|
||||||
GDCLASS(ResourceFormatSaverSpineSkeletonJsonData, ResourceFormatSaver);
|
GDCLASS(ResourceFormatSaverSpineSkeletonJsonData, ResourceFormatSaver);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0) override;
|
Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0) override;
|
||||||
void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const override;
|
void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const override;
|
||||||
@ -41,4 +42,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //GODOT_RESOURCEFORMATSAVERSPINESKELETONJSONDATA_H
|
#endif//GODOT_RESOURCEFORMATSAVERSPINESKELETONJSONDATA_H
|
||||||
|
|||||||
@ -46,8 +46,8 @@ void SpineAnimation::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("has_timeline", "ids"), &SpineAnimation::has_timeline);
|
ClassDB::bind_method(D_METHOD("has_timeline", "ids"), &SpineAnimation::has_timeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineAnimation::SpineAnimation():animation(NULL) {}
|
SpineAnimation::SpineAnimation() : animation(NULL) {}
|
||||||
SpineAnimation::~SpineAnimation(){}
|
SpineAnimation::~SpineAnimation() {}
|
||||||
|
|
||||||
String SpineAnimation::get_anim_name() {
|
String SpineAnimation::get_anim_name() {
|
||||||
return animation->getName().buffer();
|
return animation->getName().buffer();
|
||||||
@ -63,10 +63,10 @@ void SpineAnimation::set_duration(float v) {
|
|||||||
void SpineAnimation::apply(Ref<SpineSkeleton> skeleton, float lastTime, float time, bool loop,
|
void SpineAnimation::apply(Ref<SpineSkeleton> skeleton, float lastTime, float time, bool loop,
|
||||||
Array pEvents, float alpha, SpineConstant::MixBlend blend,
|
Array pEvents, float alpha, SpineConstant::MixBlend blend,
|
||||||
SpineConstant::MixDirection direction) {
|
SpineConstant::MixDirection direction) {
|
||||||
spine::Vector<spine::Event*> events;
|
spine::Vector<spine::Event *> events;
|
||||||
events.setSize(pEvents.size(), nullptr);
|
events.setSize(pEvents.size(), nullptr);
|
||||||
for (size_t i=0; i<events.size(); ++i) {
|
for (size_t i = 0; i < events.size(); ++i) {
|
||||||
events[i] = ((Ref<SpineEvent>)(pEvents[i]))->get_spine_object();
|
events[i] = ((Ref<SpineEvent>) (pEvents[i]))->get_spine_object();
|
||||||
}
|
}
|
||||||
animation->apply(*(skeleton->get_spine_object()), lastTime, time, loop, &events, alpha, (spine::MixBlend) blend, (spine::MixDirection) direction);
|
animation->apply(*(skeleton->get_spine_object()), lastTime, time, loop, &events, alpha, (spine::MixBlend) blend, (spine::MixDirection) direction);
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ Array SpineAnimation::get_timelines() {
|
|||||||
Array res;
|
Array res;
|
||||||
res.resize(timelines.size());
|
res.resize(timelines.size());
|
||||||
|
|
||||||
for (size_t i=0; i<res.size(); ++i) {
|
for (size_t i = 0; i < res.size(); ++i) {
|
||||||
auto a = Ref<SpineTimeline>(memnew(SpineTimeline));
|
auto a = Ref<SpineTimeline>(memnew(SpineTimeline));
|
||||||
a->set_spine_object(timelines[i]);
|
a->set_spine_object(timelines[i]);
|
||||||
res.set(i, a);
|
res.set(i, a);
|
||||||
@ -89,7 +89,7 @@ bool SpineAnimation::has_timeline(Array ids) {
|
|||||||
spine::Vector<spine::PropertyId> list;
|
spine::Vector<spine::PropertyId> list;
|
||||||
list.setSize(ids.size(), 0);
|
list.setSize(ids.size(), 0);
|
||||||
|
|
||||||
for (size_t i=0; i<list.size(); ++i) {
|
for (size_t i = 0; i < list.size(); ++i) {
|
||||||
list[i] = ids[i];
|
list[i] = ids[i];
|
||||||
}
|
}
|
||||||
return animation->hasTimeline(list);
|
return animation->hasTimeline(list);
|
||||||
|
|||||||
@ -40,7 +40,7 @@ class SpineEvent;
|
|||||||
class SpineSkeleton;
|
class SpineSkeleton;
|
||||||
class SpineTimeline;
|
class SpineTimeline;
|
||||||
|
|
||||||
class SpineAnimation : public Reference{
|
class SpineAnimation : public Reference {
|
||||||
GDCLASS(SpineAnimation, Reference);
|
GDCLASS(SpineAnimation, Reference);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -53,10 +53,10 @@ public:
|
|||||||
SpineAnimation();
|
SpineAnimation();
|
||||||
~SpineAnimation();
|
~SpineAnimation();
|
||||||
|
|
||||||
inline void set_spine_object(spine::Animation *a){
|
inline void set_spine_object(spine::Animation *a) {
|
||||||
animation = a;
|
animation = a;
|
||||||
}
|
}
|
||||||
inline spine::Animation *get_spine_object(){
|
inline spine::Animation *get_spine_object() {
|
||||||
return animation;
|
return animation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,11 +64,11 @@ public:
|
|||||||
void apply(Ref<SpineSkeleton> skeleton, float lastTime, float time, bool loop, Array pEvents, float alpha, SpineConstant::MixBlend blend, SpineConstant::MixDirection direction);
|
void apply(Ref<SpineSkeleton> skeleton, float lastTime, float time, bool loop, Array pEvents, float alpha, SpineConstant::MixBlend blend, SpineConstant::MixDirection direction);
|
||||||
|
|
||||||
Array get_timelines(); // Vector<Ref<SpineTimeline>>
|
Array get_timelines(); // Vector<Ref<SpineTimeline>>
|
||||||
bool has_timeline(Array ids); // Vector<SpineConstant::PropertyId>
|
bool has_timeline(Array ids);// Vector<SpineConstant::PropertyId>
|
||||||
|
|
||||||
String get_anim_name();
|
String get_anim_name();
|
||||||
float get_duration();
|
float get_duration();
|
||||||
void set_duration(float v);
|
void set_duration(float v);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINEANIMATION_H
|
#endif//GODOT_SPINEANIMATION_H
|
||||||
|
|||||||
@ -44,25 +44,22 @@ void SpineAnimationState::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_time_scale", "time_scale"), &SpineAnimationState::set_time_scale);
|
ClassDB::bind_method(D_METHOD("set_time_scale", "time_scale"), &SpineAnimationState::set_time_scale);
|
||||||
ClassDB::bind_method(D_METHOD("disable_queue"), &SpineAnimationState::disable_queue);
|
ClassDB::bind_method(D_METHOD("disable_queue"), &SpineAnimationState::disable_queue);
|
||||||
ClassDB::bind_method(D_METHOD("enable_queue"), &SpineAnimationState::enable_queue);
|
ClassDB::bind_method(D_METHOD("enable_queue"), &SpineAnimationState::enable_queue);
|
||||||
// ClassDB::bind_method(D_METHOD("reload"), &SpineAnimationState::reload_animation_state);
|
// ClassDB::bind_method(D_METHOD("reload"), &SpineAnimationState::reload_animation_state);
|
||||||
ClassDB::bind_method(D_METHOD("get_current", "track_id"), &SpineAnimationState::get_current);
|
ClassDB::bind_method(D_METHOD("get_current", "track_id"), &SpineAnimationState::get_current);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineAnimationState::SpineAnimationState():animation_state(NULL) {
|
SpineAnimationState::SpineAnimationState() : animation_state(NULL) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineAnimationState::~SpineAnimationState() {
|
SpineAnimationState::~SpineAnimationState() {
|
||||||
if(animation_state)
|
if (animation_state) {
|
||||||
{
|
|
||||||
delete animation_state;
|
delete animation_state;
|
||||||
animation_state = NULL;
|
animation_state = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineAnimationState::load_animation_state(Ref<SpineAnimationStateDataResource> ad) {
|
void SpineAnimationState::load_animation_state(Ref<SpineAnimationStateDataResource> ad) {
|
||||||
if(animation_state)
|
if (animation_state) {
|
||||||
{
|
|
||||||
delete animation_state;
|
delete animation_state;
|
||||||
animation_state = NULL;
|
animation_state = NULL;
|
||||||
}
|
}
|
||||||
@ -71,28 +68,33 @@ void SpineAnimationState::load_animation_state(Ref<SpineAnimationStateDataResour
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpineAnimationState::reload_animation_state() {
|
void SpineAnimationState::reload_animation_state() {
|
||||||
if(!anim_state_data_res.is_valid())
|
if (!anim_state_data_res.is_valid()) {
|
||||||
{
|
|
||||||
ERR_PRINT(" Reload animation state fail, because anim_state_data_res not set!");
|
ERR_PRINT(" Reload animation state fail, because anim_state_data_res not set!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(animation_state)
|
if (animation_state) {
|
||||||
{
|
|
||||||
delete animation_state;
|
delete animation_state;
|
||||||
animation_state = NULL;
|
animation_state = NULL;
|
||||||
}
|
}
|
||||||
animation_state = new spine::AnimationState(anim_state_data_res->get_animation_state_data());
|
animation_state = new spine::AnimationState(anim_state_data_res->get_animation_state_data());
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_V if(!animation_state){ERR_PRINT("The animation state is not loaded yet!");return;}
|
#define CHECK_V \
|
||||||
#define CHECK_X(x) if(!animation_state){ERR_PRINT("The animation state is not loaded yet!");return x;}
|
if (!animation_state) { \
|
||||||
|
ERR_PRINT("The animation state is not loaded yet!"); \
|
||||||
|
return; \
|
||||||
|
}
|
||||||
|
#define CHECK_X(x) \
|
||||||
|
if (!animation_state) { \
|
||||||
|
ERR_PRINT("The animation state is not loaded yet!"); \
|
||||||
|
return x; \
|
||||||
|
}
|
||||||
#define S_T(x) (spine::String(x.utf8()))
|
#define S_T(x) (spine::String(x.utf8()))
|
||||||
Ref<SpineTrackEntry> SpineAnimationState::set_animation(const String &anim_name, bool loop, uint64_t track) {
|
Ref<SpineTrackEntry> SpineAnimationState::set_animation(const String &anim_name, bool loop, uint64_t track) {
|
||||||
CHECK_X(NULL);
|
CHECK_X(NULL);
|
||||||
auto skeleton_data = anim_state_data_res->get_skeleton();
|
auto skeleton_data = anim_state_data_res->get_skeleton();
|
||||||
auto anim = skeleton_data->find_animation(anim_name);
|
auto anim = skeleton_data->find_animation(anim_name);
|
||||||
if(!anim.is_valid() || anim->get_spine_object() == NULL)
|
if (!anim.is_valid() || anim->get_spine_object() == NULL) {
|
||||||
{
|
|
||||||
ERR_PRINT(String("Can not find animation: ") + anim_name)
|
ERR_PRINT(String("Can not find animation: ") + anim_name)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -105,8 +107,7 @@ Ref<SpineTrackEntry> SpineAnimationState::add_animation(const String &anim_name,
|
|||||||
CHECK_X(NULL);
|
CHECK_X(NULL);
|
||||||
auto skeleton_data = anim_state_data_res->get_skeleton();
|
auto skeleton_data = anim_state_data_res->get_skeleton();
|
||||||
auto anim = skeleton_data->find_animation(anim_name);
|
auto anim = skeleton_data->find_animation(anim_name);
|
||||||
if(!anim.is_valid() || anim->get_spine_object() == NULL)
|
if (!anim.is_valid() || anim->get_spine_object() == NULL) {
|
||||||
{
|
|
||||||
ERR_PRINT(String("Can not find animation: ") + anim_name)
|
ERR_PRINT(String("Can not find animation: ") + anim_name)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -135,11 +136,11 @@ void SpineAnimationState::set_empty_animations(float mix_duration) {
|
|||||||
animation_state->setEmptyAnimations(mix_duration);
|
animation_state->setEmptyAnimations(mix_duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineAnimationState::update(float delta){
|
void SpineAnimationState::update(float delta) {
|
||||||
CHECK_V;
|
CHECK_V;
|
||||||
animation_state->update(delta);
|
animation_state->update(delta);
|
||||||
}
|
}
|
||||||
bool SpineAnimationState::apply(Ref<SpineSkeleton> skeleton){
|
bool SpineAnimationState::apply(Ref<SpineSkeleton> skeleton) {
|
||||||
CHECK_X(false);
|
CHECK_X(false);
|
||||||
return animation_state->apply(*(skeleton->get_spine_object()));
|
return animation_state->apply(*(skeleton->get_spine_object()));
|
||||||
}
|
}
|
||||||
@ -181,7 +182,7 @@ Ref<SpineTrackEntry> SpineAnimationState::get_current(uint64_t track_index) {
|
|||||||
CHECK_X(NULL);
|
CHECK_X(NULL);
|
||||||
Ref<SpineTrackEntry> gd_entry(memnew(SpineTrackEntry));
|
Ref<SpineTrackEntry> gd_entry(memnew(SpineTrackEntry));
|
||||||
auto entry = animation_state->getCurrent(track_index);
|
auto entry = animation_state->getCurrent(track_index);
|
||||||
if(entry == NULL) return NULL;
|
if (entry == NULL) return NULL;
|
||||||
gd_entry->set_spine_object(entry);
|
gd_entry->set_spine_object(entry);
|
||||||
return gd_entry;
|
return gd_entry;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,7 @@
|
|||||||
#include "SpineSkeleton.h"
|
#include "SpineSkeleton.h"
|
||||||
#include "SpineTrackEntry.h"
|
#include "SpineTrackEntry.h"
|
||||||
|
|
||||||
class SpineAnimationState : public Reference{
|
class SpineAnimationState : public Reference {
|
||||||
GDCLASS(SpineAnimationState, Reference);
|
GDCLASS(SpineAnimationState, Reference);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -46,21 +46,22 @@ private:
|
|||||||
spine::AnimationState *animation_state;
|
spine::AnimationState *animation_state;
|
||||||
|
|
||||||
Ref<SpineAnimationStateDataResource> anim_state_data_res;
|
Ref<SpineAnimationStateDataResource> anim_state_data_res;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void load_animation_state(Ref<SpineAnimationStateDataResource> ad);
|
void load_animation_state(Ref<SpineAnimationStateDataResource> ad);
|
||||||
|
|
||||||
inline void set_animation_state(spine::AnimationState *a){
|
inline void set_animation_state(spine::AnimationState *a) {
|
||||||
animation_state = a;
|
animation_state = a;
|
||||||
}
|
}
|
||||||
inline spine::AnimationState *get_animation_state(){
|
inline spine::AnimationState *get_animation_state() {
|
||||||
return animation_state;
|
return animation_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reload_animation_state();
|
void reload_animation_state();
|
||||||
|
|
||||||
Ref<SpineTrackEntry> set_animation(const String &anim_name, bool loop, uint64_t track_id);
|
Ref<SpineTrackEntry> set_animation(const String &anim_name, bool loop, uint64_t track_id);
|
||||||
inline void set_animation_by_ref(Ref<SpineAnimation> anim, bool loop, uint64_t track_id){
|
inline void set_animation_by_ref(Ref<SpineAnimation> anim, bool loop, uint64_t track_id) {
|
||||||
if(anim.is_valid()){
|
if (anim.is_valid()) {
|
||||||
animation_state->setAnimation(track_id, anim->get_spine_object(), loop);
|
animation_state->setAnimation(track_id, anim->get_spine_object(), loop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,4 +91,4 @@ public:
|
|||||||
~SpineAnimationState();
|
~SpineAnimationState();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINEANIMATIONSTATE_H
|
#endif//GODOT_SPINEANIMATIONSTATE_H
|
||||||
|
|||||||
@ -29,12 +29,10 @@
|
|||||||
|
|
||||||
#include "SpineAnimationStateDataResource.h"
|
#include "SpineAnimationStateDataResource.h"
|
||||||
|
|
||||||
SpineAnimationStateDataResource::SpineAnimationStateDataResource():animation_state_data(NULL),animation_state_data_created(false),default_mix(0.5f) {
|
SpineAnimationStateDataResource::SpineAnimationStateDataResource() : animation_state_data(NULL), animation_state_data_created(false), default_mix(0.5f) {
|
||||||
|
|
||||||
}
|
}
|
||||||
SpineAnimationStateDataResource::~SpineAnimationStateDataResource() {
|
SpineAnimationStateDataResource::~SpineAnimationStateDataResource() {
|
||||||
if(animation_state_data)
|
if (animation_state_data) {
|
||||||
{
|
|
||||||
delete animation_state_data;
|
delete animation_state_data;
|
||||||
animation_state_data = NULL;
|
animation_state_data = NULL;
|
||||||
}
|
}
|
||||||
@ -63,27 +61,22 @@ void SpineAnimationStateDataResource::set_skeleton(const Ref<SpineSkeletonDataRe
|
|||||||
skeleton = s;
|
skeleton = s;
|
||||||
|
|
||||||
_on_skeleton_data_changed();
|
_on_skeleton_data_changed();
|
||||||
if(skeleton.is_valid())
|
if (skeleton.is_valid()) {
|
||||||
{
|
|
||||||
skeleton->connect("skeleton_data_loaded", this, "_on_skeleton_data_loaded");
|
skeleton->connect("skeleton_data_loaded", this, "_on_skeleton_data_loaded");
|
||||||
skeleton->connect("atlas_res_changed", this, "_on_skeleton_data_changed");
|
skeleton->connect("atlas_res_changed", this, "_on_skeleton_data_changed");
|
||||||
skeleton->connect("skeleton_json_res_changed", this, "_on_skeleton_data_changed");
|
skeleton->connect("skeleton_json_res_changed", this, "_on_skeleton_data_changed");
|
||||||
|
|
||||||
if(skeleton->is_skeleton_data_loaded())
|
if (skeleton->is_skeleton_data_loaded()) {
|
||||||
{
|
|
||||||
_on_skeleton_data_loaded();
|
_on_skeleton_data_loaded();
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
if(animation_state_data)
|
if (animation_state_data) {
|
||||||
{
|
|
||||||
delete animation_state_data;
|
delete animation_state_data;
|
||||||
animation_state_data = NULL;
|
animation_state_data = NULL;
|
||||||
animation_state_data_created = false;
|
animation_state_data_created = false;
|
||||||
// print_line("Animation state data deleted.");
|
// print_line("Animation state data deleted.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Ref<SpineSkeletonDataResource> SpineAnimationStateDataResource::get_skeleton() {
|
Ref<SpineSkeletonDataResource> SpineAnimationStateDataResource::get_skeleton() {
|
||||||
return skeleton;
|
return skeleton;
|
||||||
@ -91,18 +84,17 @@ Ref<SpineSkeletonDataResource> SpineAnimationStateDataResource::get_skeleton() {
|
|||||||
|
|
||||||
void SpineAnimationStateDataResource::set_default_mix(float m) {
|
void SpineAnimationStateDataResource::set_default_mix(float m) {
|
||||||
default_mix = m;
|
default_mix = m;
|
||||||
if(!is_animation_state_data_created())
|
if (!is_animation_state_data_created()) {
|
||||||
{
|
// ERR_PRINT("'set_default_mix' fail. Animation state data is not created!");
|
||||||
// ERR_PRINT("'set_default_mix' fail. Animation state data is not created!");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
animation_state_data->setDefaultMix(((m >= 0 && m <= 1) ? m : m <= 0 ? 0 : 1));
|
animation_state_data->setDefaultMix(((m >= 0 && m <= 1) ? m : m <= 0 ? 0
|
||||||
// emit_signal("animation_state_data_changed");
|
: 1));
|
||||||
|
// emit_signal("animation_state_data_changed");
|
||||||
}
|
}
|
||||||
float SpineAnimationStateDataResource::get_default_mix() {
|
float SpineAnimationStateDataResource::get_default_mix() {
|
||||||
if(!is_animation_state_data_created())
|
if (!is_animation_state_data_created()) {
|
||||||
{
|
// ERR_PRINT("'get_default_mix' fail. Animation state data is not created!");
|
||||||
// ERR_PRINT("'get_default_mix' fail. Animation state data is not created!");
|
|
||||||
return default_mix;
|
return default_mix;
|
||||||
}
|
}
|
||||||
default_mix = animation_state_data->getDefaultMix();
|
default_mix = animation_state_data->getDefaultMix();
|
||||||
@ -110,40 +102,34 @@ float SpineAnimationStateDataResource::get_default_mix() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpineAnimationStateDataResource::set_mix(const String &from, const String &to, float mix_duration) {
|
void SpineAnimationStateDataResource::set_mix(const String &from, const String &to, float mix_duration) {
|
||||||
if(!is_animation_state_data_created())
|
if (!is_animation_state_data_created()) {
|
||||||
{
|
|
||||||
ERR_PRINT("'set_mix' fail. Animation state data is not created!");
|
ERR_PRINT("'set_mix' fail. Animation state data is not created!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto anim_from = get_skeleton()->find_animation(from);
|
auto anim_from = get_skeleton()->find_animation(from);
|
||||||
auto anim_to = get_skeleton()->find_animation(to);
|
auto anim_to = get_skeleton()->find_animation(to);
|
||||||
if(!anim_from.is_valid())
|
if (!anim_from.is_valid()) {
|
||||||
{
|
|
||||||
ERR_PRINT("'set_mix' fail. From animation animation not found!");
|
ERR_PRINT("'set_mix' fail. From animation animation not found!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!anim_to.is_valid())
|
if (!anim_to.is_valid()) {
|
||||||
{
|
|
||||||
ERR_PRINT("'set_mix' fail. To animation animation not found!");
|
ERR_PRINT("'set_mix' fail. To animation animation not found!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
animation_state_data->setMix(anim_from->get_spine_object(), anim_to->get_spine_object(), mix_duration);
|
animation_state_data->setMix(anim_from->get_spine_object(), anim_to->get_spine_object(), mix_duration);
|
||||||
}
|
}
|
||||||
float SpineAnimationStateDataResource::get_mix(const String &from, const String &to) {
|
float SpineAnimationStateDataResource::get_mix(const String &from, const String &to) {
|
||||||
if(!is_animation_state_data_created())
|
if (!is_animation_state_data_created()) {
|
||||||
{
|
|
||||||
ERR_PRINT("'set_mix' fail. Animation state data is not created!");
|
ERR_PRINT("'set_mix' fail. Animation state data is not created!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
auto anim_from = get_skeleton()->find_animation(from);
|
auto anim_from = get_skeleton()->find_animation(from);
|
||||||
auto anim_to = get_skeleton()->find_animation(to);
|
auto anim_to = get_skeleton()->find_animation(to);
|
||||||
if(!anim_from.is_valid())
|
if (!anim_from.is_valid()) {
|
||||||
{
|
|
||||||
ERR_PRINT("'set_mix' fail. From animation animation not found!");
|
ERR_PRINT("'set_mix' fail. From animation animation not found!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(!anim_to.is_valid())
|
if (!anim_to.is_valid()) {
|
||||||
{
|
|
||||||
ERR_PRINT("'set_mix' fail. To animation animation not found!");
|
ERR_PRINT("'set_mix' fail. To animation animation not found!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -152,7 +138,7 @@ float SpineAnimationStateDataResource::get_mix(const String &from, const String
|
|||||||
|
|
||||||
void SpineAnimationStateDataResource::_on_skeleton_data_loaded() {
|
void SpineAnimationStateDataResource::_on_skeleton_data_loaded() {
|
||||||
animation_state_data = new spine::AnimationStateData(skeleton->get_skeleton_data());
|
animation_state_data = new spine::AnimationStateData(skeleton->get_skeleton_data());
|
||||||
// print_line("Animation state data created.");
|
// print_line("Animation state data created.");
|
||||||
|
|
||||||
|
|
||||||
emit_signal("animation_state_data_created");
|
emit_signal("animation_state_data_created");
|
||||||
@ -162,17 +148,16 @@ void SpineAnimationStateDataResource::_on_skeleton_data_loaded() {
|
|||||||
|
|
||||||
void SpineAnimationStateDataResource::_on_skeleton_data_changed() {
|
void SpineAnimationStateDataResource::_on_skeleton_data_changed() {
|
||||||
animation_state_data_created = false;
|
animation_state_data_created = false;
|
||||||
if(animation_state_data)
|
if (animation_state_data) {
|
||||||
{
|
|
||||||
delete animation_state_data;
|
delete animation_state_data;
|
||||||
animation_state_data = NULL;
|
animation_state_data = NULL;
|
||||||
// print_line("Animation state data deleted.");
|
// print_line("Animation state data deleted.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// print_line("skeleton_data_res_changed emitted");
|
// print_line("skeleton_data_res_changed emitted");
|
||||||
emit_signal("skeleton_data_res_changed");
|
emit_signal("skeleton_data_res_changed");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineAnimationStateDataResource::is_animation_state_data_created(){
|
bool SpineAnimationStateDataResource::is_animation_state_data_created() {
|
||||||
return animation_state_data_created;
|
return animation_state_data_created;
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
#include "SpineSkeletonDataResource.h"
|
#include "SpineSkeletonDataResource.h"
|
||||||
|
|
||||||
class SpineAnimationStateDataResource : public Resource{
|
class SpineAnimationStateDataResource : public Resource {
|
||||||
GDCLASS(SpineAnimationStateDataResource, Resource);
|
GDCLASS(SpineAnimationStateDataResource, Resource);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -48,12 +48,12 @@ private:
|
|||||||
bool animation_state_data_created;
|
bool animation_state_data_created;
|
||||||
|
|
||||||
float default_mix;
|
float default_mix;
|
||||||
public:
|
|
||||||
|
|
||||||
|
public:
|
||||||
void set_skeleton(const Ref<SpineSkeletonDataResource> &s);
|
void set_skeleton(const Ref<SpineSkeletonDataResource> &s);
|
||||||
Ref<SpineSkeletonDataResource> get_skeleton();
|
Ref<SpineSkeletonDataResource> get_skeleton();
|
||||||
|
|
||||||
inline spine::AnimationStateData *get_animation_state_data(){
|
inline spine::AnimationStateData *get_animation_state_data() {
|
||||||
return animation_state_data;
|
return animation_state_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,4 +73,4 @@ public:
|
|||||||
~SpineAnimationStateDataResource();
|
~SpineAnimationStateDataResource();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINEANIMATIONSTATEDATARESOURCE_H
|
#endif//GODOT_SPINEANIMATIONSTATEDATARESOURCE_H
|
||||||
|
|||||||
@ -34,78 +34,74 @@
|
|||||||
|
|
||||||
class GodotSpineTextureLoader : public spine::TextureLoader {
|
class GodotSpineTextureLoader : public spine::TextureLoader {
|
||||||
private:
|
private:
|
||||||
Array *tex_list, *ntex_list;
|
Array *textures, *normal_maps;
|
||||||
String normal_tex_prefix;
|
String normal_maps_prefix;
|
||||||
public:
|
|
||||||
|
|
||||||
GodotSpineTextureLoader(Array *t, Array *nt, const String &p):tex_list(t), ntex_list(nt), normal_tex_prefix(p){
|
public:
|
||||||
if (tex_list) tex_list->clear();
|
GodotSpineTextureLoader(Array *t, Array *nt, const String &p) : textures(t), normal_maps(nt), normal_maps_prefix(p) {
|
||||||
if (ntex_list) ntex_list->clear();
|
if (textures) textures->clear();
|
||||||
|
if (normal_maps) normal_maps->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
String fixPathIssue(const String &path){
|
String fixPathIssue(const String &path) {
|
||||||
if(path.size() > 5 && path[4] == '/' && path[5] == '/') return path;
|
if (path.size() > 5 && path[4] == '/' && path[5] == '/') return path;
|
||||||
const String prefix = "res:/";
|
const String prefix = "res:/";
|
||||||
auto i = path.find(prefix);
|
auto i = path.find(prefix);
|
||||||
// print_line(String("Found i at ") + String(Variant(i)));
|
auto sub_str_pos = i + prefix.size() - 1;
|
||||||
auto sub_str_pos = i+prefix.size()-1;
|
if (sub_str_pos < 0) return path;
|
||||||
if(sub_str_pos < 0) return path;
|
|
||||||
auto res = path.substr(sub_str_pos);
|
auto res = path.substr(sub_str_pos);
|
||||||
// print_line(String("rest of it: ") + res);
|
|
||||||
if(res.size() > 0)
|
if (res.size() > 0) {
|
||||||
{
|
if (res[0] != '/') {
|
||||||
if(res[0] != '/')
|
|
||||||
{
|
|
||||||
return prefix + "/" + res;
|
return prefix + "/" + res;
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
return prefix + res;
|
return prefix + res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void load(spine::AtlasPage &page, const spine::String &path){
|
virtual void load(spine::AtlasPage &page, const spine::String &path) {
|
||||||
Error err = OK;
|
Error err = OK;
|
||||||
|
|
||||||
// print_line(String("Spine is loading texture: ") + String(path.buffer()));
|
// print_line(String("Spine is loading texture: ") + String(path.buffer()));
|
||||||
auto fixed_path = fixPathIssue(String(path.buffer()));
|
auto fixed_path = fixPathIssue(String(path.buffer()));
|
||||||
// print_line("Fixed path: " + fixed_path);
|
// print_line("Fixed path: " + fixed_path);
|
||||||
|
|
||||||
// Load texture (e.g. tex.png)
|
// Load texture (e.g. tex.png)
|
||||||
Ref<Texture> tex = ResourceLoader::load(fixed_path, "", false, &err);
|
Ref<Texture> tex = ResourceLoader::load(fixed_path, "", false, &err);
|
||||||
if (err != OK) {
|
if (err != OK) {
|
||||||
print_error(vformat("Can't load texture: \"%s\"", String(path.buffer())));
|
print_error(vformat("Can't load texture: \"%s\"", String(path.buffer())));
|
||||||
page.setRendererObject((void*)memnew(SpineRendererObject {nullptr}));
|
page.setRendererObject((void *) memnew(SpineRendererObject{nullptr}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tex_list) tex_list->append(tex);
|
if (textures) textures->append(tex);
|
||||||
auto p_spine_renderer_object = memnew(SpineRendererObject);
|
auto p_spine_renderer_object = memnew(SpineRendererObject);
|
||||||
p_spine_renderer_object->tex = tex;
|
p_spine_renderer_object->tex = tex;
|
||||||
|
|
||||||
// Load normal texture (e.g. n_tex.png)
|
// Load normal texture (e.g. n_tex.png)
|
||||||
String temppath = fixed_path;
|
String temppath = fixed_path;
|
||||||
String newpath = vformat("%s/%s_%s", temppath.get_base_dir(), normal_tex_prefix, temppath.get_file());
|
String newpath = vformat("%s/%s_%s", temppath.get_base_dir(), normal_maps_prefix, temppath.get_file());
|
||||||
// print_line(vformat("try n tex: %s", newpath));
|
// print_line(vformat("try n tex: %s", newpath));
|
||||||
if (ResourceLoader::exists(newpath)){
|
if (ResourceLoader::exists(newpath)) {
|
||||||
Ref<Texture> normal_tex = ResourceLoader::load(newpath);
|
Ref<Texture> normal_tex = ResourceLoader::load(newpath);
|
||||||
if (ntex_list) ntex_list->append(normal_tex);
|
if (normal_maps) normal_maps->append(normal_tex);
|
||||||
p_spine_renderer_object->normal_tex = normal_tex;
|
p_spine_renderer_object->normal_tex = normal_tex;
|
||||||
|
|
||||||
// print_line(String("From atlas resource load: ") + String(" ro ") + String(Variant((long long) p_spine_renderer_object)));
|
// print_line(String("From atlas resource load: ") + String(" ro ") + String(Variant((long long) p_spine_renderer_object)));
|
||||||
// print_line(String("From atlas resource load: ") + String(Variant(p_spine_renderer_object->tex)) + String(", ") + String(Variant(p_spine_renderer_object->normal_tex)));
|
// print_line(String("From atlas resource load: ") + String(Variant(p_spine_renderer_object->tex)) + String(", ") + String(Variant(p_spine_renderer_object->normal_tex)));
|
||||||
}
|
}
|
||||||
|
|
||||||
page.setRendererObject((void*)p_spine_renderer_object);
|
page.setRendererObject((void *) p_spine_renderer_object);
|
||||||
|
|
||||||
page.width = tex->get_width();
|
page.width = tex->get_width();
|
||||||
page.height = tex->get_height();
|
page.height = tex->get_height();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void unload(void *p){
|
virtual void unload(void *p) {
|
||||||
// print_line("I'm out.");
|
// print_line("I'm out.");
|
||||||
auto p_spine_renderer_object = (SpineRendererObject*) p;
|
auto p_spine_renderer_object = (SpineRendererObject *) p;
|
||||||
Ref<Texture> &tex = p_spine_renderer_object->tex;
|
Ref<Texture> &tex = p_spine_renderer_object->tex;
|
||||||
Ref<Texture> &normal_tex = p_spine_renderer_object->normal_tex;
|
Ref<Texture> &normal_tex = p_spine_renderer_object->normal_tex;
|
||||||
|
|
||||||
@ -116,12 +112,12 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SpineAtlasResource::SpineAtlasResource():atlas(nullptr), normal_texture_prefix("n"){}
|
SpineAtlasResource::SpineAtlasResource() : atlas(nullptr), normal_texture_prefix("n") {}
|
||||||
SpineAtlasResource::~SpineAtlasResource(){
|
SpineAtlasResource::~SpineAtlasResource() {
|
||||||
if (atlas) delete atlas;
|
if (atlas) delete atlas;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineAtlasResource::_bind_methods(){
|
void SpineAtlasResource::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("load_from_atlas_file", "path"), &SpineAtlasResource::load_from_atlas_file);
|
ClassDB::bind_method(D_METHOD("load_from_atlas_file", "path"), &SpineAtlasResource::load_from_atlas_file);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_source_path"), &SpineAtlasResource::get_source_path);
|
ClassDB::bind_method(D_METHOD("get_source_path"), &SpineAtlasResource::get_source_path);
|
||||||
@ -148,7 +144,7 @@ String SpineAtlasResource::get_source_path() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Error SpineAtlasResource::load_from_atlas_file(const String &p_path) {
|
Error SpineAtlasResource::load_from_atlas_file(const String &p_path) {
|
||||||
// print_line(vformat("Importing atlas file: %s", p_path));
|
// print_line(vformat("Importing atlas file: %s", p_path));
|
||||||
source_path = p_path;
|
source_path = p_path;
|
||||||
|
|
||||||
Error err;
|
Error err;
|
||||||
@ -161,7 +157,7 @@ Error SpineAtlasResource::load_from_atlas_file(const String &p_path) {
|
|||||||
ntex_list.clear();
|
ntex_list.clear();
|
||||||
atlas = new spine::Atlas(atlas_data.utf8(), atlas_data.size(), source_path.get_base_dir().utf8(), new GodotSpineTextureLoader(&tex_list, &ntex_list, normal_texture_prefix));
|
atlas = new spine::Atlas(atlas_data.utf8(), atlas_data.size(), source_path.get_base_dir().utf8(), new GodotSpineTextureLoader(&tex_list, &ntex_list, normal_texture_prefix));
|
||||||
|
|
||||||
// print_line(vformat("atlas loaded!"));
|
// print_line(vformat("atlas loaded!"));
|
||||||
|
|
||||||
if (atlas)
|
if (atlas)
|
||||||
return OK;
|
return OK;
|
||||||
@ -210,7 +206,7 @@ Error SpineAtlasResource::save_to_file(const String &p_path) {
|
|||||||
Error err;
|
Error err;
|
||||||
FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err);
|
FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err);
|
||||||
if (err != OK) {
|
if (err != OK) {
|
||||||
// print_line(vformat("save file err: %d", err));
|
// print_line(vformat("save file err: %d", err));
|
||||||
if (file) file->close();
|
if (file) file->close();
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -220,7 +216,7 @@ Error SpineAtlasResource::save_to_file(const String &p_path) {
|
|||||||
content["atlas_data"] = atlas_data;
|
content["atlas_data"] = atlas_data;
|
||||||
content["normal_texture_prefix"] = normal_texture_prefix;
|
content["normal_texture_prefix"] = normal_texture_prefix;
|
||||||
|
|
||||||
// print_line(vformat("storing source_path: %s", source_path));
|
// print_line(vformat("storing source_path: %s", source_path));
|
||||||
|
|
||||||
file->store_string(JSON::print(content));
|
file->store_string(JSON::print(content));
|
||||||
file->close();
|
file->close();
|
||||||
|
|||||||
@ -31,7 +31,6 @@
|
|||||||
#define GODOT_SPINEATLASRESOURCE_H
|
#define GODOT_SPINEATLASRESOURCE_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "core/variant_parser.h"
|
#include "core/variant_parser.h"
|
||||||
|
|
||||||
#include <spine/SpineString.h>
|
#include <spine/SpineString.h>
|
||||||
@ -41,7 +40,7 @@
|
|||||||
#include <core/io/image_loader.h>
|
#include <core/io/image_loader.h>
|
||||||
#include "SpineRendererObject.h"
|
#include "SpineRendererObject.h"
|
||||||
|
|
||||||
class SpineAtlasResource : public Resource{
|
class SpineAtlasResource : public Resource {
|
||||||
GDCLASS(SpineAtlasResource, Resource);
|
GDCLASS(SpineAtlasResource, Resource);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -55,16 +54,17 @@ protected:
|
|||||||
|
|
||||||
Array tex_list;
|
Array tex_list;
|
||||||
Array ntex_list;
|
Array ntex_list;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline String &get_atlas_data() {return atlas_data;}
|
inline String &get_atlas_data() { return atlas_data; }
|
||||||
|
|
||||||
inline spine::Atlas *get_spine_atlas() {return atlas;}
|
inline spine::Atlas *get_spine_atlas() { return atlas; }
|
||||||
|
|
||||||
inline void set_normal_texture_prefix(const String &p) {normal_texture_prefix = p;}
|
inline void set_normal_texture_prefix(const String &p) { normal_texture_prefix = p; }
|
||||||
|
|
||||||
Error load_from_atlas_file(const String &p_path); // .atlas
|
Error load_from_atlas_file(const String &p_path);// .atlas
|
||||||
|
|
||||||
Error load_from_file(const String &p_path); // .spatlas
|
Error load_from_file(const String &p_path);// .spatlas
|
||||||
Error save_to_file(const String &p_path); // .spatlas
|
Error save_to_file(const String &p_path); // .spatlas
|
||||||
|
|
||||||
String get_source_path();
|
String get_source_path();
|
||||||
@ -76,4 +76,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //GODOT_SPINEATLASRESOURCE_H
|
#endif//GODOT_SPINEATLASRESOURCE_H
|
||||||
|
|||||||
@ -34,21 +34,21 @@ void SpineAttachment::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("copy"), &SpineAttachment::copy);
|
ClassDB::bind_method(D_METHOD("copy"), &SpineAttachment::copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineAttachment::SpineAttachment():attachment(NULL) {}
|
SpineAttachment::SpineAttachment() : attachment(NULL) {}
|
||||||
SpineAttachment::~SpineAttachment() {
|
SpineAttachment::~SpineAttachment() {
|
||||||
if(attachment){
|
if (attachment) {
|
||||||
attachment->dereference();
|
attachment->dereference();
|
||||||
attachment = NULL;
|
attachment = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String SpineAttachment::get_attachment_name(){
|
String SpineAttachment::get_attachment_name() {
|
||||||
return attachment->getName().buffer();
|
return attachment->getName().buffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineAttachment> SpineAttachment::copy(){
|
Ref<SpineAttachment> SpineAttachment::copy() {
|
||||||
auto a = attachment->copy();
|
auto a = attachment->copy();
|
||||||
if(a == NULL) return NULL;
|
if (a == NULL) return NULL;
|
||||||
Ref<SpineAttachment> gd_attachment(memnew(SpineAttachment));
|
Ref<SpineAttachment> gd_attachment(memnew(SpineAttachment));
|
||||||
gd_attachment->set_spine_object(a);
|
gd_attachment->set_spine_object(a);
|
||||||
return gd_attachment;
|
return gd_attachment;
|
||||||
|
|||||||
@ -47,12 +47,12 @@ public:
|
|||||||
SpineAttachment();
|
SpineAttachment();
|
||||||
~SpineAttachment();
|
~SpineAttachment();
|
||||||
|
|
||||||
inline void set_spine_object(spine::Attachment *a){
|
inline void set_spine_object(spine::Attachment *a) {
|
||||||
attachment = a;
|
attachment = a;
|
||||||
if(attachment)
|
if (attachment)
|
||||||
attachment->reference();
|
attachment->reference();
|
||||||
}
|
}
|
||||||
inline spine::Attachment *get_spine_object(){
|
inline spine::Attachment *get_spine_object() {
|
||||||
return attachment;
|
return attachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,4 +61,4 @@ public:
|
|||||||
Ref<SpineAttachment> copy();
|
Ref<SpineAttachment> copy();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINEATTACHMENT_H
|
#endif//GODOT_SPINEATTACHMENT_H
|
||||||
|
|||||||
@ -34,52 +34,52 @@
|
|||||||
|
|
||||||
void SpineBone::_bind_methods() {
|
void SpineBone::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("update_world_transform"), &SpineBone::update_world_transform);
|
ClassDB::bind_method(D_METHOD("update_world_transform"), &SpineBone::update_world_transform);
|
||||||
// void set_to_setup_pose();
|
// void set_to_setup_pose();
|
||||||
//
|
//
|
||||||
// Vector2 world_to_local(Vector2 world_position);
|
// Vector2 world_to_local(Vector2 world_position);
|
||||||
//
|
//
|
||||||
// Vector2 local_to_world(Vector2 local_position);
|
// Vector2 local_to_world(Vector2 local_position);
|
||||||
//
|
//
|
||||||
// float world_to_local_rotation(float world_rotation);
|
// float world_to_local_rotation(float world_rotation);
|
||||||
//
|
//
|
||||||
// float local_to_world_rotation(float local_rotation);
|
// float local_to_world_rotation(float local_rotation);
|
||||||
//
|
//
|
||||||
// void rotate_world(float degrees);
|
// void rotate_world(float degrees);
|
||||||
ClassDB::bind_method(D_METHOD("set_to_setup_pose"), &SpineBone::set_to_setup_pose);
|
ClassDB::bind_method(D_METHOD("set_to_setup_pose"), &SpineBone::set_to_setup_pose);
|
||||||
ClassDB::bind_method(D_METHOD("world_to_local", "world_position"), &SpineBone::world_to_local);
|
ClassDB::bind_method(D_METHOD("world_to_local", "world_position"), &SpineBone::world_to_local);
|
||||||
ClassDB::bind_method(D_METHOD("local_to_world", "local_position"), &SpineBone::local_to_world);
|
ClassDB::bind_method(D_METHOD("local_to_world", "local_position"), &SpineBone::local_to_world);
|
||||||
ClassDB::bind_method(D_METHOD("world_to_local_rotation", "world_rotation"), &SpineBone::world_to_local_rotation);
|
ClassDB::bind_method(D_METHOD("world_to_local_rotation", "world_rotation"), &SpineBone::world_to_local_rotation);
|
||||||
ClassDB::bind_method(D_METHOD("local_to_world_rotation", "local_rotation"), &SpineBone::local_to_world_rotation);
|
ClassDB::bind_method(D_METHOD("local_to_world_rotation", "local_rotation"), &SpineBone::local_to_world_rotation);
|
||||||
ClassDB::bind_method(D_METHOD("rotate_world"), &SpineBone::rotate_world);
|
ClassDB::bind_method(D_METHOD("rotate_world"), &SpineBone::rotate_world);
|
||||||
//
|
//
|
||||||
// float get_world_to_local_rotation_x();
|
// float get_world_to_local_rotation_x();
|
||||||
// float get_world_to_local_rotation_y();
|
// float get_world_to_local_rotation_y();
|
||||||
//
|
//
|
||||||
// Ref<SpineBoneData> get_data();
|
// Ref<SpineBoneData> get_data();
|
||||||
//
|
//
|
||||||
// Ref<SpineSkeleton> get_skeleton();
|
// Ref<SpineSkeleton> get_skeleton();
|
||||||
//
|
//
|
||||||
// Ref<SpineBone> get_parent();
|
// Ref<SpineBone> get_parent();
|
||||||
//
|
//
|
||||||
// Array get_children();
|
// Array get_children();
|
||||||
ClassDB::bind_method(D_METHOD("get_world_to_local_rotation_x"), &SpineBone::get_world_to_local_rotation_x);
|
ClassDB::bind_method(D_METHOD("get_world_to_local_rotation_x"), &SpineBone::get_world_to_local_rotation_x);
|
||||||
ClassDB::bind_method(D_METHOD("get_world_to_local_rotation_y"), &SpineBone::get_world_to_local_rotation_y);
|
ClassDB::bind_method(D_METHOD("get_world_to_local_rotation_y"), &SpineBone::get_world_to_local_rotation_y);
|
||||||
ClassDB::bind_method(D_METHOD("get_data"), &SpineBone::get_data);
|
ClassDB::bind_method(D_METHOD("get_data"), &SpineBone::get_data);
|
||||||
ClassDB::bind_method(D_METHOD("get_skeleton"), &SpineBone::get_skeleton);
|
ClassDB::bind_method(D_METHOD("get_skeleton"), &SpineBone::get_skeleton);
|
||||||
ClassDB::bind_method(D_METHOD("get_parent"), &SpineBone::get_parent);
|
ClassDB::bind_method(D_METHOD("get_parent"), &SpineBone::get_parent);
|
||||||
ClassDB::bind_method(D_METHOD("get_children"), &SpineBone::get_children);
|
ClassDB::bind_method(D_METHOD("get_children"), &SpineBone::get_children);
|
||||||
//
|
//
|
||||||
// float get_x();
|
// float get_x();
|
||||||
// void set_x(float v);
|
// void set_x(float v);
|
||||||
//
|
//
|
||||||
// float get_y();
|
// float get_y();
|
||||||
// void set_y(float v);
|
// void set_y(float v);
|
||||||
//
|
//
|
||||||
// float get_rotation();
|
// float get_rotation();
|
||||||
// void set_rotation(float v);
|
// void set_rotation(float v);
|
||||||
//
|
//
|
||||||
// float get_scale_x();
|
// float get_scale_x();
|
||||||
// void set_scale_x(float v);
|
// void set_scale_x(float v);
|
||||||
ClassDB::bind_method(D_METHOD("get_x"), &SpineBone::get_x);
|
ClassDB::bind_method(D_METHOD("get_x"), &SpineBone::get_x);
|
||||||
ClassDB::bind_method(D_METHOD("set_x", "v"), &SpineBone::set_x);
|
ClassDB::bind_method(D_METHOD("set_x", "v"), &SpineBone::set_x);
|
||||||
ClassDB::bind_method(D_METHOD("get_y"), &SpineBone::get_y);
|
ClassDB::bind_method(D_METHOD("get_y"), &SpineBone::get_y);
|
||||||
@ -88,18 +88,18 @@ void SpineBone::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_rotation", "v"), &SpineBone::set_rotation);
|
ClassDB::bind_method(D_METHOD("set_rotation", "v"), &SpineBone::set_rotation);
|
||||||
ClassDB::bind_method(D_METHOD("get_scale_x"), &SpineBone::get_scale_x);
|
ClassDB::bind_method(D_METHOD("get_scale_x"), &SpineBone::get_scale_x);
|
||||||
ClassDB::bind_method(D_METHOD("set_scale_x", "v"), &SpineBone::set_scale_x);
|
ClassDB::bind_method(D_METHOD("set_scale_x", "v"), &SpineBone::set_scale_x);
|
||||||
//
|
//
|
||||||
// float get_scale_y();
|
// float get_scale_y();
|
||||||
// void set_scale_y(float v);
|
// void set_scale_y(float v);
|
||||||
//
|
//
|
||||||
// float get_shear_x();
|
// float get_shear_x();
|
||||||
// void set_shear_x(float v);
|
// void set_shear_x(float v);
|
||||||
//
|
//
|
||||||
// float get_shear_y();
|
// float get_shear_y();
|
||||||
// void set_shear_y(float v);
|
// void set_shear_y(float v);
|
||||||
//
|
//
|
||||||
// float get_applied_rotation();
|
// float get_applied_rotation();
|
||||||
// void set_applied_rotation(float v);
|
// void set_applied_rotation(float v);
|
||||||
ClassDB::bind_method(D_METHOD("get_scale_y"), &SpineBone::get_scale_y);
|
ClassDB::bind_method(D_METHOD("get_scale_y"), &SpineBone::get_scale_y);
|
||||||
ClassDB::bind_method(D_METHOD("set_scale_y", "v"), &SpineBone::set_scale_y);
|
ClassDB::bind_method(D_METHOD("set_scale_y", "v"), &SpineBone::set_scale_y);
|
||||||
ClassDB::bind_method(D_METHOD("get_shear_x"), &SpineBone::get_shear_x);
|
ClassDB::bind_method(D_METHOD("get_shear_x"), &SpineBone::get_shear_x);
|
||||||
@ -108,18 +108,18 @@ void SpineBone::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_shear_y", "v"), &SpineBone::set_shear_y);
|
ClassDB::bind_method(D_METHOD("set_shear_y", "v"), &SpineBone::set_shear_y);
|
||||||
ClassDB::bind_method(D_METHOD("get_applied_rotation"), &SpineBone::get_applied_rotation);
|
ClassDB::bind_method(D_METHOD("get_applied_rotation"), &SpineBone::get_applied_rotation);
|
||||||
ClassDB::bind_method(D_METHOD("set_applied_rotation", "v"), &SpineBone::set_applied_rotation);
|
ClassDB::bind_method(D_METHOD("set_applied_rotation", "v"), &SpineBone::set_applied_rotation);
|
||||||
//
|
//
|
||||||
// float get_a_x();
|
// float get_a_x();
|
||||||
// void set_a_x(float v);
|
// void set_a_x(float v);
|
||||||
//
|
//
|
||||||
// float get_a_y();
|
// float get_a_y();
|
||||||
// void set_a_y(float v);
|
// void set_a_y(float v);
|
||||||
//
|
//
|
||||||
// float get_a_scale_x();
|
// float get_a_scale_x();
|
||||||
// void set_a_scale_x(float v);
|
// void set_a_scale_x(float v);
|
||||||
//
|
//
|
||||||
// float get_a_scale_y();
|
// float get_a_scale_y();
|
||||||
// void set_a_scale_y(float v);
|
// void set_a_scale_y(float v);
|
||||||
ClassDB::bind_method(D_METHOD("get_a_x"), &SpineBone::get_a_x);
|
ClassDB::bind_method(D_METHOD("get_a_x"), &SpineBone::get_a_x);
|
||||||
ClassDB::bind_method(D_METHOD("set_a_x", "v"), &SpineBone::set_a_x);
|
ClassDB::bind_method(D_METHOD("set_a_x", "v"), &SpineBone::set_a_x);
|
||||||
ClassDB::bind_method(D_METHOD("get_a_y"), &SpineBone::get_a_y);
|
ClassDB::bind_method(D_METHOD("get_a_y"), &SpineBone::get_a_y);
|
||||||
@ -128,18 +128,18 @@ void SpineBone::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_a_scale_x", "v"), &SpineBone::set_a_scale_x);
|
ClassDB::bind_method(D_METHOD("set_a_scale_x", "v"), &SpineBone::set_a_scale_x);
|
||||||
ClassDB::bind_method(D_METHOD("get_a_scale_y"), &SpineBone::get_a_scale_y);
|
ClassDB::bind_method(D_METHOD("get_a_scale_y"), &SpineBone::get_a_scale_y);
|
||||||
ClassDB::bind_method(D_METHOD("set_a_scale_y", "v"), &SpineBone::set_a_scale_y);
|
ClassDB::bind_method(D_METHOD("set_a_scale_y", "v"), &SpineBone::set_a_scale_y);
|
||||||
//
|
//
|
||||||
// float get_a_shear_x();
|
// float get_a_shear_x();
|
||||||
// void set_a_shear_x(float v);
|
// void set_a_shear_x(float v);
|
||||||
//
|
//
|
||||||
// float get_a_shear_y();
|
// float get_a_shear_y();
|
||||||
// void set_a_shear_y(float v);
|
// void set_a_shear_y(float v);
|
||||||
//
|
//
|
||||||
// float get_a();
|
// float get_a();
|
||||||
// void set_a(float v);
|
// void set_a(float v);
|
||||||
//
|
//
|
||||||
// float get_b();
|
// float get_b();
|
||||||
// void set_b(float v);
|
// void set_b(float v);
|
||||||
ClassDB::bind_method(D_METHOD("get_a_shear_x"), &SpineBone::get_a_shear_x);
|
ClassDB::bind_method(D_METHOD("get_a_shear_x"), &SpineBone::get_a_shear_x);
|
||||||
ClassDB::bind_method(D_METHOD("set_a_shear_x", "v"), &SpineBone::set_a_shear_x);
|
ClassDB::bind_method(D_METHOD("set_a_shear_x", "v"), &SpineBone::set_a_shear_x);
|
||||||
ClassDB::bind_method(D_METHOD("get_a_shear_y"), &SpineBone::get_a_shear_y);
|
ClassDB::bind_method(D_METHOD("get_a_shear_y"), &SpineBone::get_a_shear_y);
|
||||||
@ -148,18 +148,18 @@ void SpineBone::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_a", "v"), &SpineBone::set_a);
|
ClassDB::bind_method(D_METHOD("set_a", "v"), &SpineBone::set_a);
|
||||||
ClassDB::bind_method(D_METHOD("get_b"), &SpineBone::get_b);
|
ClassDB::bind_method(D_METHOD("get_b"), &SpineBone::get_b);
|
||||||
ClassDB::bind_method(D_METHOD("set_b", "v"), &SpineBone::set_b);
|
ClassDB::bind_method(D_METHOD("set_b", "v"), &SpineBone::set_b);
|
||||||
//
|
//
|
||||||
// float get_c();
|
// float get_c();
|
||||||
// void set_c(float v);
|
// void set_c(float v);
|
||||||
//
|
//
|
||||||
// float get_d();
|
// float get_d();
|
||||||
// void set_d(float v);
|
// void set_d(float v);
|
||||||
//
|
//
|
||||||
// float get_world_x();
|
// float get_world_x();
|
||||||
// void set_world_x(float v);
|
// void set_world_x(float v);
|
||||||
//
|
//
|
||||||
// float get_world_y();
|
// float get_world_y();
|
||||||
// void set_world_y(float v);
|
// void set_world_y(float v);
|
||||||
ClassDB::bind_method(D_METHOD("get_c"), &SpineBone::get_c);
|
ClassDB::bind_method(D_METHOD("get_c"), &SpineBone::get_c);
|
||||||
ClassDB::bind_method(D_METHOD("set_c", "v"), &SpineBone::set_c);
|
ClassDB::bind_method(D_METHOD("set_c", "v"), &SpineBone::set_c);
|
||||||
ClassDB::bind_method(D_METHOD("get_d"), &SpineBone::get_d);
|
ClassDB::bind_method(D_METHOD("get_d"), &SpineBone::get_d);
|
||||||
@ -168,18 +168,18 @@ void SpineBone::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_world_x", "v"), &SpineBone::set_world_x);
|
ClassDB::bind_method(D_METHOD("set_world_x", "v"), &SpineBone::set_world_x);
|
||||||
ClassDB::bind_method(D_METHOD("get_world_y"), &SpineBone::get_world_y);
|
ClassDB::bind_method(D_METHOD("get_world_y"), &SpineBone::get_world_y);
|
||||||
ClassDB::bind_method(D_METHOD("set_world_y", "v"), &SpineBone::set_world_y);
|
ClassDB::bind_method(D_METHOD("set_world_y", "v"), &SpineBone::set_world_y);
|
||||||
//
|
//
|
||||||
// float get_world_rotation_x();
|
// float get_world_rotation_x();
|
||||||
// float get_world_rotation_y();
|
// float get_world_rotation_y();
|
||||||
//
|
//
|
||||||
// float get_world_scale_x();
|
// float get_world_scale_x();
|
||||||
// float get_world_scale_y();
|
// float get_world_scale_y();
|
||||||
//
|
//
|
||||||
// bool is_applied_valid();
|
// bool is_applied_valid();
|
||||||
// void set_applied_valid(bool v);
|
// void set_applied_valid(bool v);
|
||||||
//
|
//
|
||||||
// bool is_active();
|
// bool is_active();
|
||||||
// void set_active(bool v);
|
// void set_active(bool v);
|
||||||
ClassDB::bind_method(D_METHOD("get_world_rotation_x"), &SpineBone::get_world_rotation_x);
|
ClassDB::bind_method(D_METHOD("get_world_rotation_x"), &SpineBone::get_world_rotation_x);
|
||||||
ClassDB::bind_method(D_METHOD("get_world_rotation_y"), &SpineBone::get_world_rotation_y);
|
ClassDB::bind_method(D_METHOD("get_world_rotation_y"), &SpineBone::get_world_rotation_y);
|
||||||
ClassDB::bind_method(D_METHOD("get_world_scale_x"), &SpineBone::get_world_scale_x);
|
ClassDB::bind_method(D_METHOD("get_world_scale_x"), &SpineBone::get_world_scale_x);
|
||||||
@ -195,56 +195,56 @@ void SpineBone::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("apply_world_transform_2d", "node2d"), &SpineBone::apply_world_transform_2d);
|
ClassDB::bind_method(D_METHOD("apply_world_transform_2d", "node2d"), &SpineBone::apply_world_transform_2d);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineBone::SpineBone():bone(NULL), the_sprite(nullptr) {}
|
SpineBone::SpineBone() : bone(NULL), the_sprite(nullptr) {}
|
||||||
SpineBone::~SpineBone() {}
|
SpineBone::~SpineBone() {}
|
||||||
|
|
||||||
void SpineBone::update_world_transform(){
|
void SpineBone::update_world_transform() {
|
||||||
bone->updateWorldTransform();
|
bone->updateWorldTransform();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineBone::set_to_setup_pose(){
|
void SpineBone::set_to_setup_pose() {
|
||||||
bone->setToSetupPose();
|
bone->setToSetupPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 SpineBone::world_to_local(Vector2 world_position){
|
Vector2 SpineBone::world_to_local(Vector2 world_position) {
|
||||||
float x, y;
|
float x, y;
|
||||||
bone->worldToLocal(world_position.x, world_position.y, x, y);
|
bone->worldToLocal(world_position.x, world_position.y, x, y);
|
||||||
return Vector2(x, y);
|
return Vector2(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 SpineBone::local_to_world(Vector2 local_position){
|
Vector2 SpineBone::local_to_world(Vector2 local_position) {
|
||||||
float x, y;
|
float x, y;
|
||||||
bone->localToWorld(local_position.x, local_position.y, x, y);
|
bone->localToWorld(local_position.x, local_position.y, x, y);
|
||||||
return Vector2(x, y);
|
return Vector2(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::world_to_local_rotation(float world_rotation){
|
float SpineBone::world_to_local_rotation(float world_rotation) {
|
||||||
return bone->worldToLocalRotation(world_rotation);
|
return bone->worldToLocalRotation(world_rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::local_to_world_rotation(float local_rotation){
|
float SpineBone::local_to_world_rotation(float local_rotation) {
|
||||||
return bone->localToWorldRotation(local_rotation);
|
return bone->localToWorldRotation(local_rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineBone::rotate_world(float degrees){
|
void SpineBone::rotate_world(float degrees) {
|
||||||
bone->rotateWorld(degrees);
|
bone->rotateWorld(degrees);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_world_to_local_rotation_x(){
|
float SpineBone::get_world_to_local_rotation_x() {
|
||||||
return bone->getWorldToLocalRotationX();
|
return bone->getWorldToLocalRotationX();
|
||||||
}
|
}
|
||||||
float SpineBone::get_world_to_local_rotation_y(){
|
float SpineBone::get_world_to_local_rotation_y() {
|
||||||
return bone->getWorldToLocalRotationY();
|
return bone->getWorldToLocalRotationY();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineBoneData> SpineBone::get_data(){
|
Ref<SpineBoneData> SpineBone::get_data() {
|
||||||
auto &bd = bone->getData();
|
auto &bd = bone->getData();
|
||||||
Ref<SpineBoneData> gd_bd(memnew(SpineBoneData));
|
Ref<SpineBoneData> gd_bd(memnew(SpineBoneData));
|
||||||
gd_bd->set_spine_object(&bd);
|
gd_bd->set_spine_object(&bd);
|
||||||
return gd_bd;
|
return gd_bd;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineSkeleton> SpineBone::get_skeleton(){
|
Ref<SpineSkeleton> SpineBone::get_skeleton() {
|
||||||
auto &s = bone->getSkeleton();
|
auto &s = bone->getSkeleton();
|
||||||
Ref<SpineSkeleton> gd_s(memnew(SpineSkeleton));
|
Ref<SpineSkeleton> gd_s(memnew(SpineSkeleton));
|
||||||
gd_s->set_spine_object(&s);
|
gd_s->set_spine_object(&s);
|
||||||
@ -252,22 +252,22 @@ Ref<SpineSkeleton> SpineBone::get_skeleton(){
|
|||||||
return gd_s;
|
return gd_s;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineBone> SpineBone::get_parent(){
|
Ref<SpineBone> SpineBone::get_parent() {
|
||||||
auto b = bone->getParent();
|
auto b = bone->getParent();
|
||||||
if(b == NULL) return NULL;
|
if (b == NULL) return NULL;
|
||||||
Ref<SpineBone> gd_b(memnew(SpineBone));
|
Ref<SpineBone> gd_b(memnew(SpineBone));
|
||||||
gd_b->set_spine_object(b);
|
gd_b->set_spine_object(b);
|
||||||
gd_b->set_spine_sprite(the_sprite);
|
gd_b->set_spine_sprite(the_sprite);
|
||||||
return gd_b;
|
return gd_b;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array SpineBone::get_children(){
|
Array SpineBone::get_children() {
|
||||||
auto bs = bone->getChildren();
|
auto bs = bone->getChildren();
|
||||||
Array gd_bs;
|
Array gd_bs;
|
||||||
gd_bs.resize(bs.size());
|
gd_bs.resize(bs.size());
|
||||||
for(size_t i=0; i < bs.size(); ++i){
|
for (size_t i = 0; i < bs.size(); ++i) {
|
||||||
auto b = bs[i];
|
auto b = bs[i];
|
||||||
if(b == NULL) gd_bs[i] = Ref<SpineBone>(NULL);
|
if (b == NULL) gd_bs[i] = Ref<SpineBone>(NULL);
|
||||||
Ref<SpineBone> gd_b(memnew(SpineBone));
|
Ref<SpineBone> gd_b(memnew(SpineBone));
|
||||||
gd_b->set_spine_object(b);
|
gd_b->set_spine_object(b);
|
||||||
gd_b->set_spine_sprite(the_sprite);
|
gd_b->set_spine_sprite(the_sprite);
|
||||||
@ -276,179 +276,178 @@ Array SpineBone::get_children(){
|
|||||||
return gd_bs;
|
return gd_bs;
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_x(){
|
float SpineBone::get_x() {
|
||||||
return bone->getX();
|
return bone->getX();
|
||||||
}
|
}
|
||||||
void SpineBone::set_x(float v){
|
void SpineBone::set_x(float v) {
|
||||||
bone->setX(v);
|
bone->setX(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_y(){
|
float SpineBone::get_y() {
|
||||||
return bone->getY();
|
return bone->getY();
|
||||||
}
|
}
|
||||||
void SpineBone::set_y(float v){
|
void SpineBone::set_y(float v) {
|
||||||
bone->setY(v);
|
bone->setY(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_rotation(){
|
float SpineBone::get_rotation() {
|
||||||
return bone->getRotation();
|
return bone->getRotation();
|
||||||
}
|
}
|
||||||
void SpineBone::set_rotation(float v){
|
void SpineBone::set_rotation(float v) {
|
||||||
bone->setRotation(v);
|
bone->setRotation(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_scale_x(){
|
float SpineBone::get_scale_x() {
|
||||||
return bone->getScaleX();
|
return bone->getScaleX();
|
||||||
}
|
}
|
||||||
void SpineBone::set_scale_x(float v){
|
void SpineBone::set_scale_x(float v) {
|
||||||
bone->setScaleX(v);
|
bone->setScaleX(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_scale_y(){
|
float SpineBone::get_scale_y() {
|
||||||
return bone->getScaleY();
|
return bone->getScaleY();
|
||||||
}
|
}
|
||||||
void SpineBone::set_scale_y(float v){
|
void SpineBone::set_scale_y(float v) {
|
||||||
bone->setScaleY(v);
|
bone->setScaleY(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_shear_x(){
|
float SpineBone::get_shear_x() {
|
||||||
return bone->getShearX();
|
return bone->getShearX();
|
||||||
}
|
}
|
||||||
void SpineBone::set_shear_x(float v){
|
void SpineBone::set_shear_x(float v) {
|
||||||
bone->setShearX(v);
|
bone->setShearX(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_shear_y(){
|
float SpineBone::get_shear_y() {
|
||||||
return bone->getShearY();
|
return bone->getShearY();
|
||||||
}
|
}
|
||||||
void SpineBone::set_shear_y(float v){
|
void SpineBone::set_shear_y(float v) {
|
||||||
bone->setShearY(v);
|
bone->setShearY(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_applied_rotation(){
|
float SpineBone::get_applied_rotation() {
|
||||||
return bone->getAppliedRotation();
|
return bone->getAppliedRotation();
|
||||||
}
|
}
|
||||||
void SpineBone::set_applied_rotation(float v){
|
void SpineBone::set_applied_rotation(float v) {
|
||||||
bone->setAppliedRotation(v);
|
bone->setAppliedRotation(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_a_x(){
|
float SpineBone::get_a_x() {
|
||||||
return bone->getAX();
|
return bone->getAX();
|
||||||
}
|
}
|
||||||
void SpineBone::set_a_x(float v){
|
void SpineBone::set_a_x(float v) {
|
||||||
bone->setAX(v);
|
bone->setAX(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_a_y(){
|
float SpineBone::get_a_y() {
|
||||||
return bone->getAY();
|
return bone->getAY();
|
||||||
}
|
}
|
||||||
void SpineBone::set_a_y(float v){
|
void SpineBone::set_a_y(float v) {
|
||||||
bone->setAY(v);
|
bone->setAY(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_a_scale_x(){
|
float SpineBone::get_a_scale_x() {
|
||||||
return bone->getAScaleX();
|
return bone->getAScaleX();
|
||||||
}
|
}
|
||||||
void SpineBone::set_a_scale_x(float v){
|
void SpineBone::set_a_scale_x(float v) {
|
||||||
bone->setAScaleX(v);
|
bone->setAScaleX(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_a_scale_y(){
|
float SpineBone::get_a_scale_y() {
|
||||||
return bone->getAScaleY();
|
return bone->getAScaleY();
|
||||||
}
|
}
|
||||||
void SpineBone::set_a_scale_y(float v){
|
void SpineBone::set_a_scale_y(float v) {
|
||||||
bone->setAScaleY(v);
|
bone->setAScaleY(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_a_shear_x(){
|
float SpineBone::get_a_shear_x() {
|
||||||
return bone->getAShearX();
|
return bone->getAShearX();
|
||||||
}
|
}
|
||||||
void SpineBone::set_a_shear_x(float v){
|
void SpineBone::set_a_shear_x(float v) {
|
||||||
bone->setAShearX(v);
|
bone->setAShearX(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_a_shear_y(){
|
float SpineBone::get_a_shear_y() {
|
||||||
return bone->getAShearY();
|
return bone->getAShearY();
|
||||||
}
|
}
|
||||||
void SpineBone::set_a_shear_y(float v){
|
void SpineBone::set_a_shear_y(float v) {
|
||||||
bone->setAShearY(v);
|
bone->setAShearY(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_a(){
|
float SpineBone::get_a() {
|
||||||
return bone->getA();
|
return bone->getA();
|
||||||
}
|
}
|
||||||
void SpineBone::set_a(float v){
|
void SpineBone::set_a(float v) {
|
||||||
bone->setA(v);
|
bone->setA(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_b(){
|
float SpineBone::get_b() {
|
||||||
return bone->getB();
|
return bone->getB();
|
||||||
}
|
}
|
||||||
void SpineBone::set_b(float v){
|
void SpineBone::set_b(float v) {
|
||||||
bone->setB(v);
|
bone->setB(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_c(){
|
float SpineBone::get_c() {
|
||||||
return bone->getC();
|
return bone->getC();
|
||||||
}
|
}
|
||||||
void SpineBone::set_c(float v){
|
void SpineBone::set_c(float v) {
|
||||||
bone->setC(v);
|
bone->setC(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_d(){
|
float SpineBone::get_d() {
|
||||||
return bone->getD();
|
return bone->getD();
|
||||||
}
|
}
|
||||||
void SpineBone::set_d(float v){
|
void SpineBone::set_d(float v) {
|
||||||
bone->setD(v);
|
bone->setD(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_world_x(){
|
float SpineBone::get_world_x() {
|
||||||
return bone->getWorldX();
|
return bone->getWorldX();
|
||||||
}
|
}
|
||||||
void SpineBone::set_world_x(float v){
|
void SpineBone::set_world_x(float v) {
|
||||||
bone->setWorldX(v);
|
bone->setWorldX(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_world_y(){
|
float SpineBone::get_world_y() {
|
||||||
return bone->getWorldY();
|
return bone->getWorldY();
|
||||||
}
|
}
|
||||||
void SpineBone::set_world_y(float v){
|
void SpineBone::set_world_y(float v) {
|
||||||
bone->setWorldY(v);
|
bone->setWorldY(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_world_rotation_x(){
|
float SpineBone::get_world_rotation_x() {
|
||||||
return bone->getWorldRotationX();
|
return bone->getWorldRotationX();
|
||||||
}
|
}
|
||||||
float SpineBone::get_world_rotation_y(){
|
float SpineBone::get_world_rotation_y() {
|
||||||
return bone->getWorldRotationY();
|
return bone->getWorldRotationY();
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBone::get_world_scale_x(){
|
float SpineBone::get_world_scale_x() {
|
||||||
return bone->getWorldScaleX();
|
return bone->getWorldScaleX();
|
||||||
}
|
}
|
||||||
float SpineBone::get_world_scale_y(){
|
float SpineBone::get_world_scale_y() {
|
||||||
return bone->getWorldScaleY();
|
return bone->getWorldScaleY();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineBone::is_active(){
|
bool SpineBone::is_active() {
|
||||||
return bone->isActive();
|
return bone->isActive();
|
||||||
}
|
}
|
||||||
void SpineBone::set_active(bool v){
|
void SpineBone::set_active(bool v) {
|
||||||
bone->setActive(v);
|
bone->setActive(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// External feature functions
|
// External feature functions
|
||||||
void SpineBone::apply_world_transform_2d(Variant o){
|
void SpineBone::apply_world_transform_2d(Variant o) {
|
||||||
if(o.get_type() == Variant::OBJECT){
|
if (o.get_type() == Variant::OBJECT) {
|
||||||
auto node = (Node*) o;
|
auto node = (Node *) o;
|
||||||
if(node->is_class("Node2D")){
|
if (node->is_class("Node2D")) {
|
||||||
auto node2d = (Node2D*) node;
|
auto node2d = (Node2D *) node;
|
||||||
// In godot the y-axis is nag to spine
|
// In godot the y-axis is nag to spine
|
||||||
node2d->set_transform(Transform2D(
|
node2d->set_transform(Transform2D(
|
||||||
get_a(), get_c(),
|
get_a(), get_c(),
|
||||||
get_b(), get_d(),
|
get_b(), get_d(),
|
||||||
get_world_x(), -get_world_y())
|
get_world_x(), -get_world_y()));
|
||||||
);
|
|
||||||
// Fix the rotation
|
// Fix the rotation
|
||||||
auto pos = node2d->get_position();
|
auto pos = node2d->get_position();
|
||||||
node2d->translate(-pos);
|
node2d->translate(-pos);
|
||||||
|
|||||||
@ -54,14 +54,15 @@ private:
|
|||||||
spine::Bone *bone;
|
spine::Bone *bone;
|
||||||
|
|
||||||
SpineSprite *the_sprite;
|
SpineSprite *the_sprite;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SpineBone();
|
SpineBone();
|
||||||
~SpineBone();
|
~SpineBone();
|
||||||
|
|
||||||
inline void set_spine_object(spine::Bone *b){
|
inline void set_spine_object(spine::Bone *b) {
|
||||||
bone = b;
|
bone = b;
|
||||||
}
|
}
|
||||||
inline spine::Bone *get_spine_object(){
|
inline spine::Bone *get_spine_object() {
|
||||||
return bone;
|
return bone;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,4 +172,4 @@ public:
|
|||||||
void set_godot_global_transform(Transform2D trans);
|
void set_godot_global_transform(Transform2D trans);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINEBONE_H
|
#endif//GODOT_SPINEBONE_H
|
||||||
|
|||||||
@ -71,93 +71,93 @@ void SpineBoneData::_bind_methods() {
|
|||||||
BIND_ENUM_CONSTANT(TRANSFORMMODE_NOSCALEORREFLECTION);
|
BIND_ENUM_CONSTANT(TRANSFORMMODE_NOSCALEORREFLECTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineBoneData::SpineBoneData():bone_data(NULL) {}
|
SpineBoneData::SpineBoneData() : bone_data(NULL) {}
|
||||||
SpineBoneData::~SpineBoneData() {}
|
SpineBoneData::~SpineBoneData() {}
|
||||||
|
|
||||||
int SpineBoneData::get_index(){
|
int SpineBoneData::get_index() {
|
||||||
return bone_data->getIndex();
|
return bone_data->getIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
String SpineBoneData::get_bone_name(){
|
String SpineBoneData::get_bone_name() {
|
||||||
return bone_data->getName().buffer();
|
return bone_data->getName().buffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineBoneData> SpineBoneData::get_parent(){
|
Ref<SpineBoneData> SpineBoneData::get_parent() {
|
||||||
auto p = bone_data->getParent();
|
auto p = bone_data->getParent();
|
||||||
if(p == NULL) return NULL;
|
if (p == NULL) return NULL;
|
||||||
Ref<SpineBoneData> gd_bone_data(memnew(SpineBoneData));
|
Ref<SpineBoneData> gd_bone_data(memnew(SpineBoneData));
|
||||||
gd_bone_data->set_spine_object(p);
|
gd_bone_data->set_spine_object(p);
|
||||||
return gd_bone_data;
|
return gd_bone_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBoneData::get_length(){
|
float SpineBoneData::get_length() {
|
||||||
return bone_data->getLength();
|
return bone_data->getLength();
|
||||||
}
|
}
|
||||||
void SpineBoneData::set_length(float v){
|
void SpineBoneData::set_length(float v) {
|
||||||
bone_data->setLength(v);
|
bone_data->setLength(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBoneData::get_x(){
|
float SpineBoneData::get_x() {
|
||||||
return bone_data->getX();
|
return bone_data->getX();
|
||||||
}
|
}
|
||||||
void SpineBoneData::set_x(float v){
|
void SpineBoneData::set_x(float v) {
|
||||||
bone_data->setX(v);
|
bone_data->setX(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBoneData::get_y(){
|
float SpineBoneData::get_y() {
|
||||||
return bone_data->getY();
|
return bone_data->getY();
|
||||||
}
|
}
|
||||||
void SpineBoneData::set_y(float v){
|
void SpineBoneData::set_y(float v) {
|
||||||
bone_data->setY(v);
|
bone_data->setY(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBoneData::get_rotation(){
|
float SpineBoneData::get_rotation() {
|
||||||
return bone_data->getRotation();
|
return bone_data->getRotation();
|
||||||
}
|
}
|
||||||
void SpineBoneData::set_rotation(float v){
|
void SpineBoneData::set_rotation(float v) {
|
||||||
bone_data->setRotation(v);
|
bone_data->setRotation(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBoneData::get_scale_x(){
|
float SpineBoneData::get_scale_x() {
|
||||||
return bone_data->getScaleX();
|
return bone_data->getScaleX();
|
||||||
}
|
}
|
||||||
void SpineBoneData::set_scale_x(float v){
|
void SpineBoneData::set_scale_x(float v) {
|
||||||
bone_data->setScaleX(v);
|
bone_data->setScaleX(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBoneData::get_scale_y(){
|
float SpineBoneData::get_scale_y() {
|
||||||
return bone_data->getScaleY();
|
return bone_data->getScaleY();
|
||||||
}
|
}
|
||||||
void SpineBoneData::set_scale_y(float v){
|
void SpineBoneData::set_scale_y(float v) {
|
||||||
bone_data->setScaleY(v);
|
bone_data->setScaleY(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBoneData::get_shear_x(){
|
float SpineBoneData::get_shear_x() {
|
||||||
return bone_data->getShearX();
|
return bone_data->getShearX();
|
||||||
}
|
}
|
||||||
void SpineBoneData::set_shear_x(float v){
|
void SpineBoneData::set_shear_x(float v) {
|
||||||
bone_data->setShearX(v);
|
bone_data->setShearX(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineBoneData::get_shear_y(){
|
float SpineBoneData::get_shear_y() {
|
||||||
return bone_data->getShearY();
|
return bone_data->getShearY();
|
||||||
}
|
}
|
||||||
void SpineBoneData::set_shear_y(float v){
|
void SpineBoneData::set_shear_y(float v) {
|
||||||
bone_data->setShearY(v);
|
bone_data->setShearY(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineBoneData::TransformMode SpineBoneData::get_transform_mode(){
|
SpineBoneData::TransformMode SpineBoneData::get_transform_mode() {
|
||||||
auto tm = (int)bone_data->getTransformMode();
|
auto tm = (int) bone_data->getTransformMode();
|
||||||
return (TransformMode) tm;
|
return (TransformMode) tm;
|
||||||
}
|
}
|
||||||
void SpineBoneData::set_transform_mode(TransformMode v){
|
void SpineBoneData::set_transform_mode(TransformMode v) {
|
||||||
auto tm = (int) v;
|
auto tm = (int) v;
|
||||||
bone_data->setTransformMode((spine::TransformMode)tm);
|
bone_data->setTransformMode((spine::TransformMode) tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineBoneData::is_skin_required(){
|
bool SpineBoneData::is_skin_required() {
|
||||||
return bone_data->isSkinRequired();
|
return bone_data->isSkinRequired();
|
||||||
}
|
}
|
||||||
void SpineBoneData::set_skin_required(bool v){
|
void SpineBoneData::set_skin_required(bool v) {
|
||||||
bone_data->setSkinRequired(v);
|
bone_data->setSkinRequired(v);
|
||||||
}
|
}
|
||||||
@ -47,10 +47,10 @@ public:
|
|||||||
SpineBoneData();
|
SpineBoneData();
|
||||||
~SpineBoneData();
|
~SpineBoneData();
|
||||||
|
|
||||||
inline void set_spine_object(spine::BoneData *b){
|
inline void set_spine_object(spine::BoneData *b) {
|
||||||
bone_data = b;
|
bone_data = b;
|
||||||
}
|
}
|
||||||
inline spine::BoneData *get_spine_object(){
|
inline spine::BoneData *get_spine_object() {
|
||||||
return bone_data;
|
return bone_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,8 +97,7 @@ public:
|
|||||||
|
|
||||||
bool is_skin_required();
|
bool is_skin_required();
|
||||||
void set_skin_required(bool v);
|
void set_skin_required(bool v);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
VARIANT_ENUM_CAST(SpineBoneData::TransformMode);
|
VARIANT_ENUM_CAST(SpineBoneData::TransformMode);
|
||||||
#endif //GODOT_SPINEBONEDATA_H
|
#endif//GODOT_SPINEBONEDATA_H
|
||||||
|
|||||||
@ -45,12 +45,10 @@ void SpineCollisionShapeProxy::_bind_methods() {
|
|||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sync_transform"), "set_sync_transform", "get_sync_transform");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sync_transform"), "set_sync_transform", "get_sync_transform");
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineCollisionShapeProxy::SpineCollisionShapeProxy():sync_transform(true) {
|
SpineCollisionShapeProxy::SpineCollisionShapeProxy() : sync_transform(true) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineCollisionShapeProxy::~SpineCollisionShapeProxy() {
|
SpineCollisionShapeProxy::~SpineCollisionShapeProxy() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineCollisionShapeProxy::_notification(int p_what) {
|
void SpineCollisionShapeProxy::_notification(int p_what) {
|
||||||
@ -69,7 +67,7 @@ void SpineCollisionShapeProxy::_notification(int p_what) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SpineSprite *SpineCollisionShapeProxy::get_spine_sprite() const {
|
SpineSprite *SpineCollisionShapeProxy::get_spine_sprite() const {
|
||||||
return (SpineSprite*) get_node_or_null(spine_sprite_path);
|
return (SpineSprite *) get_node_or_null(spine_sprite_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodePath SpineCollisionShapeProxy::get_spine_sprite_path() {
|
NodePath SpineCollisionShapeProxy::get_spine_sprite_path() {
|
||||||
@ -110,12 +108,12 @@ void SpineCollisionShapeProxy::_update_polygon_from_spine_sprite(SpineSprite *sp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
spine::Attachment *attachment = s->getAttachment();
|
spine::Attachment *attachment = s->getAttachment();
|
||||||
if(!attachment){
|
if (!attachment) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attachment->getRTTI().isExactly(spine::BoundingBoxAttachment::rtti)) {
|
if (attachment->getRTTI().isExactly(spine::BoundingBoxAttachment::rtti)) {
|
||||||
auto *box = (spine::BoundingBoxAttachment*) attachment;
|
auto *box = (spine::BoundingBoxAttachment *) attachment;
|
||||||
|
|
||||||
vertices.setSize(box->getWorldVerticesLength(), 0);
|
vertices.setSize(box->getWorldVerticesLength(), 0);
|
||||||
box->computeWorldVertices(*s, vertices);
|
box->computeWorldVertices(*s, vertices);
|
||||||
@ -123,9 +121,9 @@ void SpineCollisionShapeProxy::_update_polygon_from_spine_sprite(SpineSprite *sp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
polygon.resize(vertices.size()/2);
|
polygon.resize(vertices.size() / 2);
|
||||||
for (size_t j=0; j < vertices.size(); j+=2) {
|
for (size_t j = 0; j < vertices.size(); j += 2) {
|
||||||
polygon.set(j/2, Vector2(vertices[j], -vertices[j + 1]));
|
polygon.set(j / 2, Vector2(vertices[j], -vertices[j + 1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
set_polygon(polygon);
|
set_polygon(polygon);
|
||||||
@ -190,15 +188,9 @@ void SpineCollisionShapeProxy::_get_slot_list(Vector<String> &res) const {
|
|||||||
|
|
||||||
auto slots = sprite->get_skeleton()->get_slots();
|
auto slots = sprite->get_skeleton()->get_slots();
|
||||||
res.resize(slots.size());
|
res.resize(slots.size());
|
||||||
for (size_t i=0; i < res.size(); ++i) {
|
for (size_t i = 0; i < res.size(); ++i) {
|
||||||
auto slot = (Ref<SpineSlot>)slots[i];
|
auto slot = (Ref<SpineSlot>) slots[i];
|
||||||
if (slot.is_valid())
|
if (slot.is_valid())
|
||||||
res.set(i, slot->get_data()->get_slot_name());
|
res.set(i, slot->get_data()->get_slot_name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class SpineSprite;
|
|||||||
class SpineAnimationState;
|
class SpineAnimationState;
|
||||||
class SpineSkeleton;
|
class SpineSkeleton;
|
||||||
|
|
||||||
class SpineCollisionShapeProxy : public CollisionPolygon2D{
|
class SpineCollisionShapeProxy : public CollisionPolygon2D {
|
||||||
GDCLASS(SpineCollisionShapeProxy, CollisionPolygon2D)
|
GDCLASS(SpineCollisionShapeProxy, CollisionPolygon2D)
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
@ -46,6 +46,7 @@ protected:
|
|||||||
String slot;
|
String slot;
|
||||||
|
|
||||||
bool sync_transform;
|
bool sync_transform;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
void _get_property_list(List<PropertyInfo> *p_list) const;
|
void _get_property_list(List<PropertyInfo> *p_list) const;
|
||||||
@ -60,6 +61,7 @@ protected:
|
|||||||
void _sync_transform(SpineSprite *sprite);
|
void _sync_transform(SpineSprite *sprite);
|
||||||
|
|
||||||
void _get_slot_list(Vector<String> &res) const;
|
void _get_slot_list(Vector<String> &res) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SpineCollisionShapeProxy();
|
SpineCollisionShapeProxy();
|
||||||
~SpineCollisionShapeProxy();
|
~SpineCollisionShapeProxy();
|
||||||
@ -75,4 +77,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //GODOT_SPINECOLLISIONSHAPEPROXY_H
|
#endif//GODOT_SPINECOLLISIONSHAPEPROXY_H
|
||||||
|
|||||||
@ -42,7 +42,7 @@ void SpineConstant::_bind_methods() {
|
|||||||
BIND_ENUM_CONSTANT(Property_X);
|
BIND_ENUM_CONSTANT(Property_X);
|
||||||
BIND_ENUM_CONSTANT(Property_Y);
|
BIND_ENUM_CONSTANT(Property_Y);
|
||||||
BIND_ENUM_CONSTANT(Property_ScaleX);
|
BIND_ENUM_CONSTANT(Property_ScaleX);
|
||||||
BIND_ENUM_CONSTANT( Property_ScaleY);
|
BIND_ENUM_CONSTANT(Property_ScaleY);
|
||||||
BIND_ENUM_CONSTANT(Property_ShearX);
|
BIND_ENUM_CONSTANT(Property_ShearX);
|
||||||
BIND_ENUM_CONSTANT(Property_ShearY);
|
BIND_ENUM_CONSTANT(Property_ShearY);
|
||||||
BIND_ENUM_CONSTANT(Property_Rgb);
|
BIND_ENUM_CONSTANT(Property_Rgb);
|
||||||
@ -57,6 +57,4 @@ void SpineConstant::_bind_methods() {
|
|||||||
BIND_ENUM_CONSTANT(Property_PathConstraintPosition);
|
BIND_ENUM_CONSTANT(Property_PathConstraintPosition);
|
||||||
BIND_ENUM_CONSTANT(Property_PathConstraintSpacing);
|
BIND_ENUM_CONSTANT(Property_PathConstraintSpacing);
|
||||||
BIND_ENUM_CONSTANT(Property_PathConstraintMix);
|
BIND_ENUM_CONSTANT(Property_PathConstraintMix);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -32,11 +32,12 @@
|
|||||||
|
|
||||||
#include "core/variant_parser.h"
|
#include "core/variant_parser.h"
|
||||||
|
|
||||||
class SpineConstant : public Object{
|
class SpineConstant : public Object {
|
||||||
GDCLASS(SpineConstant, Object);
|
GDCLASS(SpineConstant, Object);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum MixBlend {
|
enum MixBlend {
|
||||||
MixBlend_Setup = 0,
|
MixBlend_Setup = 0,
|
||||||
@ -77,4 +78,4 @@ VARIANT_ENUM_CAST(SpineConstant::MixBlend);
|
|||||||
VARIANT_ENUM_CAST(SpineConstant::MixDirection);
|
VARIANT_ENUM_CAST(SpineConstant::MixDirection);
|
||||||
VARIANT_ENUM_CAST(SpineConstant::PropertyId);
|
VARIANT_ENUM_CAST(SpineConstant::PropertyId);
|
||||||
|
|
||||||
#endif //GODOT_SPINECONSTANT_H
|
#endif//GODOT_SPINECONSTANT_H
|
||||||
|
|||||||
@ -37,23 +37,23 @@ void SpineConstraintData::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_skin_required", "v"), &SpineConstraintData::set_skin_required);
|
ClassDB::bind_method(D_METHOD("set_skin_required", "v"), &SpineConstraintData::set_skin_required);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineConstraintData::SpineConstraintData():constraint_data(NULL) {}
|
SpineConstraintData::SpineConstraintData() : constraint_data(NULL) {}
|
||||||
SpineConstraintData::~SpineConstraintData() {}
|
SpineConstraintData::~SpineConstraintData() {}
|
||||||
|
|
||||||
String SpineConstraintData::get_constraint_data_name(){
|
String SpineConstraintData::get_constraint_data_name() {
|
||||||
return constraint_data->getName().buffer();
|
return constraint_data->getName().buffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t SpineConstraintData::get_order(){
|
uint64_t SpineConstraintData::get_order() {
|
||||||
return constraint_data->getOrder();
|
return constraint_data->getOrder();
|
||||||
}
|
}
|
||||||
void SpineConstraintData::set_order(uint64_t v){
|
void SpineConstraintData::set_order(uint64_t v) {
|
||||||
constraint_data->setOrder(v);
|
constraint_data->setOrder(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineConstraintData::is_skin_required(){
|
bool SpineConstraintData::is_skin_required() {
|
||||||
return constraint_data->isSkinRequired();
|
return constraint_data->isSkinRequired();
|
||||||
}
|
}
|
||||||
void SpineConstraintData::set_skin_required(bool v){
|
void SpineConstraintData::set_skin_required(bool v) {
|
||||||
constraint_data->setSkinRequired(v);
|
constraint_data->setSkinRequired(v);
|
||||||
}
|
}
|
||||||
@ -47,10 +47,10 @@ public:
|
|||||||
SpineConstraintData();
|
SpineConstraintData();
|
||||||
~SpineConstraintData();
|
~SpineConstraintData();
|
||||||
|
|
||||||
inline void set_spine_object(spine::ConstraintData *c){
|
inline void set_spine_object(spine::ConstraintData *c) {
|
||||||
constraint_data = c;
|
constraint_data = c;
|
||||||
}
|
}
|
||||||
virtual inline spine::ConstraintData *get_spine_object(){
|
virtual inline spine::ConstraintData *get_spine_object() {
|
||||||
return constraint_data;
|
return constraint_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,4 +63,4 @@ public:
|
|||||||
void set_skin_required(bool v);
|
void set_skin_required(bool v);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINECONSTRAINTDATA_H
|
#endif//GODOT_SPINECONSTRAINTDATA_H
|
||||||
|
|||||||
@ -43,19 +43,19 @@ void SpineEvent::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_volume", "v"), &SpineEvent::set_volume);
|
ClassDB::bind_method(D_METHOD("set_volume", "v"), &SpineEvent::set_volume);
|
||||||
ClassDB::bind_method(D_METHOD("get_balance"), &SpineEvent::get_balance);
|
ClassDB::bind_method(D_METHOD("get_balance"), &SpineEvent::get_balance);
|
||||||
ClassDB::bind_method(D_METHOD("set_balance", "v"), &SpineEvent::set_balance);
|
ClassDB::bind_method(D_METHOD("set_balance", "v"), &SpineEvent::set_balance);
|
||||||
//
|
//
|
||||||
// BIND_ENUM_CONSTANT(EVENTTYPE_START);
|
// BIND_ENUM_CONSTANT(EVENTTYPE_START);
|
||||||
// BIND_ENUM_CONSTANT(EVENTTYPE_INTERRUPT);
|
// BIND_ENUM_CONSTANT(EVENTTYPE_INTERRUPT);
|
||||||
// BIND_ENUM_CONSTANT(EVENTTYPE_END);
|
// BIND_ENUM_CONSTANT(EVENTTYPE_END);
|
||||||
// BIND_ENUM_CONSTANT(EVENTTYPE_COMPLETE);
|
// BIND_ENUM_CONSTANT(EVENTTYPE_COMPLETE);
|
||||||
// BIND_ENUM_CONSTANT(EVENTTYPE_DISPOSE);
|
// BIND_ENUM_CONSTANT(EVENTTYPE_DISPOSE);
|
||||||
// BIND_ENUM_CONSTANT(EVENTTYPE_EVENT);
|
// BIND_ENUM_CONSTANT(EVENTTYPE_EVENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineEvent::SpineEvent():event(NULL) {}
|
SpineEvent::SpineEvent() : event(NULL) {}
|
||||||
SpineEvent::~SpineEvent(){}
|
SpineEvent::~SpineEvent() {}
|
||||||
|
|
||||||
Ref<SpineEventData> SpineEvent::get_data(){
|
Ref<SpineEventData> SpineEvent::get_data() {
|
||||||
Ref<SpineEventData> event_data(memnew(SpineEventData));
|
Ref<SpineEventData> event_data(memnew(SpineEventData));
|
||||||
event_data->set_spine_object(&(event->getData()));
|
event_data->set_spine_object(&(event->getData()));
|
||||||
return event_data;
|
return event_data;
|
||||||
@ -65,46 +65,46 @@ String SpineEvent::get_event_name() {
|
|||||||
return event->getData().getName().buffer();
|
return event->getData().getName().buffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineEvent::get_time(){
|
float SpineEvent::get_time() {
|
||||||
return event->getTime();
|
return event->getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SpineEvent::get_int_value(){
|
int SpineEvent::get_int_value() {
|
||||||
return event->getIntValue();
|
return event->getIntValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineEvent::set_int_value(int v){
|
void SpineEvent::set_int_value(int v) {
|
||||||
event->setIntValue(v);
|
event->setIntValue(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineEvent::get_float_value(){
|
float SpineEvent::get_float_value() {
|
||||||
return event->getFloatValue();
|
return event->getFloatValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineEvent::set_float_value(float v){
|
void SpineEvent::set_float_value(float v) {
|
||||||
event->setFloatValue(v);
|
event->setFloatValue(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
String SpineEvent::get_string_value(){
|
String SpineEvent::get_string_value() {
|
||||||
return event->getStringValue().buffer();
|
return event->getStringValue().buffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineEvent::set_string_value(const String &v){
|
void SpineEvent::set_string_value(const String &v) {
|
||||||
event->setStringValue(spine::String(v.utf8()));
|
event->setStringValue(spine::String(v.utf8()));
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineEvent::get_volume(){
|
float SpineEvent::get_volume() {
|
||||||
return event->getVolume();
|
return event->getVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineEvent::set_volume(float v){
|
void SpineEvent::set_volume(float v) {
|
||||||
event->setVolume(v);
|
event->setVolume(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineEvent::get_balance(){
|
float SpineEvent::get_balance() {
|
||||||
return event->getBalance();
|
return event->getBalance();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineEvent::set_balance(float v){
|
void SpineEvent::set_balance(float v) {
|
||||||
event->setBalance(v);
|
event->setBalance(v);
|
||||||
}
|
}
|
||||||
@ -36,25 +36,27 @@
|
|||||||
|
|
||||||
#include "SpineEventData.h"
|
#include "SpineEventData.h"
|
||||||
|
|
||||||
class SpineEvent : public Reference{
|
class SpineEvent : public Reference {
|
||||||
GDCLASS(SpineEvent, Reference);
|
GDCLASS(SpineEvent, Reference);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
spine::Event *event;
|
spine::Event *event;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SpineEvent();
|
SpineEvent();
|
||||||
~SpineEvent();
|
~SpineEvent();
|
||||||
|
|
||||||
inline void set_spine_object(spine::Event *e){
|
inline void set_spine_object(spine::Event *e) {
|
||||||
event = e;
|
event = e;
|
||||||
}
|
}
|
||||||
inline spine::Event *get_spine_object() const{
|
inline spine::Event *get_spine_object() const {
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum EventType{
|
enum EventType {
|
||||||
EVENTTYPE_START = spine::EventType_Start,
|
EVENTTYPE_START = spine::EventType_Start,
|
||||||
EVENTTYPE_INTERRUPT = spine::EventType_Interrupt,
|
EVENTTYPE_INTERRUPT = spine::EventType_Interrupt,
|
||||||
EVENTTYPE_END = spine::EventType_End,
|
EVENTTYPE_END = spine::EventType_End,
|
||||||
@ -86,4 +88,4 @@ public:
|
|||||||
void set_balance(float inValue);
|
void set_balance(float inValue);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINEEVENT_H
|
#endif//GODOT_SPINEEVENT_H
|
||||||
|
|||||||
@ -30,8 +30,7 @@
|
|||||||
#include "SpineEventData.h"
|
#include "SpineEventData.h"
|
||||||
|
|
||||||
void SpineEventData::_bind_methods() {
|
void SpineEventData::_bind_methods() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineEventData::SpineEventData():event_data(NULL) {}
|
SpineEventData::SpineEventData() : event_data(NULL) {}
|
||||||
SpineEventData::~SpineEventData(){}
|
SpineEventData::~SpineEventData() {}
|
||||||
|
|||||||
@ -34,23 +34,25 @@
|
|||||||
|
|
||||||
#include <spine/spine.h>
|
#include <spine/spine.h>
|
||||||
|
|
||||||
class SpineEventData : public Reference{
|
class SpineEventData : public Reference {
|
||||||
GDCLASS(SpineEventData, Reference);
|
GDCLASS(SpineEventData, Reference);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const spine::EventData *event_data;
|
const spine::EventData *event_data;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SpineEventData();
|
SpineEventData();
|
||||||
~SpineEventData();
|
~SpineEventData();
|
||||||
|
|
||||||
inline void set_spine_object(const spine::EventData *e){
|
inline void set_spine_object(const spine::EventData *e) {
|
||||||
event_data = e;
|
event_data = e;
|
||||||
}
|
}
|
||||||
inline const spine::EventData *get_spine_object(){
|
inline const spine::EventData *get_spine_object() {
|
||||||
return event_data;
|
return event_data;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINEEVENTDATA_H
|
#endif//GODOT_SPINEEVENTDATA_H
|
||||||
|
|||||||
@ -52,35 +52,35 @@ void SpineIkConstraint::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_active", "v"), &SpineIkConstraint::set_active);
|
ClassDB::bind_method(D_METHOD("set_active", "v"), &SpineIkConstraint::set_active);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineIkConstraint::SpineIkConstraint():ik_constraint(NULL) {}
|
SpineIkConstraint::SpineIkConstraint() : ik_constraint(NULL) {}
|
||||||
SpineIkConstraint::~SpineIkConstraint() {}
|
SpineIkConstraint::~SpineIkConstraint() {}
|
||||||
|
|
||||||
// void SpineIkConstraint::apply(){
|
// void SpineIkConstraint::apply(){
|
||||||
// ik_constraint->apply();
|
// ik_constraint->apply();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
void SpineIkConstraint::update(){
|
void SpineIkConstraint::update() {
|
||||||
ik_constraint->update();
|
ik_constraint->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SpineIkConstraint::get_order(){
|
int SpineIkConstraint::get_order() {
|
||||||
return ik_constraint->getOrder();
|
return ik_constraint->getOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineIkConstraintData> SpineIkConstraint::get_data(){
|
Ref<SpineIkConstraintData> SpineIkConstraint::get_data() {
|
||||||
auto &ikc = ik_constraint->getData();
|
auto &ikc = ik_constraint->getData();
|
||||||
Ref<SpineIkConstraintData> gd_ikc(memnew(SpineIkConstraintData));
|
Ref<SpineIkConstraintData> gd_ikc(memnew(SpineIkConstraintData));
|
||||||
gd_ikc->set_spine_object(&ikc);
|
gd_ikc->set_spine_object(&ikc);
|
||||||
return gd_ikc;
|
return gd_ikc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array SpineIkConstraint::get_bones(){
|
Array SpineIkConstraint::get_bones() {
|
||||||
auto &bs = ik_constraint->getBones();
|
auto &bs = ik_constraint->getBones();
|
||||||
Array gd_bs;
|
Array gd_bs;
|
||||||
gd_bs.resize(bs.size());
|
gd_bs.resize(bs.size());
|
||||||
for(size_t i=0; i<bs.size(); ++i){
|
for (size_t i = 0; i < bs.size(); ++i) {
|
||||||
auto b = bs[i];
|
auto b = bs[i];
|
||||||
if(b == NULL) gd_bs[i] = Ref<SpineBone>(NULL);
|
if (b == NULL) gd_bs[i] = Ref<SpineBone>(NULL);
|
||||||
Ref<SpineBone> gd_b(memnew(SpineBone));
|
Ref<SpineBone> gd_b(memnew(SpineBone));
|
||||||
gd_b->set_spine_object(b);
|
gd_b->set_spine_object(b);
|
||||||
gd_bs[i] = gd_b;
|
gd_bs[i] = gd_b;
|
||||||
@ -88,59 +88,59 @@ Array SpineIkConstraint::get_bones(){
|
|||||||
return gd_bs;
|
return gd_bs;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineBone> SpineIkConstraint::get_target(){
|
Ref<SpineBone> SpineIkConstraint::get_target() {
|
||||||
auto b = ik_constraint->getTarget();
|
auto b = ik_constraint->getTarget();
|
||||||
if(b == NULL) return NULL;
|
if (b == NULL) return NULL;
|
||||||
Ref<SpineBone> gd_b(memnew(SpineBone));
|
Ref<SpineBone> gd_b(memnew(SpineBone));
|
||||||
gd_b->set_spine_object(b);
|
gd_b->set_spine_object(b);
|
||||||
return gd_b;
|
return gd_b;
|
||||||
}
|
}
|
||||||
void SpineIkConstraint::set_target(Ref<SpineBone> v){
|
void SpineIkConstraint::set_target(Ref<SpineBone> v) {
|
||||||
if(v.is_valid()){
|
if (v.is_valid()) {
|
||||||
ik_constraint->setTarget(v->get_spine_object());
|
ik_constraint->setTarget(v->get_spine_object());
|
||||||
} else{
|
} else {
|
||||||
ik_constraint->setTarget(NULL);
|
ik_constraint->setTarget(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int SpineIkConstraint::get_bend_direction(){
|
int SpineIkConstraint::get_bend_direction() {
|
||||||
return ik_constraint->getBendDirection();
|
return ik_constraint->getBendDirection();
|
||||||
}
|
}
|
||||||
void SpineIkConstraint::set_bend_direction(int v){
|
void SpineIkConstraint::set_bend_direction(int v) {
|
||||||
ik_constraint->setBendDirection(v);
|
ik_constraint->setBendDirection(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineIkConstraint::get_compress(){
|
bool SpineIkConstraint::get_compress() {
|
||||||
return ik_constraint->getCompress();
|
return ik_constraint->getCompress();
|
||||||
}
|
}
|
||||||
void SpineIkConstraint::set_compress(bool v){
|
void SpineIkConstraint::set_compress(bool v) {
|
||||||
ik_constraint->setCompress(v);
|
ik_constraint->setCompress(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineIkConstraint::get_stretch(){
|
bool SpineIkConstraint::get_stretch() {
|
||||||
return ik_constraint->getStretch();
|
return ik_constraint->getStretch();
|
||||||
}
|
}
|
||||||
void SpineIkConstraint::set_stretch(bool v){
|
void SpineIkConstraint::set_stretch(bool v) {
|
||||||
ik_constraint->setStretch(v);
|
ik_constraint->setStretch(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineIkConstraint::get_mix(){
|
float SpineIkConstraint::get_mix() {
|
||||||
return ik_constraint->getMix();
|
return ik_constraint->getMix();
|
||||||
}
|
}
|
||||||
void SpineIkConstraint::set_mix(float v){
|
void SpineIkConstraint::set_mix(float v) {
|
||||||
ik_constraint->setMix(v);
|
ik_constraint->setMix(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineIkConstraint::get_softness(){
|
float SpineIkConstraint::get_softness() {
|
||||||
return ik_constraint->getSoftness();
|
return ik_constraint->getSoftness();
|
||||||
}
|
}
|
||||||
void SpineIkConstraint::set_softness(float v){
|
void SpineIkConstraint::set_softness(float v) {
|
||||||
ik_constraint->setSoftness(v);
|
ik_constraint->setSoftness(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineIkConstraint::is_active(){
|
bool SpineIkConstraint::is_active() {
|
||||||
return ik_constraint->isActive();
|
return ik_constraint->isActive();
|
||||||
}
|
}
|
||||||
void SpineIkConstraint::set_active(bool v){
|
void SpineIkConstraint::set_active(bool v) {
|
||||||
ik_constraint->setActive(v);
|
ik_constraint->setActive(v);
|
||||||
}
|
}
|
||||||
@ -51,10 +51,10 @@ public:
|
|||||||
SpineIkConstraint();
|
SpineIkConstraint();
|
||||||
~SpineIkConstraint();
|
~SpineIkConstraint();
|
||||||
|
|
||||||
inline void set_spine_object(spine::IkConstraint * ic){
|
inline void set_spine_object(spine::IkConstraint *ic) {
|
||||||
ik_constraint = ic;
|
ik_constraint = ic;
|
||||||
}
|
}
|
||||||
inline spine::IkConstraint *get_spine_object(){
|
inline spine::IkConstraint *get_spine_object() {
|
||||||
return ik_constraint;
|
return ik_constraint;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +89,6 @@ public:
|
|||||||
|
|
||||||
bool is_active();
|
bool is_active();
|
||||||
void set_active(bool v);
|
void set_active(bool v);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINEIKCONSTRAINT_H
|
#endif//GODOT_SPINEIKCONSTRAINT_H
|
||||||
|
|||||||
@ -50,12 +50,12 @@ void SpineIkConstraintData::_bind_methods() {
|
|||||||
SpineIkConstraintData::SpineIkConstraintData() {}
|
SpineIkConstraintData::SpineIkConstraintData() {}
|
||||||
SpineIkConstraintData::~SpineIkConstraintData() {}
|
SpineIkConstraintData::~SpineIkConstraintData() {}
|
||||||
|
|
||||||
Array SpineIkConstraintData::get_bones(){
|
Array SpineIkConstraintData::get_bones() {
|
||||||
auto bs = get_spine_data()->getBones();
|
auto bs = get_spine_data()->getBones();
|
||||||
Array gd_bs;
|
Array gd_bs;
|
||||||
gd_bs.resize(bs.size());
|
gd_bs.resize(bs.size());
|
||||||
for(size_t i=0; i < bs.size(); ++i){
|
for (size_t i = 0; i < bs.size(); ++i) {
|
||||||
if(bs[i] == NULL) gd_bs[i] = Ref<SpineBoneData>(NULL);
|
if (bs[i] == NULL) gd_bs[i] = Ref<SpineBoneData>(NULL);
|
||||||
else {
|
else {
|
||||||
Ref<SpineBoneData> gd_b(memnew(SpineBoneData));
|
Ref<SpineBoneData> gd_b(memnew(SpineBoneData));
|
||||||
gd_b->set_spine_object(bs[i]);
|
gd_b->set_spine_object(bs[i]);
|
||||||
@ -65,59 +65,59 @@ Array SpineIkConstraintData::get_bones(){
|
|||||||
return gd_bs;
|
return gd_bs;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineBoneData> SpineIkConstraintData::get_target(){
|
Ref<SpineBoneData> SpineIkConstraintData::get_target() {
|
||||||
auto b = get_spine_data()->getTarget();
|
auto b = get_spine_data()->getTarget();
|
||||||
if(b == NULL) return NULL;
|
if (b == NULL) return NULL;
|
||||||
Ref<SpineBoneData> gd_b(memnew(SpineBoneData));
|
Ref<SpineBoneData> gd_b(memnew(SpineBoneData));
|
||||||
gd_b->set_spine_object(b);
|
gd_b->set_spine_object(b);
|
||||||
return gd_b;
|
return gd_b;
|
||||||
}
|
}
|
||||||
void SpineIkConstraintData::set_target(Ref<SpineBoneData> v){
|
void SpineIkConstraintData::set_target(Ref<SpineBoneData> v) {
|
||||||
if(v.is_valid()){
|
if (v.is_valid()) {
|
||||||
get_spine_data()->setTarget(v->get_spine_object());
|
get_spine_data()->setTarget(v->get_spine_object());
|
||||||
}else{
|
} else {
|
||||||
get_spine_data()->setTarget(NULL);
|
get_spine_data()->setTarget(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int SpineIkConstraintData::get_bend_direction(){
|
int SpineIkConstraintData::get_bend_direction() {
|
||||||
return get_spine_data()->getBendDirection();
|
return get_spine_data()->getBendDirection();
|
||||||
}
|
}
|
||||||
void SpineIkConstraintData::set_bend_direction(int v){
|
void SpineIkConstraintData::set_bend_direction(int v) {
|
||||||
get_spine_data()->setBendDirection(v);
|
get_spine_data()->setBendDirection(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineIkConstraintData::get_compress(){
|
bool SpineIkConstraintData::get_compress() {
|
||||||
return get_spine_data()->getCompress();
|
return get_spine_data()->getCompress();
|
||||||
}
|
}
|
||||||
void SpineIkConstraintData::set_compress(bool v){
|
void SpineIkConstraintData::set_compress(bool v) {
|
||||||
get_spine_data()->setCompress(v);
|
get_spine_data()->setCompress(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineIkConstraintData::get_stretch(){
|
bool SpineIkConstraintData::get_stretch() {
|
||||||
return get_spine_data()->getStretch();
|
return get_spine_data()->getStretch();
|
||||||
}
|
}
|
||||||
void SpineIkConstraintData::set_stretch(bool v){
|
void SpineIkConstraintData::set_stretch(bool v) {
|
||||||
get_spine_data()->setStretch(v);
|
get_spine_data()->setStretch(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineIkConstraintData::get_uniform(){
|
bool SpineIkConstraintData::get_uniform() {
|
||||||
return get_spine_data()->getUniform();
|
return get_spine_data()->getUniform();
|
||||||
}
|
}
|
||||||
void SpineIkConstraintData::set_uniform(bool v){
|
void SpineIkConstraintData::set_uniform(bool v) {
|
||||||
get_spine_data()->setUniform(v);
|
get_spine_data()->setUniform(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineIkConstraintData::get_mix(){
|
float SpineIkConstraintData::get_mix() {
|
||||||
return get_spine_data()->getMix();
|
return get_spine_data()->getMix();
|
||||||
}
|
}
|
||||||
void SpineIkConstraintData::set_mix(float v){
|
void SpineIkConstraintData::set_mix(float v) {
|
||||||
get_spine_data()->setMix(v);
|
get_spine_data()->setMix(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineIkConstraintData::get_softness(){
|
float SpineIkConstraintData::get_softness() {
|
||||||
return get_spine_data()->getSoftness();
|
return get_spine_data()->getSoftness();
|
||||||
}
|
}
|
||||||
void SpineIkConstraintData::set_softness(float v){
|
void SpineIkConstraintData::set_softness(float v) {
|
||||||
get_spine_data()->setSoftness(v);
|
get_spine_data()->setSoftness(v);
|
||||||
}
|
}
|
||||||
@ -47,8 +47,8 @@ public:
|
|||||||
SpineIkConstraintData();
|
SpineIkConstraintData();
|
||||||
~SpineIkConstraintData();
|
~SpineIkConstraintData();
|
||||||
|
|
||||||
virtual inline spine::IkConstraintData *get_spine_data(){
|
virtual inline spine::IkConstraintData *get_spine_data() {
|
||||||
return (spine::IkConstraintData*) SpineConstraintData::get_spine_object();
|
return (spine::IkConstraintData *) SpineConstraintData::get_spine_object();
|
||||||
}
|
}
|
||||||
|
|
||||||
Array get_bones();
|
Array get_bones();
|
||||||
@ -73,7 +73,6 @@ public:
|
|||||||
|
|
||||||
float get_softness();
|
float get_softness();
|
||||||
void set_softness(float v);
|
void set_softness(float v);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINEIKCONSTRAINTDATA_H
|
#endif//GODOT_SPINEIKCONSTRAINTDATA_H
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include "SpinePathConstraint.h"
|
#include "SpinePathConstraint.h"
|
||||||
|
|
||||||
void SpinePathConstraint::_bind_methods(){
|
void SpinePathConstraint::_bind_methods() {
|
||||||
// ClassDB::bind_method(D_METHOD("apply"), &SpinePathConstraint::apply);
|
// ClassDB::bind_method(D_METHOD("apply"), &SpinePathConstraint::apply);
|
||||||
ClassDB::bind_method(D_METHOD("update"), &SpinePathConstraint::update);
|
ClassDB::bind_method(D_METHOD("update"), &SpinePathConstraint::update);
|
||||||
ClassDB::bind_method(D_METHOD("get_order"), &SpinePathConstraint::get_order);
|
ClassDB::bind_method(D_METHOD("get_order"), &SpinePathConstraint::get_order);
|
||||||
@ -51,63 +51,63 @@ void SpinePathConstraint::_bind_methods(){
|
|||||||
ClassDB::bind_method(D_METHOD("set_active", "v"), &SpinePathConstraint::set_active);
|
ClassDB::bind_method(D_METHOD("set_active", "v"), &SpinePathConstraint::set_active);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinePathConstraint::SpinePathConstraint():path_constraint(NULL) {}
|
SpinePathConstraint::SpinePathConstraint() : path_constraint(NULL) {}
|
||||||
SpinePathConstraint::~SpinePathConstraint() {}
|
SpinePathConstraint::~SpinePathConstraint() {}
|
||||||
|
|
||||||
// void SpinePathConstraint::apply(){
|
// void SpinePathConstraint::apply(){
|
||||||
// path_constraint->apply();
|
// path_constraint->apply();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
void SpinePathConstraint::update(){
|
void SpinePathConstraint::update() {
|
||||||
path_constraint->update();
|
path_constraint->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SpinePathConstraint::get_order(){
|
int SpinePathConstraint::get_order() {
|
||||||
return path_constraint->getOrder();
|
return path_constraint->getOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpinePathConstraint::get_position(){
|
float SpinePathConstraint::get_position() {
|
||||||
return path_constraint->getPosition();
|
return path_constraint->getPosition();
|
||||||
}
|
}
|
||||||
void SpinePathConstraint::set_position(float v){
|
void SpinePathConstraint::set_position(float v) {
|
||||||
path_constraint->setPosition(v);
|
path_constraint->setPosition(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpinePathConstraint::get_spacing(){
|
float SpinePathConstraint::get_spacing() {
|
||||||
return path_constraint->getSpacing();
|
return path_constraint->getSpacing();
|
||||||
}
|
}
|
||||||
void SpinePathConstraint::set_spacing(float v){
|
void SpinePathConstraint::set_spacing(float v) {
|
||||||
path_constraint->setSpacing(v);
|
path_constraint->setSpacing(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpinePathConstraint::get_mix_rotate(){
|
float SpinePathConstraint::get_mix_rotate() {
|
||||||
return path_constraint->getMixRotate();
|
return path_constraint->getMixRotate();
|
||||||
}
|
}
|
||||||
void SpinePathConstraint::set_mix_rotate(float v){
|
void SpinePathConstraint::set_mix_rotate(float v) {
|
||||||
path_constraint->setMixRotate(v);
|
path_constraint->setMixRotate(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpinePathConstraint::get_mix_x(){
|
float SpinePathConstraint::get_mix_x() {
|
||||||
return path_constraint->getMixX();
|
return path_constraint->getMixX();
|
||||||
}
|
}
|
||||||
void SpinePathConstraint::set_mix_x(float v){
|
void SpinePathConstraint::set_mix_x(float v) {
|
||||||
path_constraint->setMixX(v);
|
path_constraint->setMixX(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpinePathConstraint::get_mix_y(){
|
float SpinePathConstraint::get_mix_y() {
|
||||||
return path_constraint->getMixY();
|
return path_constraint->getMixY();
|
||||||
}
|
}
|
||||||
void SpinePathConstraint::set_mix_y(float v){
|
void SpinePathConstraint::set_mix_y(float v) {
|
||||||
path_constraint->setMixY(v);
|
path_constraint->setMixY(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
Array SpinePathConstraint::get_bones(){
|
Array SpinePathConstraint::get_bones() {
|
||||||
auto &bs = path_constraint->getBones();
|
auto &bs = path_constraint->getBones();
|
||||||
Array gd_bs;
|
Array gd_bs;
|
||||||
gd_bs.resize(bs.size());
|
gd_bs.resize(bs.size());
|
||||||
for(size_t i=0; i<bs.size(); ++i){
|
for (size_t i = 0; i < bs.size(); ++i) {
|
||||||
auto b = bs[i];
|
auto b = bs[i];
|
||||||
if(b == NULL) gd_bs[i] = Ref<SpineBone>(NULL);
|
if (b == NULL) gd_bs[i] = Ref<SpineBone>(NULL);
|
||||||
Ref<SpineBone> gd_b(memnew(SpineBone));
|
Ref<SpineBone> gd_b(memnew(SpineBone));
|
||||||
gd_b->set_spine_object(b);
|
gd_b->set_spine_object(b);
|
||||||
gd_bs[i] = gd_b;
|
gd_bs[i] = gd_b;
|
||||||
@ -115,31 +115,31 @@ Array SpinePathConstraint::get_bones(){
|
|||||||
return gd_bs;
|
return gd_bs;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineSlot> SpinePathConstraint::get_target(){
|
Ref<SpineSlot> SpinePathConstraint::get_target() {
|
||||||
auto s = path_constraint->getTarget();
|
auto s = path_constraint->getTarget();
|
||||||
if(s == NULL) return NULL;
|
if (s == NULL) return NULL;
|
||||||
Ref<SpineSlot> gd_s(memnew(SpineSlot));
|
Ref<SpineSlot> gd_s(memnew(SpineSlot));
|
||||||
gd_s->set_spine_object(s);
|
gd_s->set_spine_object(s);
|
||||||
return gd_s;
|
return gd_s;
|
||||||
}
|
}
|
||||||
void SpinePathConstraint::set_target(Ref<SpineSlot> v){
|
void SpinePathConstraint::set_target(Ref<SpineSlot> v) {
|
||||||
if(v.is_valid()){
|
if (v.is_valid()) {
|
||||||
path_constraint->setTarget(v->get_spine_object());
|
path_constraint->setTarget(v->get_spine_object());
|
||||||
}else{
|
} else {
|
||||||
path_constraint->setTarget(NULL);
|
path_constraint->setTarget(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpinePathConstraintData> SpinePathConstraint::get_data(){
|
Ref<SpinePathConstraintData> SpinePathConstraint::get_data() {
|
||||||
auto &sd = path_constraint->getData();
|
auto &sd = path_constraint->getData();
|
||||||
Ref<SpinePathConstraintData> gd_sd(memnew(SpinePathConstraintData));
|
Ref<SpinePathConstraintData> gd_sd(memnew(SpinePathConstraintData));
|
||||||
gd_sd->set_spine_object(&sd);
|
gd_sd->set_spine_object(&sd);
|
||||||
return gd_sd;
|
return gd_sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpinePathConstraint::is_active(){
|
bool SpinePathConstraint::is_active() {
|
||||||
return path_constraint->isActive();
|
return path_constraint->isActive();
|
||||||
}
|
}
|
||||||
void SpinePathConstraint::set_active(bool v){
|
void SpinePathConstraint::set_active(bool v) {
|
||||||
path_constraint->setActive(v);
|
path_constraint->setActive(v);
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@
|
|||||||
#include "SpineSlot.h"
|
#include "SpineSlot.h"
|
||||||
#include "SpinePathConstraintData.h"
|
#include "SpinePathConstraintData.h"
|
||||||
|
|
||||||
class SpinePathConstraint : public Reference{
|
class SpinePathConstraint : public Reference {
|
||||||
GDCLASS(SpinePathConstraint, Reference);
|
GDCLASS(SpinePathConstraint, Reference);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -51,10 +51,10 @@ public:
|
|||||||
SpinePathConstraint();
|
SpinePathConstraint();
|
||||||
~SpinePathConstraint();
|
~SpinePathConstraint();
|
||||||
|
|
||||||
inline void set_spine_object(spine::PathConstraint *pc){
|
inline void set_spine_object(spine::PathConstraint *pc) {
|
||||||
path_constraint = pc;
|
path_constraint = pc;
|
||||||
}
|
}
|
||||||
inline spine::PathConstraint *get_spine_object(){
|
inline spine::PathConstraint *get_spine_object() {
|
||||||
return path_constraint;
|
return path_constraint;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,4 +91,4 @@ public:
|
|||||||
void set_active(bool v);
|
void set_active(bool v);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINEPATHCONSTRAINT_H
|
#endif//GODOT_SPINEPATHCONSTRAINT_H
|
||||||
|
|||||||
@ -68,12 +68,12 @@ void SpinePathConstraintData::_bind_methods() {
|
|||||||
SpinePathConstraintData::SpinePathConstraintData() {}
|
SpinePathConstraintData::SpinePathConstraintData() {}
|
||||||
SpinePathConstraintData::~SpinePathConstraintData() {}
|
SpinePathConstraintData::~SpinePathConstraintData() {}
|
||||||
|
|
||||||
Array SpinePathConstraintData::get_bones(){
|
Array SpinePathConstraintData::get_bones() {
|
||||||
auto bs = get_spine_data()->getBones();
|
auto bs = get_spine_data()->getBones();
|
||||||
Array gd_bs;
|
Array gd_bs;
|
||||||
gd_bs.resize(bs.size());
|
gd_bs.resize(bs.size());
|
||||||
for(size_t i=0; i < bs.size(); ++i){
|
for (size_t i = 0; i < bs.size(); ++i) {
|
||||||
if(bs[i] == NULL) gd_bs[i] = Ref<SpineBoneData>(NULL);
|
if (bs[i] == NULL) gd_bs[i] = Ref<SpineBoneData>(NULL);
|
||||||
else {
|
else {
|
||||||
Ref<SpineBoneData> gd_b(memnew(SpineBoneData));
|
Ref<SpineBoneData> gd_b(memnew(SpineBoneData));
|
||||||
gd_b->set_spine_object(bs[i]);
|
gd_b->set_spine_object(bs[i]);
|
||||||
@ -83,86 +83,86 @@ Array SpinePathConstraintData::get_bones(){
|
|||||||
return gd_bs;
|
return gd_bs;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineSlotData> SpinePathConstraintData::get_target(){
|
Ref<SpineSlotData> SpinePathConstraintData::get_target() {
|
||||||
auto s = get_spine_data()->getTarget();
|
auto s = get_spine_data()->getTarget();
|
||||||
if(s == NULL) return NULL;
|
if (s == NULL) return NULL;
|
||||||
Ref<SpineSlotData> gd_s(memnew(SpineSlotData));
|
Ref<SpineSlotData> gd_s(memnew(SpineSlotData));
|
||||||
gd_s->set_spine_object(s);
|
gd_s->set_spine_object(s);
|
||||||
return gd_s;
|
return gd_s;
|
||||||
}
|
}
|
||||||
void SpinePathConstraintData::set_target(Ref<SpineSlotData> v){
|
void SpinePathConstraintData::set_target(Ref<SpineSlotData> v) {
|
||||||
if(v.is_valid()){
|
if (v.is_valid()) {
|
||||||
get_spine_data()->setTarget(v->get_spine_object());
|
get_spine_data()->setTarget(v->get_spine_object());
|
||||||
}else{
|
} else {
|
||||||
get_spine_data()->setTarget(NULL);
|
get_spine_data()->setTarget(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinePathConstraintData::PositionMode SpinePathConstraintData::get_position_mode(){
|
SpinePathConstraintData::PositionMode SpinePathConstraintData::get_position_mode() {
|
||||||
auto m = (int) get_spine_data()->getPositionMode();
|
auto m = (int) get_spine_data()->getPositionMode();
|
||||||
return (PositionMode) m;
|
return (PositionMode) m;
|
||||||
}
|
}
|
||||||
void SpinePathConstraintData::set_position_mode(PositionMode v){
|
void SpinePathConstraintData::set_position_mode(PositionMode v) {
|
||||||
auto m = (int) v;
|
auto m = (int) v;
|
||||||
get_spine_data()->setPositionMode((spine::PositionMode)m);
|
get_spine_data()->setPositionMode((spine::PositionMode) m);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinePathConstraintData::SpacingMode SpinePathConstraintData::get_spacing_mode(){
|
SpinePathConstraintData::SpacingMode SpinePathConstraintData::get_spacing_mode() {
|
||||||
auto m = (int) get_spine_data()->getSpacingMode();
|
auto m = (int) get_spine_data()->getSpacingMode();
|
||||||
return (SpacingMode) m;
|
return (SpacingMode) m;
|
||||||
}
|
}
|
||||||
void SpinePathConstraintData::set_spacing_mode(SpacingMode v){
|
void SpinePathConstraintData::set_spacing_mode(SpacingMode v) {
|
||||||
auto m = (int) v;
|
auto m = (int) v;
|
||||||
get_spine_data()->setSpacingMode((spine::SpacingMode)m);
|
get_spine_data()->setSpacingMode((spine::SpacingMode) m);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinePathConstraintData::RotateMode SpinePathConstraintData::get_rotate_mode(){
|
SpinePathConstraintData::RotateMode SpinePathConstraintData::get_rotate_mode() {
|
||||||
auto m = (int) get_spine_data()->getRotateMode();
|
auto m = (int) get_spine_data()->getRotateMode();
|
||||||
return (RotateMode) m;
|
return (RotateMode) m;
|
||||||
}
|
}
|
||||||
void SpinePathConstraintData::set_rotate_mode(RotateMode v){
|
void SpinePathConstraintData::set_rotate_mode(RotateMode v) {
|
||||||
auto m = (int) v;
|
auto m = (int) v;
|
||||||
get_spine_data()->setRotateMode((spine::RotateMode)m);
|
get_spine_data()->setRotateMode((spine::RotateMode) m);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpinePathConstraintData::get_offset_rotation(){
|
float SpinePathConstraintData::get_offset_rotation() {
|
||||||
return get_spine_data()->getOffsetRotation();
|
return get_spine_data()->getOffsetRotation();
|
||||||
}
|
}
|
||||||
void SpinePathConstraintData::set_offset_rotation(float v){
|
void SpinePathConstraintData::set_offset_rotation(float v) {
|
||||||
get_spine_data()->setOffsetRotation(v);
|
get_spine_data()->setOffsetRotation(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpinePathConstraintData::get_position(){
|
float SpinePathConstraintData::get_position() {
|
||||||
return get_spine_data()->getPosition();
|
return get_spine_data()->getPosition();
|
||||||
}
|
}
|
||||||
void SpinePathConstraintData::set_position(float v){
|
void SpinePathConstraintData::set_position(float v) {
|
||||||
get_spine_data()->setPosition(v);
|
get_spine_data()->setPosition(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpinePathConstraintData::get_spacing(){
|
float SpinePathConstraintData::get_spacing() {
|
||||||
return get_spine_data()->getSpacing();
|
return get_spine_data()->getSpacing();
|
||||||
}
|
}
|
||||||
void SpinePathConstraintData::set_spacing(float v){
|
void SpinePathConstraintData::set_spacing(float v) {
|
||||||
get_spine_data()->setSpacing(v);
|
get_spine_data()->setSpacing(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpinePathConstraintData::get_mix_rotate(){
|
float SpinePathConstraintData::get_mix_rotate() {
|
||||||
return get_spine_data()->getMixRotate();
|
return get_spine_data()->getMixRotate();
|
||||||
}
|
}
|
||||||
void SpinePathConstraintData::set_mix_rotate(float v){
|
void SpinePathConstraintData::set_mix_rotate(float v) {
|
||||||
get_spine_data()->setMixRotate(v);
|
get_spine_data()->setMixRotate(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpinePathConstraintData::get_mix_x(){
|
float SpinePathConstraintData::get_mix_x() {
|
||||||
return get_spine_data()->getMixX();
|
return get_spine_data()->getMixX();
|
||||||
}
|
}
|
||||||
void SpinePathConstraintData::set_mix_x(float v){
|
void SpinePathConstraintData::set_mix_x(float v) {
|
||||||
get_spine_data()->setMixX(v);
|
get_spine_data()->setMixX(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpinePathConstraintData::get_mix_y(){
|
float SpinePathConstraintData::get_mix_y() {
|
||||||
return get_spine_data()->getMixY();
|
return get_spine_data()->getMixY();
|
||||||
}
|
}
|
||||||
void SpinePathConstraintData::set_mix_y(float v){
|
void SpinePathConstraintData::set_mix_y(float v) {
|
||||||
get_spine_data()->setMixY(v);
|
get_spine_data()->setMixY(v);
|
||||||
}
|
}
|
||||||
@ -48,8 +48,8 @@ public:
|
|||||||
SpinePathConstraintData();
|
SpinePathConstraintData();
|
||||||
~SpinePathConstraintData();
|
~SpinePathConstraintData();
|
||||||
|
|
||||||
virtual inline spine::PathConstraintData *get_spine_data(){
|
virtual inline spine::PathConstraintData *get_spine_data() {
|
||||||
return (spine::PathConstraintData*) SpineConstraintData::get_spine_object();
|
return (spine::PathConstraintData *) SpineConstraintData::get_spine_object();
|
||||||
}
|
}
|
||||||
|
|
||||||
enum PositionMode {
|
enum PositionMode {
|
||||||
@ -105,4 +105,4 @@ public:
|
|||||||
VARIANT_ENUM_CAST(SpinePathConstraintData::PositionMode);
|
VARIANT_ENUM_CAST(SpinePathConstraintData::PositionMode);
|
||||||
VARIANT_ENUM_CAST(SpinePathConstraintData::SpacingMode);
|
VARIANT_ENUM_CAST(SpinePathConstraintData::SpacingMode);
|
||||||
VARIANT_ENUM_CAST(SpinePathConstraintData::RotateMode);
|
VARIANT_ENUM_CAST(SpinePathConstraintData::RotateMode);
|
||||||
#endif //GODOT_SPINEPATHCONSTRAINTDATA_H
|
#endif//GODOT_SPINEPATHCONSTRAINTDATA_H
|
||||||
|
|||||||
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
#include "SpineSprite.h"
|
#include "SpineSprite.h"
|
||||||
|
|
||||||
Error SpineAtlasResourceImportPlugin::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata){
|
Error SpineAtlasResourceImportPlugin::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
|
||||||
Ref<SpineAtlasResource> res(memnew(SpineAtlasResource));
|
Ref<SpineAtlasResource> res(memnew(SpineAtlasResource));
|
||||||
res->set_normal_texture_prefix(p_options["normal_texture_prefix"]);
|
res->set_normal_texture_prefix(p_options["normal_texture_prefix"]);
|
||||||
res->load_from_atlas_file(p_source_file);
|
res->load_from_atlas_file(p_source_file);
|
||||||
@ -57,7 +57,7 @@ void SpineAtlasResourceImportPlugin::get_import_options(List<ImportOption> *r_op
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Error SpineJsonResourceImportPlugin::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata){
|
Error SpineJsonResourceImportPlugin::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
|
||||||
Ref<SpineSkeletonJsonDataResource> res(memnew(SpineSkeletonJsonDataResource));
|
Ref<SpineSkeletonJsonDataResource> res(memnew(SpineSkeletonJsonDataResource));
|
||||||
res->load_from_file(p_source_file);
|
res->load_from_file(p_source_file);
|
||||||
|
|
||||||
@ -82,7 +82,6 @@ SpineRuntimeEditorPlugin::SpineRuntimeEditorPlugin(EditorNode *p_node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SpineRuntimeEditorPlugin::~SpineRuntimeEditorPlugin() {
|
SpineRuntimeEditorPlugin::~SpineRuntimeEditorPlugin() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineRuntimeEditorPlugin::handles(Object *p_object) const {
|
bool SpineRuntimeEditorPlugin::handles(Object *p_object) const {
|
||||||
|
|||||||
@ -37,31 +37,39 @@ class SpineAtlasResourceImportPlugin : public EditorImportPlugin {
|
|||||||
GDCLASS(SpineAtlasResourceImportPlugin, EditorImportPlugin);
|
GDCLASS(SpineAtlasResourceImportPlugin, EditorImportPlugin);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
String get_importer_name() const override {return "spine.atlas";}
|
String get_importer_name() const override { return "spine.atlas"; }
|
||||||
String get_visible_name() const override {return "Spine Runtime Atlas";}
|
String get_visible_name() const override { return "Spine Runtime Atlas"; }
|
||||||
void get_recognized_extensions(List<String> *p_extensions) const override {p_extensions->push_back("atlas");}
|
void get_recognized_extensions(List<String> *p_extensions) const override { p_extensions->push_back("atlas"); }
|
||||||
String get_preset_name(int p_idx) const override {if (p_idx == 0) return "Default"; else return "Unknown";}
|
String get_preset_name(int p_idx) const override {
|
||||||
int get_preset_count() const override {return 1;}
|
if (p_idx == 0) return "Default";
|
||||||
String get_save_extension() const override {return "spatlas";}
|
else
|
||||||
String get_resource_type() const override {return "SpineAtlasResource";}
|
return "Unknown";
|
||||||
|
}
|
||||||
|
int get_preset_count() const override { return 1; }
|
||||||
|
String get_save_extension() const override { return "spatlas"; }
|
||||||
|
String get_resource_type() const override { return "SpineAtlasResource"; }
|
||||||
void get_import_options(List<ImportOption> *r_options, int p_preset) const override;
|
void get_import_options(List<ImportOption> *r_options, int p_preset) const override;
|
||||||
bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override {return true;}
|
bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override { return true; }
|
||||||
Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) override;
|
Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpineJsonResourceImportPlugin : public EditorImportPlugin {
|
class SpineJsonResourceImportPlugin : public EditorImportPlugin {
|
||||||
GDCLASS(SpineJsonResourceImportPlugin, EditorImportPlugin);
|
GDCLASS(SpineJsonResourceImportPlugin, EditorImportPlugin);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
String get_importer_name() const override {return "spine.json";}
|
String get_importer_name() const override { return "spine.json"; }
|
||||||
String get_visible_name() const override {return "Spine Runtime Json";}
|
String get_visible_name() const override { return "Spine Runtime Json"; }
|
||||||
void get_recognized_extensions(List<String> *p_extensions) const override {p_extensions->push_back("json");}
|
void get_recognized_extensions(List<String> *p_extensions) const override { p_extensions->push_back("json"); }
|
||||||
String get_preset_name(int p_idx) const override {if (p_idx == 0) return "Default"; else return "Unknown";}
|
String get_preset_name(int p_idx) const override {
|
||||||
int get_preset_count() const override {return 1;}
|
if (p_idx == 0) return "Default";
|
||||||
String get_save_extension() const override {return "spjson";}
|
else
|
||||||
String get_resource_type() const override {return "SpineSkeletonJsonDataResource";}
|
return "Unknown";
|
||||||
|
}
|
||||||
|
int get_preset_count() const override { return 1; }
|
||||||
|
String get_save_extension() const override { return "spjson"; }
|
||||||
|
String get_resource_type() const override { return "SpineSkeletonJsonDataResource"; }
|
||||||
void get_import_options(List<ImportOption> *r_options, int p_preset) const override {}
|
void get_import_options(List<ImportOption> *r_options, int p_preset) const override {}
|
||||||
bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override {return true;}
|
bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override { return true; }
|
||||||
Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) override;
|
Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -72,6 +80,7 @@ class SpineRuntimeEditorPlugin : public EditorPlugin {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
SpineSpriteAnimateDialog *animate_dialog;
|
SpineSpriteAnimateDialog *animate_dialog;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SpineRuntimeEditorPlugin(EditorNode *p_node);
|
SpineRuntimeEditorPlugin(EditorNode *p_node);
|
||||||
~SpineRuntimeEditorPlugin();
|
~SpineRuntimeEditorPlugin();
|
||||||
@ -86,4 +95,4 @@ public:
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif //GODOT_SPINERUNTIMEEDITORPLUGIN_H
|
#endif//GODOT_SPINERUNTIMEEDITORPLUGIN_H
|
||||||
|
|||||||
@ -30,49 +30,49 @@
|
|||||||
#include "SpineSkeleton.h"
|
#include "SpineSkeleton.h"
|
||||||
|
|
||||||
void SpineSkeleton::_bind_methods() {
|
void SpineSkeleton::_bind_methods() {
|
||||||
//void update_world_transform();
|
//void update_world_transform();
|
||||||
//
|
//
|
||||||
// void set_to_setup_pose();
|
// void set_to_setup_pose();
|
||||||
//
|
//
|
||||||
// void set_bones_to_setup_pose();
|
// void set_bones_to_setup_pose();
|
||||||
//
|
//
|
||||||
// void set_slots_to_setup_pose();
|
// void set_slots_to_setup_pose();
|
||||||
ClassDB::bind_method(D_METHOD("update_world_transform"), &SpineSkeleton::update_world_transform);
|
ClassDB::bind_method(D_METHOD("update_world_transform"), &SpineSkeleton::update_world_transform);
|
||||||
ClassDB::bind_method(D_METHOD("set_to_setup_pose"), &SpineSkeleton::set_to_setup_pose);
|
ClassDB::bind_method(D_METHOD("set_to_setup_pose"), &SpineSkeleton::set_to_setup_pose);
|
||||||
ClassDB::bind_method(D_METHOD("set_bones_to_setup_pose"), &SpineSkeleton::set_bones_to_setup_pose);
|
ClassDB::bind_method(D_METHOD("set_bones_to_setup_pose"), &SpineSkeleton::set_bones_to_setup_pose);
|
||||||
ClassDB::bind_method(D_METHOD("set_slots_to_setup_pose"), &SpineSkeleton::set_slots_to_setup_pose);
|
ClassDB::bind_method(D_METHOD("set_slots_to_setup_pose"), &SpineSkeleton::set_slots_to_setup_pose);
|
||||||
//
|
//
|
||||||
// Ref<SpineBone> find_bone(const String &name);
|
// Ref<SpineBone> find_bone(const String &name);
|
||||||
// int find_bone_index(const String &name);
|
// int find_bone_index(const String &name);
|
||||||
//
|
//
|
||||||
// Ref<SpineSlot> find_slot(const String &name);
|
// Ref<SpineSlot> find_slot(const String &name);
|
||||||
// int find_slot_index(const String &name);
|
// int find_slot_index(const String &name);
|
||||||
//
|
//
|
||||||
// void set_skin_by_name(const String &skin_name);
|
// void set_skin_by_name(const String &skin_name);
|
||||||
// void set_skin(Ref<SpineSkin> new_skin);
|
// void set_skin(Ref<SpineSkin> new_skin);
|
||||||
//
|
//
|
||||||
// Ref<SpineAttachment> get_attachment_by_slot_name(const String &slot_name, const String &attachment_name);
|
// Ref<SpineAttachment> get_attachment_by_slot_name(const String &slot_name, const String &attachment_name);
|
||||||
// Ref<SpineAttachment> get_attachment_by_slot_index(int slot_index, const String &attachment_name);
|
// Ref<SpineAttachment> get_attachment_by_slot_index(int slot_index, const String &attachment_name);
|
||||||
ClassDB::bind_method(D_METHOD("find_bone", "bone_name"), &SpineSkeleton::find_bone);
|
ClassDB::bind_method(D_METHOD("find_bone", "bone_name"), &SpineSkeleton::find_bone);
|
||||||
ClassDB::bind_method(D_METHOD("find_slot", "slot_name"), &SpineSkeleton::find_slot);
|
ClassDB::bind_method(D_METHOD("find_slot", "slot_name"), &SpineSkeleton::find_slot);
|
||||||
ClassDB::bind_method(D_METHOD("set_skin_by_name", "skin_name"), &SpineSkeleton::set_skin_by_name);
|
ClassDB::bind_method(D_METHOD("set_skin_by_name", "skin_name"), &SpineSkeleton::set_skin_by_name);
|
||||||
ClassDB::bind_method(D_METHOD("set_skin", "new_skin"), &SpineSkeleton::set_skin);
|
ClassDB::bind_method(D_METHOD("set_skin", "new_skin"), &SpineSkeleton::set_skin);
|
||||||
ClassDB::bind_method(D_METHOD("get_attachment_by_slot_name", "slot_name", "attachment_name"), &SpineSkeleton::get_attachment_by_slot_name);
|
ClassDB::bind_method(D_METHOD("get_attachment_by_slot_name", "slot_name", "attachment_name"), &SpineSkeleton::get_attachment_by_slot_name);
|
||||||
ClassDB::bind_method(D_METHOD("get_attachment_by_slot_index", "slot_index", "attachment_name"), &SpineSkeleton::get_attachment_by_slot_index);
|
ClassDB::bind_method(D_METHOD("get_attachment_by_slot_index", "slot_index", "attachment_name"), &SpineSkeleton::get_attachment_by_slot_index);
|
||||||
//
|
//
|
||||||
// void set_attachment(const String &slot_name, const String &attachment_name);
|
// void set_attachment(const String &slot_name, const String &attachment_name);
|
||||||
//
|
//
|
||||||
// Ref<SpineIkConstraint> find_ik_constraint(const String &constraint_name);
|
// Ref<SpineIkConstraint> find_ik_constraint(const String &constraint_name);
|
||||||
// Ref<SpineTransformConstraint> find_transform_constraint(const String &constraint_name);
|
// Ref<SpineTransformConstraint> find_transform_constraint(const String &constraint_name);
|
||||||
// Ref<SpinePathConstraint> find_path_constraint(const String &constraint_name);
|
// Ref<SpinePathConstraint> find_path_constraint(const String &constraint_name);
|
||||||
//
|
//
|
||||||
// void update(float delta);
|
// void update(float delta);
|
||||||
//
|
//
|
||||||
// Dictionary get_bounds();
|
// Dictionary get_bounds();
|
||||||
//
|
//
|
||||||
// Ref<SpineBone> get_root_bone();
|
// Ref<SpineBone> get_root_bone();
|
||||||
//
|
//
|
||||||
// Ref<SpineSkeletonDataResource> get_data();
|
// Ref<SpineSkeletonDataResource> get_data();
|
||||||
ClassDB::bind_method(D_METHOD("set_attachment", "slot_name", "attachment_name"), &SpineSkeleton::set_attachment);
|
ClassDB::bind_method(D_METHOD("set_attachment", "slot_name", "attachment_name"), &SpineSkeleton::set_attachment);
|
||||||
ClassDB::bind_method(D_METHOD("find_ik_constraint", "constraint_name"), &SpineSkeleton::find_ik_constraint);
|
ClassDB::bind_method(D_METHOD("find_ik_constraint", "constraint_name"), &SpineSkeleton::find_ik_constraint);
|
||||||
ClassDB::bind_method(D_METHOD("find_transform_constraint", "constraint_name"), &SpineSkeleton::find_transform_constraint);
|
ClassDB::bind_method(D_METHOD("find_transform_constraint", "constraint_name"), &SpineSkeleton::find_transform_constraint);
|
||||||
@ -81,15 +81,15 @@ void SpineSkeleton::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("get_bounds"), &SpineSkeleton::get_bounds);
|
ClassDB::bind_method(D_METHOD("get_bounds"), &SpineSkeleton::get_bounds);
|
||||||
ClassDB::bind_method(D_METHOD("get_root_bone"), &SpineSkeleton::get_root_bone);
|
ClassDB::bind_method(D_METHOD("get_root_bone"), &SpineSkeleton::get_root_bone);
|
||||||
ClassDB::bind_method(D_METHOD("get_data"), &SpineSkeleton::get_data);
|
ClassDB::bind_method(D_METHOD("get_data"), &SpineSkeleton::get_data);
|
||||||
//
|
//
|
||||||
// Array get_bones();
|
// Array get_bones();
|
||||||
// Array get_slots();
|
// Array get_slots();
|
||||||
// Array get_draw_orders();
|
// Array get_draw_orders();
|
||||||
// Array get_ik_constraints();
|
// Array get_ik_constraints();
|
||||||
// Array get_path_constraints();
|
// Array get_path_constraints();
|
||||||
// Array get_transform_constraints();
|
// Array get_transform_constraints();
|
||||||
//
|
//
|
||||||
// Ref<SpineSkin> get_skin();
|
// Ref<SpineSkin> get_skin();
|
||||||
ClassDB::bind_method(D_METHOD("get_bones"), &SpineSkeleton::get_bones);
|
ClassDB::bind_method(D_METHOD("get_bones"), &SpineSkeleton::get_bones);
|
||||||
ClassDB::bind_method(D_METHOD("get_slots"), &SpineSkeleton::get_slots);
|
ClassDB::bind_method(D_METHOD("get_slots"), &SpineSkeleton::get_slots);
|
||||||
ClassDB::bind_method(D_METHOD("get_draw_orders"), &SpineSkeleton::get_draw_orders);
|
ClassDB::bind_method(D_METHOD("get_draw_orders"), &SpineSkeleton::get_draw_orders);
|
||||||
@ -97,31 +97,31 @@ void SpineSkeleton::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("get_path_constraints"), &SpineSkeleton::get_path_constraints);
|
ClassDB::bind_method(D_METHOD("get_path_constraints"), &SpineSkeleton::get_path_constraints);
|
||||||
ClassDB::bind_method(D_METHOD("get_transform_constraints"), &SpineSkeleton::get_transform_constraints);
|
ClassDB::bind_method(D_METHOD("get_transform_constraints"), &SpineSkeleton::get_transform_constraints);
|
||||||
ClassDB::bind_method(D_METHOD("get_skin"), &SpineSkeleton::get_skin);
|
ClassDB::bind_method(D_METHOD("get_skin"), &SpineSkeleton::get_skin);
|
||||||
//
|
//
|
||||||
// Color get_color();
|
// Color get_color();
|
||||||
// void set_color(Color v);
|
// void set_color(Color v);
|
||||||
//
|
//
|
||||||
// float get_time();
|
// float get_time();
|
||||||
// void set_time(float v);
|
// void set_time(float v);
|
||||||
//
|
//
|
||||||
// void set_position(Vector2 pos);
|
// void set_position(Vector2 pos);
|
||||||
ClassDB::bind_method(D_METHOD("get_color"), &SpineSkeleton::get_color);
|
ClassDB::bind_method(D_METHOD("get_color"), &SpineSkeleton::get_color);
|
||||||
ClassDB::bind_method(D_METHOD("set_color", "v"), &SpineSkeleton::set_color);
|
ClassDB::bind_method(D_METHOD("set_color", "v"), &SpineSkeleton::set_color);
|
||||||
ClassDB::bind_method(D_METHOD("get_time"), &SpineSkeleton::get_time);
|
ClassDB::bind_method(D_METHOD("get_time"), &SpineSkeleton::get_time);
|
||||||
ClassDB::bind_method(D_METHOD("set_time", "v"), &SpineSkeleton::set_time);
|
ClassDB::bind_method(D_METHOD("set_time", "v"), &SpineSkeleton::set_time);
|
||||||
ClassDB::bind_method(D_METHOD("set_position", "pos"), &SpineSkeleton::set_position);
|
ClassDB::bind_method(D_METHOD("set_position", "pos"), &SpineSkeleton::set_position);
|
||||||
//
|
//
|
||||||
// float get_x();
|
// float get_x();
|
||||||
// void set_x(float v);
|
// void set_x(float v);
|
||||||
//
|
//
|
||||||
// float get_y();
|
// float get_y();
|
||||||
// void set_y(float v);
|
// void set_y(float v);
|
||||||
//
|
//
|
||||||
// float get_scale_x();
|
// float get_scale_x();
|
||||||
// void set_scale_x(float v);
|
// void set_scale_x(float v);
|
||||||
//
|
//
|
||||||
// float get_scale_y();
|
// float get_scale_y();
|
||||||
// void set_scale_y(float v);
|
// void set_scale_y(float v);
|
||||||
ClassDB::bind_method(D_METHOD("get_x"), &SpineSkeleton::get_x);
|
ClassDB::bind_method(D_METHOD("get_x"), &SpineSkeleton::get_x);
|
||||||
ClassDB::bind_method(D_METHOD("set_x", "v"), &SpineSkeleton::set_x);
|
ClassDB::bind_method(D_METHOD("set_x", "v"), &SpineSkeleton::set_x);
|
||||||
ClassDB::bind_method(D_METHOD("get_y"), &SpineSkeleton::get_y);
|
ClassDB::bind_method(D_METHOD("get_y"), &SpineSkeleton::get_y);
|
||||||
@ -132,21 +132,18 @@ void SpineSkeleton::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_scale_y", "v"), &SpineSkeleton::set_scale_y);
|
ClassDB::bind_method(D_METHOD("set_scale_y", "v"), &SpineSkeleton::set_scale_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineSkeleton::SpineSkeleton():skeleton(NULL),spine_object(false),the_sprite(nullptr) {
|
SpineSkeleton::SpineSkeleton() : skeleton(NULL), spine_object(false), the_sprite(nullptr) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineSkeleton::~SpineSkeleton() {
|
SpineSkeleton::~SpineSkeleton() {
|
||||||
if(skeleton && !spine_object)
|
if (skeleton && !spine_object) {
|
||||||
{
|
|
||||||
delete skeleton;
|
delete skeleton;
|
||||||
skeleton = NULL;
|
skeleton = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSkeleton::load_skeleton(Ref<SpineSkeletonDataResource> sd) {
|
void SpineSkeleton::load_skeleton(Ref<SpineSkeletonDataResource> sd) {
|
||||||
if(skeleton && !spine_object)
|
if (skeleton && !spine_object) {
|
||||||
{
|
|
||||||
delete skeleton;
|
delete skeleton;
|
||||||
skeleton = NULL;
|
skeleton = NULL;
|
||||||
}
|
}
|
||||||
@ -155,103 +152,103 @@ void SpineSkeleton::load_skeleton(Ref<SpineSkeletonDataResource> sd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define S_T(x) (spine::String(x.utf8()))
|
#define S_T(x) (spine::String(x.utf8()))
|
||||||
void SpineSkeleton::update_world_transform(){
|
void SpineSkeleton::update_world_transform() {
|
||||||
skeleton->updateWorldTransform();
|
skeleton->updateWorldTransform();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSkeleton::set_to_setup_pose(){
|
void SpineSkeleton::set_to_setup_pose() {
|
||||||
skeleton->setToSetupPose();
|
skeleton->setToSetupPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSkeleton::set_bones_to_setup_pose(){
|
void SpineSkeleton::set_bones_to_setup_pose() {
|
||||||
skeleton->setBonesToSetupPose();
|
skeleton->setBonesToSetupPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSkeleton::set_slots_to_setup_pose(){
|
void SpineSkeleton::set_slots_to_setup_pose() {
|
||||||
skeleton->setSlotsToSetupPose();
|
skeleton->setSlotsToSetupPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineBone> SpineSkeleton::find_bone(const String &name){
|
Ref<SpineBone> SpineSkeleton::find_bone(const String &name) {
|
||||||
if(name.empty()) return NULL;
|
if (name.empty()) return NULL;
|
||||||
auto b = skeleton->findBone(S_T(name));
|
auto b = skeleton->findBone(S_T(name));
|
||||||
if(b == NULL) return NULL;
|
if (b == NULL) return NULL;
|
||||||
Ref<SpineBone> gd_b(memnew(SpineBone));
|
Ref<SpineBone> gd_b(memnew(SpineBone));
|
||||||
gd_b->set_spine_object(b);
|
gd_b->set_spine_object(b);
|
||||||
gd_b->set_spine_sprite(the_sprite);
|
gd_b->set_spine_sprite(the_sprite);
|
||||||
return gd_b;
|
return gd_b;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineSlot> SpineSkeleton::find_slot(const String &name){
|
Ref<SpineSlot> SpineSkeleton::find_slot(const String &name) {
|
||||||
if(name.empty()) return NULL;
|
if (name.empty()) return NULL;
|
||||||
auto s = skeleton->findSlot(S_T(name));
|
auto s = skeleton->findSlot(S_T(name));
|
||||||
if(s == NULL) return NULL;
|
if (s == NULL) return NULL;
|
||||||
Ref<SpineSlot> gd_s(memnew(SpineSlot));
|
Ref<SpineSlot> gd_s(memnew(SpineSlot));
|
||||||
gd_s->set_spine_object(s);
|
gd_s->set_spine_object(s);
|
||||||
return gd_s;
|
return gd_s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSkeleton::set_skin_by_name(const String &skin_name){
|
void SpineSkeleton::set_skin_by_name(const String &skin_name) {
|
||||||
skeleton->setSkin(S_T(skin_name));
|
skeleton->setSkin(S_T(skin_name));
|
||||||
}
|
}
|
||||||
void SpineSkeleton::set_skin(Ref<SpineSkin> new_skin){
|
void SpineSkeleton::set_skin(Ref<SpineSkin> new_skin) {
|
||||||
if(new_skin.is_valid()){
|
if (new_skin.is_valid()) {
|
||||||
skeleton->setSkin(new_skin->get_spine_object());
|
skeleton->setSkin(new_skin->get_spine_object());
|
||||||
}else{
|
} else {
|
||||||
skeleton->setSkin(NULL);
|
skeleton->setSkin(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineAttachment> SpineSkeleton::get_attachment_by_slot_name(const String &slot_name, const String &attachment_name){
|
Ref<SpineAttachment> SpineSkeleton::get_attachment_by_slot_name(const String &slot_name, const String &attachment_name) {
|
||||||
auto a = skeleton->getAttachment(S_T(slot_name), S_T(attachment_name));
|
auto a = skeleton->getAttachment(S_T(slot_name), S_T(attachment_name));
|
||||||
if(a == NULL) return NULL;
|
if (a == NULL) return NULL;
|
||||||
Ref<SpineAttachment> gd_a(memnew(SpineAttachment));
|
Ref<SpineAttachment> gd_a(memnew(SpineAttachment));
|
||||||
gd_a->set_spine_object(a);
|
gd_a->set_spine_object(a);
|
||||||
return gd_a;
|
return gd_a;
|
||||||
}
|
}
|
||||||
Ref<SpineAttachment> SpineSkeleton::get_attachment_by_slot_index(int slot_index, const String &attachment_name){
|
Ref<SpineAttachment> SpineSkeleton::get_attachment_by_slot_index(int slot_index, const String &attachment_name) {
|
||||||
auto a = skeleton->getAttachment(slot_index, S_T(attachment_name));
|
auto a = skeleton->getAttachment(slot_index, S_T(attachment_name));
|
||||||
if(a == NULL) return NULL;
|
if (a == NULL) return NULL;
|
||||||
Ref<SpineAttachment> gd_a(memnew(SpineAttachment));
|
Ref<SpineAttachment> gd_a(memnew(SpineAttachment));
|
||||||
gd_a->set_spine_object(a);
|
gd_a->set_spine_object(a);
|
||||||
return gd_a;
|
return gd_a;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSkeleton::set_attachment(const String &slot_name, const String &attachment_name){
|
void SpineSkeleton::set_attachment(const String &slot_name, const String &attachment_name) {
|
||||||
ERR_FAIL_COND(slot_name.empty());
|
ERR_FAIL_COND(slot_name.empty());
|
||||||
ERR_FAIL_COND(get_attachment_by_slot_name(slot_name, attachment_name) == NULL);
|
ERR_FAIL_COND(get_attachment_by_slot_name(slot_name, attachment_name) == NULL);
|
||||||
skeleton->setAttachment(S_T(slot_name), S_T(attachment_name));
|
skeleton->setAttachment(S_T(slot_name), S_T(attachment_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineIkConstraint> SpineSkeleton::find_ik_constraint(const String &constraint_name){
|
Ref<SpineIkConstraint> SpineSkeleton::find_ik_constraint(const String &constraint_name) {
|
||||||
if(constraint_name.empty()) return NULL;
|
if (constraint_name.empty()) return NULL;
|
||||||
auto c = skeleton->findIkConstraint(S_T(constraint_name));
|
auto c = skeleton->findIkConstraint(S_T(constraint_name));
|
||||||
if(c == NULL) return NULL;
|
if (c == NULL) return NULL;
|
||||||
Ref<SpineIkConstraint> gd_c(memnew(SpineIkConstraint));
|
Ref<SpineIkConstraint> gd_c(memnew(SpineIkConstraint));
|
||||||
gd_c->set_spine_object(c);
|
gd_c->set_spine_object(c);
|
||||||
return gd_c;
|
return gd_c;
|
||||||
}
|
}
|
||||||
Ref<SpineTransformConstraint> SpineSkeleton::find_transform_constraint(const String &constraint_name){
|
Ref<SpineTransformConstraint> SpineSkeleton::find_transform_constraint(const String &constraint_name) {
|
||||||
if(constraint_name.empty()) return NULL;
|
if (constraint_name.empty()) return NULL;
|
||||||
auto c = skeleton->findTransformConstraint(S_T(constraint_name));
|
auto c = skeleton->findTransformConstraint(S_T(constraint_name));
|
||||||
if(c == NULL) return NULL;
|
if (c == NULL) return NULL;
|
||||||
Ref<SpineTransformConstraint> gd_c(memnew(SpineTransformConstraint));
|
Ref<SpineTransformConstraint> gd_c(memnew(SpineTransformConstraint));
|
||||||
gd_c->set_spine_object(c);
|
gd_c->set_spine_object(c);
|
||||||
return gd_c;
|
return gd_c;
|
||||||
}
|
}
|
||||||
Ref<SpinePathConstraint> SpineSkeleton::find_path_constraint(const String &constraint_name){
|
Ref<SpinePathConstraint> SpineSkeleton::find_path_constraint(const String &constraint_name) {
|
||||||
if(constraint_name.empty()) return NULL;
|
if (constraint_name.empty()) return NULL;
|
||||||
auto c = skeleton->findPathConstraint(S_T(constraint_name));
|
auto c = skeleton->findPathConstraint(S_T(constraint_name));
|
||||||
if(c == NULL) return NULL;
|
if (c == NULL) return NULL;
|
||||||
Ref<SpinePathConstraint> gd_c(memnew(SpinePathConstraint));
|
Ref<SpinePathConstraint> gd_c(memnew(SpinePathConstraint));
|
||||||
gd_c->set_spine_object(c);
|
gd_c->set_spine_object(c);
|
||||||
return gd_c;
|
return gd_c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSkeleton::update(float delta){
|
void SpineSkeleton::update(float delta) {
|
||||||
skeleton->update(delta);
|
skeleton->update(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary SpineSkeleton::get_bounds(){
|
Dictionary SpineSkeleton::get_bounds() {
|
||||||
float x, y, w, h;
|
float x, y, w, h;
|
||||||
spine::Vector<float> vertex_buffer;
|
spine::Vector<float> vertex_buffer;
|
||||||
skeleton->getBounds(x, y, w, h, vertex_buffer);
|
skeleton->getBounds(x, y, w, h, vertex_buffer);
|
||||||
@ -264,7 +261,7 @@ Dictionary SpineSkeleton::get_bounds(){
|
|||||||
|
|
||||||
Array gd_a;
|
Array gd_a;
|
||||||
gd_a.resize(vertex_buffer.size());
|
gd_a.resize(vertex_buffer.size());
|
||||||
for(size_t i=0; i<gd_a.size(); ++i){
|
for (size_t i = 0; i < gd_a.size(); ++i) {
|
||||||
gd_a[i] = vertex_buffer[i];
|
gd_a[i] = vertex_buffer[i];
|
||||||
}
|
}
|
||||||
res["vertex_buffer"] = gd_a;
|
res["vertex_buffer"] = gd_a;
|
||||||
@ -272,9 +269,9 @@ Dictionary SpineSkeleton::get_bounds(){
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineBone> SpineSkeleton::get_root_bone(){
|
Ref<SpineBone> SpineSkeleton::get_root_bone() {
|
||||||
auto b = skeleton->getRootBone();
|
auto b = skeleton->getRootBone();
|
||||||
if(b == NULL) return NULL;
|
if (b == NULL) return NULL;
|
||||||
Ref<SpineBone> gd_b(memnew(SpineBone));
|
Ref<SpineBone> gd_b(memnew(SpineBone));
|
||||||
gd_b->set_spine_object(b);
|
gd_b->set_spine_object(b);
|
||||||
gd_b->set_spine_sprite(the_sprite);
|
gd_b->set_spine_sprite(the_sprite);
|
||||||
@ -283,19 +280,19 @@ Ref<SpineBone> SpineSkeleton::get_root_bone(){
|
|||||||
|
|
||||||
Ref<SpineSkeletonDataResource> SpineSkeleton::get_data() const {
|
Ref<SpineSkeletonDataResource> SpineSkeleton::get_data() const {
|
||||||
auto sd = skeleton->getData();
|
auto sd = skeleton->getData();
|
||||||
if(sd == NULL) return NULL;
|
if (sd == NULL) return NULL;
|
||||||
Ref<SpineSkeletonDataResource> gd_sd(memnew(SpineSkeletonDataResource));
|
Ref<SpineSkeletonDataResource> gd_sd(memnew(SpineSkeletonDataResource));
|
||||||
gd_sd->set_spine_object(sd);
|
gd_sd->set_spine_object(sd);
|
||||||
return gd_sd;
|
return gd_sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array SpineSkeleton::get_bones(){
|
Array SpineSkeleton::get_bones() {
|
||||||
auto &as = skeleton->getBones();
|
auto &as = skeleton->getBones();
|
||||||
Array gd_as;
|
Array gd_as;
|
||||||
gd_as.resize(as.size());
|
gd_as.resize(as.size());
|
||||||
for(size_t i=0; i<gd_as.size(); ++i){
|
for (size_t i = 0; i < gd_as.size(); ++i) {
|
||||||
auto b = as[i];
|
auto b = as[i];
|
||||||
if(b == NULL) gd_as[i] = Ref<SpineBone>(NULL);
|
if (b == NULL) gd_as[i] = Ref<SpineBone>(NULL);
|
||||||
Ref<SpineBone> gd_a(memnew(SpineBone));
|
Ref<SpineBone> gd_a(memnew(SpineBone));
|
||||||
gd_a->set_spine_object(b);
|
gd_a->set_spine_object(b);
|
||||||
gd_a->set_spine_sprite(the_sprite);
|
gd_a->set_spine_sprite(the_sprite);
|
||||||
@ -303,65 +300,65 @@ Array SpineSkeleton::get_bones(){
|
|||||||
}
|
}
|
||||||
return gd_as;
|
return gd_as;
|
||||||
}
|
}
|
||||||
Array SpineSkeleton::get_slots(){
|
Array SpineSkeleton::get_slots() {
|
||||||
auto &as = skeleton->getSlots();
|
auto &as = skeleton->getSlots();
|
||||||
Array gd_as;
|
Array gd_as;
|
||||||
gd_as.resize(as.size());
|
gd_as.resize(as.size());
|
||||||
for(size_t i=0; i<gd_as.size(); ++i){
|
for (size_t i = 0; i < gd_as.size(); ++i) {
|
||||||
auto b = as[i];
|
auto b = as[i];
|
||||||
if(b == NULL) gd_as[i] = Ref<SpineSlot>(NULL);
|
if (b == NULL) gd_as[i] = Ref<SpineSlot>(NULL);
|
||||||
Ref<SpineSlot> gd_a(memnew(SpineSlot));
|
Ref<SpineSlot> gd_a(memnew(SpineSlot));
|
||||||
gd_a->set_spine_object(b);
|
gd_a->set_spine_object(b);
|
||||||
gd_as[i] = gd_a;
|
gd_as[i] = gd_a;
|
||||||
}
|
}
|
||||||
return gd_as;
|
return gd_as;
|
||||||
}
|
}
|
||||||
Array SpineSkeleton::get_draw_orders(){
|
Array SpineSkeleton::get_draw_orders() {
|
||||||
auto &as = skeleton->getDrawOrder();
|
auto &as = skeleton->getDrawOrder();
|
||||||
Array gd_as;
|
Array gd_as;
|
||||||
gd_as.resize(as.size());
|
gd_as.resize(as.size());
|
||||||
for(size_t i=0; i<gd_as.size(); ++i){
|
for (size_t i = 0; i < gd_as.size(); ++i) {
|
||||||
auto b = as[i];
|
auto b = as[i];
|
||||||
if(b == NULL) gd_as[i] = Ref<SpineSlot>(NULL);
|
if (b == NULL) gd_as[i] = Ref<SpineSlot>(NULL);
|
||||||
Ref<SpineSlot> gd_a(memnew(SpineSlot));
|
Ref<SpineSlot> gd_a(memnew(SpineSlot));
|
||||||
gd_a->set_spine_object(b);
|
gd_a->set_spine_object(b);
|
||||||
gd_as[i] = gd_a;
|
gd_as[i] = gd_a;
|
||||||
}
|
}
|
||||||
return gd_as;
|
return gd_as;
|
||||||
}
|
}
|
||||||
Array SpineSkeleton::get_ik_constraints(){
|
Array SpineSkeleton::get_ik_constraints() {
|
||||||
auto &as = skeleton->getIkConstraints();
|
auto &as = skeleton->getIkConstraints();
|
||||||
Array gd_as;
|
Array gd_as;
|
||||||
gd_as.resize(as.size());
|
gd_as.resize(as.size());
|
||||||
for(size_t i=0; i<gd_as.size(); ++i){
|
for (size_t i = 0; i < gd_as.size(); ++i) {
|
||||||
auto b = as[i];
|
auto b = as[i];
|
||||||
if(b == NULL) gd_as[i] = Ref<SpineIkConstraint>(NULL);
|
if (b == NULL) gd_as[i] = Ref<SpineIkConstraint>(NULL);
|
||||||
Ref<SpineIkConstraint> gd_a(memnew(SpineIkConstraint));
|
Ref<SpineIkConstraint> gd_a(memnew(SpineIkConstraint));
|
||||||
gd_a->set_spine_object(b);
|
gd_a->set_spine_object(b);
|
||||||
gd_as[i] = gd_a;
|
gd_as[i] = gd_a;
|
||||||
}
|
}
|
||||||
return gd_as;
|
return gd_as;
|
||||||
}
|
}
|
||||||
Array SpineSkeleton::get_path_constraints(){
|
Array SpineSkeleton::get_path_constraints() {
|
||||||
auto &as = skeleton->getPathConstraints();
|
auto &as = skeleton->getPathConstraints();
|
||||||
Array gd_as;
|
Array gd_as;
|
||||||
gd_as.resize(as.size());
|
gd_as.resize(as.size());
|
||||||
for(size_t i=0; i<gd_as.size(); ++i){
|
for (size_t i = 0; i < gd_as.size(); ++i) {
|
||||||
auto b = as[i];
|
auto b = as[i];
|
||||||
if(b == NULL) gd_as[i] = Ref<SpinePathConstraint>(NULL);
|
if (b == NULL) gd_as[i] = Ref<SpinePathConstraint>(NULL);
|
||||||
Ref<SpinePathConstraint> gd_a(memnew(SpinePathConstraint));
|
Ref<SpinePathConstraint> gd_a(memnew(SpinePathConstraint));
|
||||||
gd_a->set_spine_object(b);
|
gd_a->set_spine_object(b);
|
||||||
gd_as[i] = gd_a;
|
gd_as[i] = gd_a;
|
||||||
}
|
}
|
||||||
return gd_as;
|
return gd_as;
|
||||||
}
|
}
|
||||||
Array SpineSkeleton::get_transform_constraints(){
|
Array SpineSkeleton::get_transform_constraints() {
|
||||||
auto &as = skeleton->getTransformConstraints();
|
auto &as = skeleton->getTransformConstraints();
|
||||||
Array gd_as;
|
Array gd_as;
|
||||||
gd_as.resize(as.size());
|
gd_as.resize(as.size());
|
||||||
for(size_t i=0; i<gd_as.size(); ++i){
|
for (size_t i = 0; i < gd_as.size(); ++i) {
|
||||||
auto b = as[i];
|
auto b = as[i];
|
||||||
if(b == NULL) gd_as[i] = Ref<SpineTransformConstraint>(NULL);
|
if (b == NULL) gd_as[i] = Ref<SpineTransformConstraint>(NULL);
|
||||||
Ref<SpineTransformConstraint> gd_a(memnew(SpineTransformConstraint));
|
Ref<SpineTransformConstraint> gd_a(memnew(SpineTransformConstraint));
|
||||||
gd_a->set_spine_object(b);
|
gd_a->set_spine_object(b);
|
||||||
gd_as[i] = gd_a;
|
gd_as[i] = gd_a;
|
||||||
@ -369,59 +366,59 @@ Array SpineSkeleton::get_transform_constraints(){
|
|||||||
return gd_as;
|
return gd_as;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineSkin> SpineSkeleton::get_skin(){
|
Ref<SpineSkin> SpineSkeleton::get_skin() {
|
||||||
auto s = skeleton->getSkin();
|
auto s = skeleton->getSkin();
|
||||||
if(s == NULL) return NULL;
|
if (s == NULL) return NULL;
|
||||||
Ref<SpineSkin> gd_s(memnew(SpineSkin));
|
Ref<SpineSkin> gd_s(memnew(SpineSkin));
|
||||||
gd_s->set_spine_object(s);
|
gd_s->set_spine_object(s);
|
||||||
return gd_s;
|
return gd_s;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color SpineSkeleton::get_color(){
|
Color SpineSkeleton::get_color() {
|
||||||
auto &c = skeleton->getColor();
|
auto &c = skeleton->getColor();
|
||||||
return Color(c.r, c.g, c.b, c.a);
|
return Color(c.r, c.g, c.b, c.a);
|
||||||
}
|
}
|
||||||
void SpineSkeleton::set_color(Color v){
|
void SpineSkeleton::set_color(Color v) {
|
||||||
auto &c = skeleton->getColor();
|
auto &c = skeleton->getColor();
|
||||||
c.set(v.r, v.g, v.b, v.a);
|
c.set(v.r, v.g, v.b, v.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineSkeleton::get_time(){
|
float SpineSkeleton::get_time() {
|
||||||
return skeleton->getTime();
|
return skeleton->getTime();
|
||||||
}
|
}
|
||||||
void SpineSkeleton::set_time(float v){
|
void SpineSkeleton::set_time(float v) {
|
||||||
skeleton->setTime(v);
|
skeleton->setTime(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSkeleton::set_position(Vector2 pos){
|
void SpineSkeleton::set_position(Vector2 pos) {
|
||||||
skeleton->setPosition(pos.x, pos.y);
|
skeleton->setPosition(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineSkeleton::get_x(){
|
float SpineSkeleton::get_x() {
|
||||||
return skeleton->getX();
|
return skeleton->getX();
|
||||||
}
|
}
|
||||||
void SpineSkeleton::set_x(float v){
|
void SpineSkeleton::set_x(float v) {
|
||||||
skeleton->setX(v);
|
skeleton->setX(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineSkeleton::get_y(){
|
float SpineSkeleton::get_y() {
|
||||||
return skeleton->getY();
|
return skeleton->getY();
|
||||||
}
|
}
|
||||||
void SpineSkeleton::set_y(float v){
|
void SpineSkeleton::set_y(float v) {
|
||||||
skeleton->setY(v);
|
skeleton->setY(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineSkeleton::get_scale_x(){
|
float SpineSkeleton::get_scale_x() {
|
||||||
return skeleton->getScaleX();
|
return skeleton->getScaleX();
|
||||||
}
|
}
|
||||||
void SpineSkeleton::set_scale_x(float v){
|
void SpineSkeleton::set_scale_x(float v) {
|
||||||
skeleton->setScaleX(v);
|
skeleton->setScaleX(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineSkeleton::get_scale_y(){
|
float SpineSkeleton::get_scale_y() {
|
||||||
return skeleton->getScaleY();
|
return skeleton->getScaleY();
|
||||||
}
|
}
|
||||||
void SpineSkeleton::set_scale_y(float v){
|
void SpineSkeleton::set_scale_y(float v) {
|
||||||
skeleton->setScaleY(v);
|
skeleton->setScaleY(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
class SpineSprite;
|
class SpineSprite;
|
||||||
|
|
||||||
class SpineSkeleton : public Reference{
|
class SpineSkeleton : public Reference {
|
||||||
GDCLASS(SpineSkeleton, Reference);
|
GDCLASS(SpineSkeleton, Reference);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -51,18 +51,18 @@ private:
|
|||||||
bool spine_object;
|
bool spine_object;
|
||||||
|
|
||||||
SpineSprite *the_sprite;
|
SpineSprite *the_sprite;
|
||||||
public:
|
|
||||||
|
|
||||||
|
public:
|
||||||
SpineSkeleton();
|
SpineSkeleton();
|
||||||
~SpineSkeleton();
|
~SpineSkeleton();
|
||||||
|
|
||||||
void load_skeleton(Ref<SpineSkeletonDataResource> sd);
|
void load_skeleton(Ref<SpineSkeletonDataResource> sd);
|
||||||
|
|
||||||
inline void set_spine_object(spine::Skeleton *s){
|
inline void set_spine_object(spine::Skeleton *s) {
|
||||||
skeleton = s;
|
skeleton = s;
|
||||||
spine_object = true;
|
spine_object = true;
|
||||||
}
|
}
|
||||||
inline spine::Skeleton *get_spine_object(){
|
inline spine::Skeleton *get_spine_object() {
|
||||||
return skeleton;
|
return skeleton;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +129,6 @@ public:
|
|||||||
|
|
||||||
float get_scale_y();
|
float get_scale_y();
|
||||||
void set_scale_y(float v);
|
void set_scale_y(float v);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINESKELETON_H
|
#endif//GODOT_SPINESKELETON_H
|
||||||
|
|||||||
@ -74,18 +74,16 @@ void SpineSkeletonDataResource::_bind_methods() {
|
|||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "skeleton_json_res", PropertyHint::PROPERTY_HINT_RESOURCE_TYPE, "SpineSkeletonJsonDataResource"), "set_skeleton_json_res", "get_skeleton_json_res");
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "skeleton_json_res", PropertyHint::PROPERTY_HINT_RESOURCE_TYPE, "SpineSkeletonJsonDataResource"), "set_skeleton_json_res", "get_skeleton_json_res");
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineSkeletonDataResource::SpineSkeletonDataResource():valid(false),spine_object(false),skeleton_data(NULL) {
|
SpineSkeletonDataResource::SpineSkeletonDataResource() : valid(false), spine_object(false), skeleton_data(NULL) {
|
||||||
|
|
||||||
}
|
}
|
||||||
SpineSkeletonDataResource::~SpineSkeletonDataResource() {
|
SpineSkeletonDataResource::~SpineSkeletonDataResource() {
|
||||||
if(skeleton_data && !spine_object)
|
if (skeleton_data && !spine_object) {
|
||||||
{
|
|
||||||
delete skeleton_data;
|
delete skeleton_data;
|
||||||
skeleton_data = NULL;
|
skeleton_data = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineSkeletonDataResource::is_skeleton_data_loaded() const{
|
bool SpineSkeletonDataResource::is_skeleton_data_loaded() const {
|
||||||
return valid || spine_object;
|
return valid || spine_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,29 +92,25 @@ void SpineSkeletonDataResource::load_res(spine::Atlas *a, const String &json_str
|
|||||||
auto path = get_path();
|
auto path = get_path();
|
||||||
spine::SkeletonJson json(a);
|
spine::SkeletonJson json(a);
|
||||||
auto temp_skeleton_data = json.readSkeletonData(json_string.utf8());
|
auto temp_skeleton_data = json.readSkeletonData(json_string.utf8());
|
||||||
if(!temp_skeleton_data)
|
if (!temp_skeleton_data) {
|
||||||
{
|
|
||||||
print_error(String("Error happened while loading skeleton json data: ") + path);
|
print_error(String("Error happened while loading skeleton json data: ") + path);
|
||||||
print_error(String("Error msg: ") + json.getError().buffer());
|
print_error(String("Error msg: ") + json.getError().buffer());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(skeleton_data)
|
if (skeleton_data) {
|
||||||
{
|
|
||||||
delete skeleton_data;
|
delete skeleton_data;
|
||||||
skeleton_data = NULL;
|
skeleton_data = NULL;
|
||||||
}
|
}
|
||||||
skeleton_data = temp_skeleton_data;
|
skeleton_data = temp_skeleton_data;
|
||||||
|
|
||||||
valid = true;
|
valid = true;
|
||||||
// print_line("Skeleton json data loaded!");
|
// print_line("Skeleton json data loaded!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSkeletonDataResource::update_skeleton_data() {
|
void SpineSkeletonDataResource::update_skeleton_data() {
|
||||||
if(atlas_res.is_valid() && skeleton_json_res.is_valid())
|
if (atlas_res.is_valid() && skeleton_json_res.is_valid()) {
|
||||||
{
|
|
||||||
load_res(atlas_res->get_spine_atlas(), skeleton_json_res->get_json_string());
|
load_res(atlas_res->get_spine_atlas(), skeleton_json_res->get_json_string());
|
||||||
if(valid)
|
if (valid) {
|
||||||
{
|
|
||||||
emit_signal("skeleton_data_loaded");
|
emit_signal("skeleton_data_loaded");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,12 +119,12 @@ void SpineSkeletonDataResource::update_skeleton_data() {
|
|||||||
void SpineSkeletonDataResource::set_atlas_res(const Ref<SpineAtlasResource> &a) {
|
void SpineSkeletonDataResource::set_atlas_res(const Ref<SpineAtlasResource> &a) {
|
||||||
atlas_res = a;
|
atlas_res = a;
|
||||||
valid = false;
|
valid = false;
|
||||||
// print_line("atlas_res_changed emitted");
|
// print_line("atlas_res_changed emitted");
|
||||||
emit_signal("atlas_res_changed");
|
emit_signal("atlas_res_changed");
|
||||||
update_skeleton_data();
|
update_skeleton_data();
|
||||||
}
|
}
|
||||||
Ref<SpineAtlasResource> SpineSkeletonDataResource::get_atlas_res() {
|
Ref<SpineAtlasResource> SpineSkeletonDataResource::get_atlas_res() {
|
||||||
if(spine_object){
|
if (spine_object) {
|
||||||
print_line("Getting atlas res from a spine_object skeleton! The result may be NULL!");
|
print_line("Getting atlas res from a spine_object skeleton! The result may be NULL!");
|
||||||
}
|
}
|
||||||
return atlas_res;
|
return atlas_res;
|
||||||
@ -139,27 +133,35 @@ Ref<SpineAtlasResource> SpineSkeletonDataResource::get_atlas_res() {
|
|||||||
void SpineSkeletonDataResource::set_skeleton_json_res(const Ref<SpineSkeletonJsonDataResource> &s) {
|
void SpineSkeletonDataResource::set_skeleton_json_res(const Ref<SpineSkeletonJsonDataResource> &s) {
|
||||||
skeleton_json_res = s;
|
skeleton_json_res = s;
|
||||||
valid = false;
|
valid = false;
|
||||||
// print_line("skeleton_json_res_changed emitted");
|
// print_line("skeleton_json_res_changed emitted");
|
||||||
emit_signal("skeleton_json_res_changed");
|
emit_signal("skeleton_json_res_changed");
|
||||||
update_skeleton_data();
|
update_skeleton_data();
|
||||||
}
|
}
|
||||||
Ref<SpineSkeletonJsonDataResource> SpineSkeletonDataResource::get_skeleton_json_res() {
|
Ref<SpineSkeletonJsonDataResource> SpineSkeletonDataResource::get_skeleton_json_res() {
|
||||||
if(spine_object){
|
if (spine_object) {
|
||||||
print_line("Getting atlas res from a spine_object skeleton! The result may be NULL!");
|
print_line("Getting atlas res from a spine_object skeleton! The result may be NULL!");
|
||||||
}
|
}
|
||||||
return skeleton_json_res;
|
return skeleton_json_res;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_V if(!is_skeleton_data_loaded()){ERR_PRINT("skeleton data has not loaded yet!");return;}
|
#define CHECK_V \
|
||||||
#define CHECK_X(x) if(!is_skeleton_data_loaded()){ERR_PRINT("skeleton data has not loaded yet!");return x;}
|
if (!is_skeleton_data_loaded()) { \
|
||||||
|
ERR_PRINT("skeleton data has not loaded yet!"); \
|
||||||
|
return; \
|
||||||
|
}
|
||||||
|
#define CHECK_X(x) \
|
||||||
|
if (!is_skeleton_data_loaded()) { \
|
||||||
|
ERR_PRINT("skeleton data has not loaded yet!"); \
|
||||||
|
return x; \
|
||||||
|
}
|
||||||
#define S_T(x) (spine::String(x.utf8()))
|
#define S_T(x) (spine::String(x.utf8()))
|
||||||
Ref<SpineAnimation> SpineSkeletonDataResource::find_animation(const String &animation_name) {
|
Ref<SpineAnimation> SpineSkeletonDataResource::find_animation(const String &animation_name) {
|
||||||
CHECK_X(NULL);
|
CHECK_X(NULL);
|
||||||
if(animation_name.empty()){
|
if (animation_name.empty()) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
auto a = skeleton_data->findAnimation(S_T(animation_name));
|
auto a = skeleton_data->findAnimation(S_T(animation_name));
|
||||||
if(!a) return NULL;
|
if (!a) return NULL;
|
||||||
Ref<SpineAnimation> sa(memnew(SpineAnimation));
|
Ref<SpineAnimation> sa(memnew(SpineAnimation));
|
||||||
sa->set_spine_object(a);
|
sa->set_spine_object(a);
|
||||||
return sa;
|
return sa;
|
||||||
@ -209,73 +211,73 @@ void SpineSkeletonDataResource::set_fps(float v) {
|
|||||||
skeleton_data->setFps(v);
|
skeleton_data->setFps(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineBoneData> SpineSkeletonDataResource::find_bone(const String &bone_name){
|
Ref<SpineBoneData> SpineSkeletonDataResource::find_bone(const String &bone_name) {
|
||||||
if(bone_name.empty()) return NULL;
|
if (bone_name.empty()) return NULL;
|
||||||
auto b = skeleton_data->findBone(S_T(bone_name));
|
auto b = skeleton_data->findBone(S_T(bone_name));
|
||||||
if(b == NULL) return NULL;
|
if (b == NULL) return NULL;
|
||||||
Ref<SpineBoneData> gd_b(memnew(SpineBoneData));
|
Ref<SpineBoneData> gd_b(memnew(SpineBoneData));
|
||||||
gd_b->set_spine_object(b);
|
gd_b->set_spine_object(b);
|
||||||
return gd_b;
|
return gd_b;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineSlotData> SpineSkeletonDataResource::find_slot(const String &slot_name){
|
Ref<SpineSlotData> SpineSkeletonDataResource::find_slot(const String &slot_name) {
|
||||||
if(slot_name.empty()) return NULL;
|
if (slot_name.empty()) return NULL;
|
||||||
auto b = skeleton_data->findSlot(S_T(slot_name));
|
auto b = skeleton_data->findSlot(S_T(slot_name));
|
||||||
if(b == NULL) return NULL;
|
if (b == NULL) return NULL;
|
||||||
Ref<SpineSlotData> gd_b(memnew(SpineSlotData));
|
Ref<SpineSlotData> gd_b(memnew(SpineSlotData));
|
||||||
gd_b->set_spine_object(b);
|
gd_b->set_spine_object(b);
|
||||||
return gd_b;
|
return gd_b;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineSkin> SpineSkeletonDataResource::find_skin(const String &skin_name){
|
Ref<SpineSkin> SpineSkeletonDataResource::find_skin(const String &skin_name) {
|
||||||
if(skin_name.empty()) return NULL;
|
if (skin_name.empty()) return NULL;
|
||||||
auto b = skeleton_data->findSkin(S_T(skin_name));
|
auto b = skeleton_data->findSkin(S_T(skin_name));
|
||||||
if(b == NULL) return NULL;
|
if (b == NULL) return NULL;
|
||||||
Ref<SpineSkin> gd_b(memnew(SpineSkin));
|
Ref<SpineSkin> gd_b(memnew(SpineSkin));
|
||||||
gd_b->set_spine_object(b);
|
gd_b->set_spine_object(b);
|
||||||
return gd_b;
|
return gd_b;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineEventData> SpineSkeletonDataResource::find_event(const String &event_data_name){
|
Ref<SpineEventData> SpineSkeletonDataResource::find_event(const String &event_data_name) {
|
||||||
if(event_data_name.empty()) return NULL;
|
if (event_data_name.empty()) return NULL;
|
||||||
auto b = skeleton_data->findEvent(S_T(event_data_name));
|
auto b = skeleton_data->findEvent(S_T(event_data_name));
|
||||||
if(b == NULL) return NULL;
|
if (b == NULL) return NULL;
|
||||||
Ref<SpineEventData> gd_b(memnew(SpineEventData));
|
Ref<SpineEventData> gd_b(memnew(SpineEventData));
|
||||||
gd_b->set_spine_object(b);
|
gd_b->set_spine_object(b);
|
||||||
return gd_b;
|
return gd_b;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineIkConstraintData> SpineSkeletonDataResource::find_ik_constraint(const String &constraint_name){
|
Ref<SpineIkConstraintData> SpineSkeletonDataResource::find_ik_constraint(const String &constraint_name) {
|
||||||
if(constraint_name.empty()) return NULL;
|
if (constraint_name.empty()) return NULL;
|
||||||
auto b = skeleton_data->findIkConstraint(S_T(constraint_name));
|
auto b = skeleton_data->findIkConstraint(S_T(constraint_name));
|
||||||
if(b == NULL) return NULL;
|
if (b == NULL) return NULL;
|
||||||
Ref<SpineIkConstraintData> gd_b(memnew(SpineIkConstraintData));
|
Ref<SpineIkConstraintData> gd_b(memnew(SpineIkConstraintData));
|
||||||
gd_b->set_spine_object(b);
|
gd_b->set_spine_object(b);
|
||||||
return gd_b;
|
return gd_b;
|
||||||
}
|
}
|
||||||
Ref<SpineTransformConstraintData> SpineSkeletonDataResource::find_transform_constraint(const String &constraint_name){
|
Ref<SpineTransformConstraintData> SpineSkeletonDataResource::find_transform_constraint(const String &constraint_name) {
|
||||||
if(constraint_name.empty()) return NULL;
|
if (constraint_name.empty()) return NULL;
|
||||||
auto b = skeleton_data->findTransformConstraint(S_T(constraint_name));
|
auto b = skeleton_data->findTransformConstraint(S_T(constraint_name));
|
||||||
if(b == NULL) return NULL;
|
if (b == NULL) return NULL;
|
||||||
Ref<SpineTransformConstraintData> gd_b(memnew(SpineTransformConstraintData));
|
Ref<SpineTransformConstraintData> gd_b(memnew(SpineTransformConstraintData));
|
||||||
gd_b->set_spine_object(b);
|
gd_b->set_spine_object(b);
|
||||||
return gd_b;
|
return gd_b;
|
||||||
}
|
}
|
||||||
Ref<SpinePathConstraintData> SpineSkeletonDataResource::find_path_constraint(const String &constraint_name){
|
Ref<SpinePathConstraintData> SpineSkeletonDataResource::find_path_constraint(const String &constraint_name) {
|
||||||
if(constraint_name.empty()) return NULL;
|
if (constraint_name.empty()) return NULL;
|
||||||
auto b = skeleton_data->findPathConstraint(S_T(constraint_name));
|
auto b = skeleton_data->findPathConstraint(S_T(constraint_name));
|
||||||
if(b == NULL) return NULL;
|
if (b == NULL) return NULL;
|
||||||
Ref<SpinePathConstraintData> gd_b(memnew(SpinePathConstraintData));
|
Ref<SpinePathConstraintData> gd_b(memnew(SpinePathConstraintData));
|
||||||
gd_b->set_spine_object(b);
|
gd_b->set_spine_object(b);
|
||||||
return gd_b;
|
return gd_b;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array SpineSkeletonDataResource::get_bones(){
|
Array SpineSkeletonDataResource::get_bones() {
|
||||||
auto bs = skeleton_data->getBones();
|
auto bs = skeleton_data->getBones();
|
||||||
Array gd_bs;
|
Array gd_bs;
|
||||||
gd_bs.resize(bs.size());
|
gd_bs.resize(bs.size());
|
||||||
for(size_t i=0; i < bs.size(); ++i){
|
for (size_t i = 0; i < bs.size(); ++i) {
|
||||||
if(bs[i] == NULL) gd_bs[i] = Ref<SpineBoneData>(NULL);
|
if (bs[i] == NULL) gd_bs[i] = Ref<SpineBoneData>(NULL);
|
||||||
else {
|
else {
|
||||||
Ref<SpineBoneData> gd_b(memnew(SpineBoneData));
|
Ref<SpineBoneData> gd_b(memnew(SpineBoneData));
|
||||||
gd_b->set_spine_object(bs[i]);
|
gd_b->set_spine_object(bs[i]);
|
||||||
@ -284,12 +286,12 @@ Array SpineSkeletonDataResource::get_bones(){
|
|||||||
}
|
}
|
||||||
return gd_bs;
|
return gd_bs;
|
||||||
}
|
}
|
||||||
Array SpineSkeletonDataResource::get_slots(){
|
Array SpineSkeletonDataResource::get_slots() {
|
||||||
auto bs = skeleton_data->getSlots();
|
auto bs = skeleton_data->getSlots();
|
||||||
Array gd_bs;
|
Array gd_bs;
|
||||||
gd_bs.resize(bs.size());
|
gd_bs.resize(bs.size());
|
||||||
for(size_t i=0; i < bs.size(); ++i){
|
for (size_t i = 0; i < bs.size(); ++i) {
|
||||||
if(bs[i] == NULL) gd_bs[i] = Ref<SpineSlotData>(NULL);
|
if (bs[i] == NULL) gd_bs[i] = Ref<SpineSlotData>(NULL);
|
||||||
else {
|
else {
|
||||||
Ref<SpineSlotData> gd_b(memnew(SpineSlotData));
|
Ref<SpineSlotData> gd_b(memnew(SpineSlotData));
|
||||||
gd_b->set_spine_object(bs[i]);
|
gd_b->set_spine_object(bs[i]);
|
||||||
@ -298,12 +300,12 @@ Array SpineSkeletonDataResource::get_slots(){
|
|||||||
}
|
}
|
||||||
return gd_bs;
|
return gd_bs;
|
||||||
}
|
}
|
||||||
Array SpineSkeletonDataResource::get_skins() const{
|
Array SpineSkeletonDataResource::get_skins() const {
|
||||||
auto bs = skeleton_data->getSkins();
|
auto bs = skeleton_data->getSkins();
|
||||||
Array gd_bs;
|
Array gd_bs;
|
||||||
gd_bs.resize(bs.size());
|
gd_bs.resize(bs.size());
|
||||||
for(size_t i=0; i < bs.size(); ++i){
|
for (size_t i = 0; i < bs.size(); ++i) {
|
||||||
if(bs[i] == NULL) gd_bs[i] = Ref<SpineSkin>(NULL);
|
if (bs[i] == NULL) gd_bs[i] = Ref<SpineSkin>(NULL);
|
||||||
else {
|
else {
|
||||||
Ref<SpineSkin> gd_b(memnew(SpineSkin));
|
Ref<SpineSkin> gd_b(memnew(SpineSkin));
|
||||||
gd_b->set_spine_object(bs[i]);
|
gd_b->set_spine_object(bs[i]);
|
||||||
@ -313,26 +315,26 @@ Array SpineSkeletonDataResource::get_skins() const{
|
|||||||
return gd_bs;
|
return gd_bs;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineSkin> SpineSkeletonDataResource::get_default_skin(){
|
Ref<SpineSkin> SpineSkeletonDataResource::get_default_skin() {
|
||||||
auto b = skeleton_data->getDefaultSkin();
|
auto b = skeleton_data->getDefaultSkin();
|
||||||
if(b == NULL) return NULL;
|
if (b == NULL) return NULL;
|
||||||
Ref<SpineSkin> gd_b(memnew(SpineSkin));
|
Ref<SpineSkin> gd_b(memnew(SpineSkin));
|
||||||
gd_b->set_spine_object(b);
|
gd_b->set_spine_object(b);
|
||||||
return gd_b;
|
return gd_b;
|
||||||
}
|
}
|
||||||
void SpineSkeletonDataResource::set_default_skin(Ref<SpineSkin> v){
|
void SpineSkeletonDataResource::set_default_skin(Ref<SpineSkin> v) {
|
||||||
if(v.is_valid()){
|
if (v.is_valid()) {
|
||||||
skeleton_data->setDefaultSkin(v->get_spine_object());
|
skeleton_data->setDefaultSkin(v->get_spine_object());
|
||||||
} else
|
} else
|
||||||
skeleton_data->setDefaultSkin(NULL);
|
skeleton_data->setDefaultSkin(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Array SpineSkeletonDataResource::get_events(){
|
Array SpineSkeletonDataResource::get_events() {
|
||||||
auto bs = skeleton_data->getEvents();
|
auto bs = skeleton_data->getEvents();
|
||||||
Array gd_bs;
|
Array gd_bs;
|
||||||
gd_bs.resize(bs.size());
|
gd_bs.resize(bs.size());
|
||||||
for(size_t i=0; i < bs.size(); ++i){
|
for (size_t i = 0; i < bs.size(); ++i) {
|
||||||
if(bs[i] == NULL) gd_bs[i] = Ref<SpineEventData>(NULL);
|
if (bs[i] == NULL) gd_bs[i] = Ref<SpineEventData>(NULL);
|
||||||
else {
|
else {
|
||||||
Ref<SpineEventData> gd_b(memnew(SpineEventData));
|
Ref<SpineEventData> gd_b(memnew(SpineEventData));
|
||||||
gd_b->set_spine_object(bs[i]);
|
gd_b->set_spine_object(bs[i]);
|
||||||
@ -341,12 +343,12 @@ Array SpineSkeletonDataResource::get_events(){
|
|||||||
}
|
}
|
||||||
return gd_bs;
|
return gd_bs;
|
||||||
}
|
}
|
||||||
Array SpineSkeletonDataResource::get_animations(){
|
Array SpineSkeletonDataResource::get_animations() {
|
||||||
auto bs = skeleton_data->getAnimations();
|
auto bs = skeleton_data->getAnimations();
|
||||||
Array gd_bs;
|
Array gd_bs;
|
||||||
gd_bs.resize(bs.size());
|
gd_bs.resize(bs.size());
|
||||||
for(size_t i=0; i < bs.size(); ++i){
|
for (size_t i = 0; i < bs.size(); ++i) {
|
||||||
if(bs[i] == NULL) gd_bs[i] = Ref<SpineAnimation>(NULL);
|
if (bs[i] == NULL) gd_bs[i] = Ref<SpineAnimation>(NULL);
|
||||||
else {
|
else {
|
||||||
Ref<SpineAnimation> gd_b(memnew(SpineAnimation));
|
Ref<SpineAnimation> gd_b(memnew(SpineAnimation));
|
||||||
gd_b->set_spine_object(bs[i]);
|
gd_b->set_spine_object(bs[i]);
|
||||||
@ -355,12 +357,12 @@ Array SpineSkeletonDataResource::get_animations(){
|
|||||||
}
|
}
|
||||||
return gd_bs;
|
return gd_bs;
|
||||||
}
|
}
|
||||||
Array SpineSkeletonDataResource::get_ik_constraints(){
|
Array SpineSkeletonDataResource::get_ik_constraints() {
|
||||||
auto bs = skeleton_data->getIkConstraints();
|
auto bs = skeleton_data->getIkConstraints();
|
||||||
Array gd_bs;
|
Array gd_bs;
|
||||||
gd_bs.resize(bs.size());
|
gd_bs.resize(bs.size());
|
||||||
for(size_t i=0; i < bs.size(); ++i){
|
for (size_t i = 0; i < bs.size(); ++i) {
|
||||||
if(bs[i] == NULL) gd_bs[i] = Ref<SpineIkConstraintData>(NULL);
|
if (bs[i] == NULL) gd_bs[i] = Ref<SpineIkConstraintData>(NULL);
|
||||||
else {
|
else {
|
||||||
Ref<SpineIkConstraintData> gd_b(memnew(SpineIkConstraintData));
|
Ref<SpineIkConstraintData> gd_b(memnew(SpineIkConstraintData));
|
||||||
gd_b->set_spine_object(bs[i]);
|
gd_b->set_spine_object(bs[i]);
|
||||||
@ -369,12 +371,12 @@ Array SpineSkeletonDataResource::get_ik_constraints(){
|
|||||||
}
|
}
|
||||||
return gd_bs;
|
return gd_bs;
|
||||||
}
|
}
|
||||||
Array SpineSkeletonDataResource::get_transform_constraints(){
|
Array SpineSkeletonDataResource::get_transform_constraints() {
|
||||||
auto bs = skeleton_data->getTransformConstraints();
|
auto bs = skeleton_data->getTransformConstraints();
|
||||||
Array gd_bs;
|
Array gd_bs;
|
||||||
gd_bs.resize(bs.size());
|
gd_bs.resize(bs.size());
|
||||||
for(size_t i=0; i < bs.size(); ++i){
|
for (size_t i = 0; i < bs.size(); ++i) {
|
||||||
if(bs[i] == NULL) gd_bs[i] = Ref<SpineTransformConstraintData>(NULL);
|
if (bs[i] == NULL) gd_bs[i] = Ref<SpineTransformConstraintData>(NULL);
|
||||||
else {
|
else {
|
||||||
Ref<SpineTransformConstraintData> gd_b(memnew(SpineTransformConstraintData));
|
Ref<SpineTransformConstraintData> gd_b(memnew(SpineTransformConstraintData));
|
||||||
gd_b->set_spine_object(bs[i]);
|
gd_b->set_spine_object(bs[i]);
|
||||||
@ -383,12 +385,12 @@ Array SpineSkeletonDataResource::get_transform_constraints(){
|
|||||||
}
|
}
|
||||||
return gd_bs;
|
return gd_bs;
|
||||||
}
|
}
|
||||||
Array SpineSkeletonDataResource::get_path_constraints(){
|
Array SpineSkeletonDataResource::get_path_constraints() {
|
||||||
auto bs = skeleton_data->getPathConstraints();
|
auto bs = skeleton_data->getPathConstraints();
|
||||||
Array gd_bs;
|
Array gd_bs;
|
||||||
gd_bs.resize(bs.size());
|
gd_bs.resize(bs.size());
|
||||||
for(size_t i=0; i < bs.size(); ++i){
|
for (size_t i = 0; i < bs.size(); ++i) {
|
||||||
if(bs[i] == NULL) gd_bs[i] = Ref<SpinePathConstraintData>(NULL);
|
if (bs[i] == NULL) gd_bs[i] = Ref<SpinePathConstraintData>(NULL);
|
||||||
else {
|
else {
|
||||||
Ref<SpinePathConstraintData> gd_b(memnew(SpinePathConstraintData));
|
Ref<SpinePathConstraintData> gd_b(memnew(SpinePathConstraintData));
|
||||||
gd_b->set_spine_object(bs[i]);
|
gd_b->set_spine_object(bs[i]);
|
||||||
@ -402,39 +404,39 @@ Array SpineSkeletonDataResource::get_path_constraints(){
|
|||||||
#undef CHECK_X
|
#undef CHECK_X
|
||||||
|
|
||||||
//External feature functions
|
//External feature functions
|
||||||
void SpineSkeletonDataResource::get_animation_names(Vector<String> &res) const{
|
void SpineSkeletonDataResource::get_animation_names(Vector<String> &res) const {
|
||||||
res.clear();
|
res.clear();
|
||||||
if(!is_skeleton_data_loaded()){
|
if (!is_skeleton_data_loaded()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto as = skeleton_data->getAnimations();
|
auto as = skeleton_data->getAnimations();
|
||||||
for(size_t i=0; i<as.size(); ++i){
|
for (size_t i = 0; i < as.size(); ++i) {
|
||||||
auto a = as[i];
|
auto a = as[i];
|
||||||
if(a){
|
if (a) {
|
||||||
res.push_back(a->getName().buffer());
|
res.push_back(a->getName().buffer());
|
||||||
}else{
|
} else {
|
||||||
res.push_back("");
|
res.push_back("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SpineSkeletonDataResource::get_skin_names(Vector<String> &res) const{
|
void SpineSkeletonDataResource::get_skin_names(Vector<String> &res) const {
|
||||||
res.clear();
|
res.clear();
|
||||||
if(!is_skeleton_data_loaded()){
|
if (!is_skeleton_data_loaded()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto as = get_skins();
|
auto as = get_skins();
|
||||||
res.resize(as.size());
|
res.resize(as.size());
|
||||||
for(size_t i=0; i<as.size(); ++i){
|
for (size_t i = 0; i < as.size(); ++i) {
|
||||||
auto a = Ref<SpineSkin>(as[i]);
|
auto a = Ref<SpineSkin>(as[i]);
|
||||||
if(a.is_valid()){
|
if (a.is_valid()) {
|
||||||
res.push_back(a->get_skin_name());
|
res.push_back(a->get_skin_name());
|
||||||
}else{
|
} else {
|
||||||
res.push_back("");
|
res.push_back("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSkeletonDataResource::_get_property_list(List<PropertyInfo> *p_list) const{
|
void SpineSkeletonDataResource::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||||
PropertyInfo p;
|
PropertyInfo p;
|
||||||
Vector<String> res;
|
Vector<String> res;
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,7 @@
|
|||||||
#include "SpinePathConstraintData.h"
|
#include "SpinePathConstraintData.h"
|
||||||
#include "SpineEventData.h"
|
#include "SpineEventData.h"
|
||||||
|
|
||||||
class SpineSkeletonDataResource : public Resource{
|
class SpineSkeletonDataResource : public Resource {
|
||||||
GDCLASS(SpineSkeletonDataResource, Resource);
|
GDCLASS(SpineSkeletonDataResource, Resource);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -60,14 +60,14 @@ private:
|
|||||||
spine::SkeletonData *skeleton_data;
|
spine::SkeletonData *skeleton_data;
|
||||||
|
|
||||||
void update_skeleton_data();
|
void update_skeleton_data();
|
||||||
public:
|
|
||||||
|
|
||||||
inline void set_spine_object(spine::SkeletonData *s){
|
public:
|
||||||
|
inline void set_spine_object(spine::SkeletonData *s) {
|
||||||
skeleton_data = s;
|
skeleton_data = s;
|
||||||
if(s)
|
if (s)
|
||||||
spine_object = true;
|
spine_object = true;
|
||||||
}
|
}
|
||||||
inline spine::SkeletonData *get_spine_object(){
|
inline spine::SkeletonData *get_spine_object() {
|
||||||
return skeleton_data;
|
return skeleton_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ public:
|
|||||||
void set_skeleton_json_res(const Ref<SpineSkeletonJsonDataResource> &s);
|
void set_skeleton_json_res(const Ref<SpineSkeletonJsonDataResource> &s);
|
||||||
Ref<SpineSkeletonJsonDataResource> get_skeleton_json_res();
|
Ref<SpineSkeletonJsonDataResource> get_skeleton_json_res();
|
||||||
|
|
||||||
inline spine::SkeletonData *get_skeleton_data(){return skeleton_data;}
|
inline spine::SkeletonData *get_skeleton_data() { return skeleton_data; }
|
||||||
|
|
||||||
bool is_skeleton_data_loaded() const;
|
bool is_skeleton_data_loaded() const;
|
||||||
|
|
||||||
@ -137,4 +137,4 @@ public:
|
|||||||
void set_fps(float v);
|
void set_fps(float v);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINESKELETONDATARESOURCE_H
|
#endif//GODOT_SPINESKELETONDATARESOURCE_H
|
||||||
|
|||||||
@ -32,18 +32,19 @@
|
|||||||
|
|
||||||
#include "core/variant_parser.h"
|
#include "core/variant_parser.h"
|
||||||
|
|
||||||
class SpineSkeletonJsonDataResource : public Resource{
|
class SpineSkeletonJsonDataResource : public Resource {
|
||||||
GDCLASS(SpineSkeletonJsonDataResource, Resource);
|
GDCLASS(SpineSkeletonJsonDataResource, Resource);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
String json_string;
|
String json_string;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline const String &get_json_string() {return json_string;}
|
inline const String &get_json_string() { return json_string; }
|
||||||
|
|
||||||
Error load_from_file(const String &p_path);
|
Error load_from_file(const String &p_path);
|
||||||
Error save_to_file(const String &p_path);
|
Error save_to_file(const String &p_path);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINESKELETONJSONDATARESOURCE_H
|
#endif//GODOT_SPINESKELETONJSONDATARESOURCE_H
|
||||||
|
|||||||
@ -47,53 +47,53 @@ void SpineSkin::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("get_all_constraint_data"), &SpineSkin::get_constraint);
|
ClassDB::bind_method(D_METHOD("get_all_constraint_data"), &SpineSkin::get_constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineSkin::SpineSkin():skin(NULL) {}
|
SpineSkin::SpineSkin() : skin(NULL) {}
|
||||||
SpineSkin::~SpineSkin() {}
|
SpineSkin::~SpineSkin() {}
|
||||||
|
|
||||||
#define S_T(x) (spine::String(x.utf8()))
|
#define S_T(x) (spine::String(x.utf8()))
|
||||||
Ref<SpineSkin> SpineSkin::init(const String &name){
|
Ref<SpineSkin> SpineSkin::init(const String &name) {
|
||||||
skin = new spine::Skin(S_T(name));
|
skin = new spine::Skin(S_T(name));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSkin::set_attachment(uint64_t slot_index, const String &name, Ref<SpineAttachment> attachment){
|
void SpineSkin::set_attachment(uint64_t slot_index, const String &name, Ref<SpineAttachment> attachment) {
|
||||||
if(!attachment.is_valid()){
|
if (!attachment.is_valid()) {
|
||||||
ERR_PRINT("attachment is invalid!");
|
ERR_PRINT("attachment is invalid!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
skin->setAttachment(slot_index, S_T(name), attachment->get_spine_object());
|
skin->setAttachment(slot_index, S_T(name), attachment->get_spine_object());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineAttachment> SpineSkin::get_attachment(uint64_t slot_index, const String &name){
|
Ref<SpineAttachment> SpineSkin::get_attachment(uint64_t slot_index, const String &name) {
|
||||||
auto a = skin->getAttachment(slot_index, S_T(name));
|
auto a = skin->getAttachment(slot_index, S_T(name));
|
||||||
if(a == NULL) return NULL;
|
if (a == NULL) return NULL;
|
||||||
Ref<SpineAttachment> gd_attachment(memnew(SpineAttachment));
|
Ref<SpineAttachment> gd_attachment(memnew(SpineAttachment));
|
||||||
gd_attachment->set_spine_object(a);
|
gd_attachment->set_spine_object(a);
|
||||||
return gd_attachment;
|
return gd_attachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSkin::remove_attachment(uint64_t slot_index, const String &name){
|
void SpineSkin::remove_attachment(uint64_t slot_index, const String &name) {
|
||||||
skin->removeAttachment(slot_index, S_T(name));
|
skin->removeAttachment(slot_index, S_T(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
Array SpineSkin::find_names_for_slot(uint64_t slot_index){
|
Array SpineSkin::find_names_for_slot(uint64_t slot_index) {
|
||||||
spine::Vector<spine::String> names;
|
spine::Vector<spine::String> names;
|
||||||
skin->findNamesForSlot(slot_index, names);
|
skin->findNamesForSlot(slot_index, names);
|
||||||
Array gd_names;
|
Array gd_names;
|
||||||
gd_names.resize(names.size());
|
gd_names.resize(names.size());
|
||||||
for(size_t i=0; i < names.size(); ++i){
|
for (size_t i = 0; i < names.size(); ++i) {
|
||||||
gd_names[i] = names[i].buffer();
|
gd_names[i] = names[i].buffer();
|
||||||
}
|
}
|
||||||
return gd_names;
|
return gd_names;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array SpineSkin::find_attachments_for_slot(uint64_t slot_index){
|
Array SpineSkin::find_attachments_for_slot(uint64_t slot_index) {
|
||||||
spine::Vector<spine::Attachment*> as;
|
spine::Vector<spine::Attachment *> as;
|
||||||
skin->findAttachmentsForSlot(slot_index, as);
|
skin->findAttachmentsForSlot(slot_index, as);
|
||||||
Array gd_as;
|
Array gd_as;
|
||||||
gd_as.resize(as.size());
|
gd_as.resize(as.size());
|
||||||
for(size_t i=0; i < as.size(); ++i){
|
for (size_t i = 0; i < as.size(); ++i) {
|
||||||
if(as[i] == NULL) gd_as[i] = Ref<SpineAttachment>(NULL);
|
if (as[i] == NULL) gd_as[i] = Ref<SpineAttachment>(NULL);
|
||||||
else {
|
else {
|
||||||
Ref<SpineAttachment> gd_a(memnew(SpineAttachment));
|
Ref<SpineAttachment> gd_a(memnew(SpineAttachment));
|
||||||
gd_a->set_spine_object(as[i]);
|
gd_a->set_spine_object(as[i]);
|
||||||
@ -103,41 +103,40 @@ Array SpineSkin::find_attachments_for_slot(uint64_t slot_index){
|
|||||||
return gd_as;
|
return gd_as;
|
||||||
}
|
}
|
||||||
|
|
||||||
String SpineSkin::get_skin_name(){
|
String SpineSkin::get_skin_name() {
|
||||||
return skin->getName().buffer();
|
return skin->getName().buffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSkin::add_skin(Ref<SpineSkin> other){
|
void SpineSkin::add_skin(Ref<SpineSkin> other) {
|
||||||
if(other.is_valid() && other->get_spine_object()){
|
if (other.is_valid() && other->get_spine_object()) {
|
||||||
skin->addSkin(other->get_spine_object());
|
skin->addSkin(other->get_spine_object());
|
||||||
} else{
|
} else {
|
||||||
ERR_PRINT("other is NULL!");
|
ERR_PRINT("other is NULL!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSkin::copy_skin(Ref<SpineSkin> other){
|
void SpineSkin::copy_skin(Ref<SpineSkin> other) {
|
||||||
if(other.is_valid() && other->get_spine_object()){
|
if (other.is_valid() && other->get_spine_object()) {
|
||||||
skin->copySkin(other->get_spine_object());
|
skin->copySkin(other->get_spine_object());
|
||||||
} else{
|
} else {
|
||||||
ERR_PRINT("other is NULL!");
|
ERR_PRINT("other is NULL!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineSkinAttachmentMapEntries> SpineSkin::get_attachments(){
|
Ref<SpineSkinAttachmentMapEntries> SpineSkin::get_attachments() {
|
||||||
auto *es = new spine::Skin::AttachmentMap::Entries(skin->getAttachments());
|
auto *es = new spine::Skin::AttachmentMap::Entries(skin->getAttachments());
|
||||||
Ref<SpineSkinAttachmentMapEntries> gd_es(memnew(SpineSkinAttachmentMapEntries));
|
Ref<SpineSkinAttachmentMapEntries> gd_es(memnew(SpineSkinAttachmentMapEntries));
|
||||||
gd_es->set_spine_object(es);
|
gd_es->set_spine_object(es);
|
||||||
return gd_es;
|
return gd_es;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Array SpineSkin::get_bones(){
|
Array SpineSkin::get_bones() {
|
||||||
auto bs = skin->getBones();
|
auto bs = skin->getBones();
|
||||||
Array gd_bs;
|
Array gd_bs;
|
||||||
gd_bs.resize(bs.size());
|
gd_bs.resize(bs.size());
|
||||||
for(size_t i=0; i < bs.size(); ++i){
|
for (size_t i = 0; i < bs.size(); ++i) {
|
||||||
if(bs[i] == NULL) gd_bs[i] = Ref<SpineBoneData>(NULL);
|
if (bs[i] == NULL) gd_bs[i] = Ref<SpineBoneData>(NULL);
|
||||||
else{
|
else {
|
||||||
Ref<SpineBoneData> gd_b(memnew(SpineBoneData));
|
Ref<SpineBoneData> gd_b(memnew(SpineBoneData));
|
||||||
gd_b->set_spine_object(bs[i]);
|
gd_b->set_spine_object(bs[i]);
|
||||||
gd_bs[i] = gd_b;
|
gd_bs[i] = gd_b;
|
||||||
@ -146,13 +145,13 @@ Array SpineSkin::get_bones(){
|
|||||||
return gd_bs;
|
return gd_bs;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array SpineSkin::get_constraint(){
|
Array SpineSkin::get_constraint() {
|
||||||
auto cs = skin->getConstraints();
|
auto cs = skin->getConstraints();
|
||||||
Array gd_cs;
|
Array gd_cs;
|
||||||
gd_cs.resize(cs.size());
|
gd_cs.resize(cs.size());
|
||||||
for(size_t i=0; i < cs.size(); ++i){
|
for (size_t i = 0; i < cs.size(); ++i) {
|
||||||
if(cs[i] == NULL) gd_cs[i] = Ref<SpineConstraintData>(NULL);
|
if (cs[i] == NULL) gd_cs[i] = Ref<SpineConstraintData>(NULL);
|
||||||
else{
|
else {
|
||||||
Ref<SpineConstraintData> gd_c(memnew(SpineConstraintData));
|
Ref<SpineConstraintData> gd_c(memnew(SpineConstraintData));
|
||||||
gd_c->set_spine_object(cs[i]);
|
gd_c->set_spine_object(cs[i]);
|
||||||
gd_cs[i] = gd_c;
|
gd_cs[i] = gd_c;
|
||||||
|
|||||||
@ -50,10 +50,10 @@ public:
|
|||||||
SpineSkin();
|
SpineSkin();
|
||||||
~SpineSkin();
|
~SpineSkin();
|
||||||
|
|
||||||
inline void set_spine_object(spine::Skin *s){
|
inline void set_spine_object(spine::Skin *s) {
|
||||||
skin = s;
|
skin = s;
|
||||||
}
|
}
|
||||||
spine::Skin *get_spine_object(){
|
spine::Skin *get_spine_object() {
|
||||||
return skin;
|
return skin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,4 +82,4 @@ public:
|
|||||||
Array get_constraint();
|
Array get_constraint();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINESKIN_H
|
#endif//GODOT_SPINESKIN_H
|
||||||
|
|||||||
@ -38,33 +38,33 @@ void SpineSkinAttachmentMapEntry::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_attachment", "v"), &SpineSkinAttachmentMapEntry::set_attachment);
|
ClassDB::bind_method(D_METHOD("set_attachment", "v"), &SpineSkinAttachmentMapEntry::set_attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineSkinAttachmentMapEntry::SpineSkinAttachmentMapEntry():entry(NULL) {}
|
SpineSkinAttachmentMapEntry::SpineSkinAttachmentMapEntry() : entry(NULL) {}
|
||||||
SpineSkinAttachmentMapEntry::~SpineSkinAttachmentMapEntry() {}
|
SpineSkinAttachmentMapEntry::~SpineSkinAttachmentMapEntry() {}
|
||||||
|
|
||||||
uint64_t SpineSkinAttachmentMapEntry::get_slot_index(){
|
uint64_t SpineSkinAttachmentMapEntry::get_slot_index() {
|
||||||
return entry->_slotIndex;
|
return entry->_slotIndex;
|
||||||
}
|
}
|
||||||
void SpineSkinAttachmentMapEntry::set_slot_index(uint64_t v){
|
void SpineSkinAttachmentMapEntry::set_slot_index(uint64_t v) {
|
||||||
entry->_slotIndex = v;
|
entry->_slotIndex = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
String SpineSkinAttachmentMapEntry::get_entry_name(){
|
String SpineSkinAttachmentMapEntry::get_entry_name() {
|
||||||
return entry->_name.buffer();
|
return entry->_name.buffer();
|
||||||
}
|
}
|
||||||
void SpineSkinAttachmentMapEntry::set_entry_name(const String &v){
|
void SpineSkinAttachmentMapEntry::set_entry_name(const String &v) {
|
||||||
entry->_name = spine::String(v.utf8());
|
entry->_name = spine::String(v.utf8());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineAttachment> SpineSkinAttachmentMapEntry::get_attachment(){
|
Ref<SpineAttachment> SpineSkinAttachmentMapEntry::get_attachment() {
|
||||||
if(entry->_attachment == NULL) return NULL;
|
if (entry->_attachment == NULL) return NULL;
|
||||||
Ref<SpineAttachment> gd_attachment(memnew(SpineAttachment));
|
Ref<SpineAttachment> gd_attachment(memnew(SpineAttachment));
|
||||||
gd_attachment->set_spine_object(entry->_attachment);
|
gd_attachment->set_spine_object(entry->_attachment);
|
||||||
return gd_attachment;
|
return gd_attachment;
|
||||||
}
|
}
|
||||||
void SpineSkinAttachmentMapEntry::set_attachment(Ref<SpineAttachment> v){
|
void SpineSkinAttachmentMapEntry::set_attachment(Ref<SpineAttachment> v) {
|
||||||
if(v.is_valid()){
|
if (v.is_valid()) {
|
||||||
entry->_attachment = v->get_spine_object();
|
entry->_attachment = v->get_spine_object();
|
||||||
}else{
|
} else {
|
||||||
entry->_attachment = NULL;
|
entry->_attachment = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,18 +74,18 @@ void SpineSkinAttachmentMapEntries::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("next"), &SpineSkinAttachmentMapEntries::next);
|
ClassDB::bind_method(D_METHOD("next"), &SpineSkinAttachmentMapEntries::next);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineSkinAttachmentMapEntries::SpineSkinAttachmentMapEntries():entries(NULL) {}
|
SpineSkinAttachmentMapEntries::SpineSkinAttachmentMapEntries() : entries(NULL) {}
|
||||||
SpineSkinAttachmentMapEntries::~SpineSkinAttachmentMapEntries() {
|
SpineSkinAttachmentMapEntries::~SpineSkinAttachmentMapEntries() {
|
||||||
if(entries){
|
if (entries) {
|
||||||
delete entries;
|
delete entries;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineSkinAttachmentMapEntries::has_next(){
|
bool SpineSkinAttachmentMapEntries::has_next() {
|
||||||
return entries->hasNext();
|
return entries->hasNext();
|
||||||
}
|
}
|
||||||
Ref<SpineSkinAttachmentMapEntry> SpineSkinAttachmentMapEntries::next(){
|
Ref<SpineSkinAttachmentMapEntry> SpineSkinAttachmentMapEntries::next() {
|
||||||
auto &e = entries->next();
|
auto &e = entries->next();
|
||||||
Ref<SpineSkinAttachmentMapEntry> gd_entry(memnew(SpineSkinAttachmentMapEntry));
|
Ref<SpineSkinAttachmentMapEntry> gd_entry(memnew(SpineSkinAttachmentMapEntry));
|
||||||
gd_entry->set_spine_object(&e);
|
gd_entry->set_spine_object(&e);
|
||||||
|
|||||||
@ -49,10 +49,10 @@ public:
|
|||||||
SpineSkinAttachmentMapEntry();
|
SpineSkinAttachmentMapEntry();
|
||||||
~SpineSkinAttachmentMapEntry();
|
~SpineSkinAttachmentMapEntry();
|
||||||
|
|
||||||
inline void set_spine_object(spine::Skin::AttachmentMap::Entry *e){
|
inline void set_spine_object(spine::Skin::AttachmentMap::Entry *e) {
|
||||||
entry = e;
|
entry = e;
|
||||||
}
|
}
|
||||||
inline spine::Skin::AttachmentMap::Entry *get_spine_object(){
|
inline spine::Skin::AttachmentMap::Entry *get_spine_object() {
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,10 +79,10 @@ public:
|
|||||||
SpineSkinAttachmentMapEntries();
|
SpineSkinAttachmentMapEntries();
|
||||||
~SpineSkinAttachmentMapEntries();
|
~SpineSkinAttachmentMapEntries();
|
||||||
|
|
||||||
inline void set_spine_object(spine::Skin::AttachmentMap::Entries *e){
|
inline void set_spine_object(spine::Skin::AttachmentMap::Entries *e) {
|
||||||
entries = e;
|
entries = e;
|
||||||
}
|
}
|
||||||
inline spine::Skin::AttachmentMap::Entries *get_spine_object(){
|
inline spine::Skin::AttachmentMap::Entries *get_spine_object() {
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,4 +90,4 @@ public:
|
|||||||
Ref<SpineSkinAttachmentMapEntry> next();
|
Ref<SpineSkinAttachmentMapEntry> next();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINESKINATTACHMENTMAPENTRIES_H
|
#endif//GODOT_SPINESKINATTACHMENTMAPENTRIES_H
|
||||||
|
|||||||
@ -51,98 +51,98 @@ void SpineSlot::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_deform", "v"), &SpineSlot::set_deform);
|
ClassDB::bind_method(D_METHOD("set_deform", "v"), &SpineSlot::set_deform);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineSlot::SpineSlot():slot(NULL) {}
|
SpineSlot::SpineSlot() : slot(NULL) {}
|
||||||
SpineSlot::~SpineSlot() {}
|
SpineSlot::~SpineSlot() {}
|
||||||
|
|
||||||
void SpineSlot::set_to_setup_pos(){
|
void SpineSlot::set_to_setup_pos() {
|
||||||
slot->setToSetupPose();
|
slot->setToSetupPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineSlotData> SpineSlot::get_data(){
|
Ref<SpineSlotData> SpineSlot::get_data() {
|
||||||
auto &sd = slot->getData();
|
auto &sd = slot->getData();
|
||||||
Ref<SpineSlotData> gd_sd(memnew(SpineSlotData));
|
Ref<SpineSlotData> gd_sd(memnew(SpineSlotData));
|
||||||
gd_sd->set_spine_object(&sd);
|
gd_sd->set_spine_object(&sd);
|
||||||
return gd_sd;
|
return gd_sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineBone> SpineSlot::get_bone(){
|
Ref<SpineBone> SpineSlot::get_bone() {
|
||||||
auto &b = slot->getBone();
|
auto &b = slot->getBone();
|
||||||
Ref<SpineBone> gd_b(memnew(SpineBone));
|
Ref<SpineBone> gd_b(memnew(SpineBone));
|
||||||
gd_b->set_spine_object(&b);
|
gd_b->set_spine_object(&b);
|
||||||
return gd_b;
|
return gd_b;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineSkeleton> SpineSlot::get_skeleton(){
|
Ref<SpineSkeleton> SpineSlot::get_skeleton() {
|
||||||
auto &s = slot->getSkeleton();
|
auto &s = slot->getSkeleton();
|
||||||
Ref<SpineSkeleton> gd_s(memnew(SpineSkeleton));
|
Ref<SpineSkeleton> gd_s(memnew(SpineSkeleton));
|
||||||
gd_s->set_spine_object(&s);
|
gd_s->set_spine_object(&s);
|
||||||
return gd_s;
|
return gd_s;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color SpineSlot::get_color(){
|
Color SpineSlot::get_color() {
|
||||||
auto &c = slot->getColor();
|
auto &c = slot->getColor();
|
||||||
return Color(c.r, c.g, c.b, c.a);
|
return Color(c.r, c.g, c.b, c.a);
|
||||||
}
|
}
|
||||||
void SpineSlot::set_color(Color v){
|
void SpineSlot::set_color(Color v) {
|
||||||
auto &c = slot->getColor();
|
auto &c = slot->getColor();
|
||||||
c.set(v.r, v.g, v.b, v.a);
|
c.set(v.r, v.g, v.b, v.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color SpineSlot::get_dark_color(){
|
Color SpineSlot::get_dark_color() {
|
||||||
auto &c = slot->getDarkColor();
|
auto &c = slot->getDarkColor();
|
||||||
return Color(c.r, c.g, c.b, c.a);
|
return Color(c.r, c.g, c.b, c.a);
|
||||||
}
|
}
|
||||||
void SpineSlot::set_dark_color(Color v){
|
void SpineSlot::set_dark_color(Color v) {
|
||||||
auto &c = slot->getDarkColor();
|
auto &c = slot->getDarkColor();
|
||||||
c.set(v.r, v.g, v.b, v.a);
|
c.set(v.r, v.g, v.b, v.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineSlot::has_dark_color(){
|
bool SpineSlot::has_dark_color() {
|
||||||
return slot->hasDarkColor();
|
return slot->hasDarkColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineAttachment> SpineSlot::get_attachment(){
|
Ref<SpineAttachment> SpineSlot::get_attachment() {
|
||||||
auto a = slot->getAttachment();
|
auto a = slot->getAttachment();
|
||||||
if(a == NULL) return NULL;
|
if (a == NULL) return NULL;
|
||||||
Ref<SpineAttachment> gd_a(memnew(SpineAttachment));
|
Ref<SpineAttachment> gd_a(memnew(SpineAttachment));
|
||||||
gd_a->set_spine_object(a);
|
gd_a->set_spine_object(a);
|
||||||
return gd_a;
|
return gd_a;
|
||||||
}
|
}
|
||||||
void SpineSlot::set_attachment(Ref<SpineAttachment> v){
|
void SpineSlot::set_attachment(Ref<SpineAttachment> v) {
|
||||||
if(v.is_valid()){
|
if (v.is_valid()) {
|
||||||
slot->setAttachment(v->get_spine_object());
|
slot->setAttachment(v->get_spine_object());
|
||||||
}else{
|
} else {
|
||||||
slot->setAttachment(NULL);
|
slot->setAttachment(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int SpineSlot::get_attachment_state(){
|
int SpineSlot::get_attachment_state() {
|
||||||
return slot->getAttachmentState();
|
return slot->getAttachmentState();
|
||||||
}
|
}
|
||||||
void SpineSlot::set_attachment_state(int v){
|
void SpineSlot::set_attachment_state(int v) {
|
||||||
slot->setAttachmentState(v);
|
slot->setAttachmentState(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineSlot::get_attachment_time(){
|
float SpineSlot::get_attachment_time() {
|
||||||
return slot->getAttachmentTime();
|
return slot->getAttachmentTime();
|
||||||
}
|
}
|
||||||
void SpineSlot::set_attachment_time(float v){
|
void SpineSlot::set_attachment_time(float v) {
|
||||||
slot->setAttachmentTime(v);
|
slot->setAttachmentTime(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
Array SpineSlot::get_deform(){
|
Array SpineSlot::get_deform() {
|
||||||
auto &ds = slot->getDeform();
|
auto &ds = slot->getDeform();
|
||||||
Array gd_ds;
|
Array gd_ds;
|
||||||
gd_ds.resize(ds.size());
|
gd_ds.resize(ds.size());
|
||||||
for(size_t i=0; i < ds.size(); ++i){
|
for (size_t i = 0; i < ds.size(); ++i) {
|
||||||
gd_ds[i] = ds[i];
|
gd_ds[i] = ds[i];
|
||||||
}
|
}
|
||||||
return gd_ds;
|
return gd_ds;
|
||||||
}
|
}
|
||||||
void SpineSlot::set_deform(Array gd_ds){
|
void SpineSlot::set_deform(Array gd_ds) {
|
||||||
auto &ds = slot->getDeform();
|
auto &ds = slot->getDeform();
|
||||||
ds.setSize(gd_ds.size(), 0);
|
ds.setSize(gd_ds.size(), 0);
|
||||||
for(size_t i=0; i < gd_ds.size(); ++i){
|
for (size_t i = 0; i < gd_ds.size(); ++i) {
|
||||||
ds[i] = gd_ds[i];
|
ds[i] = gd_ds[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ class SpineSkeleton;
|
|||||||
|
|
||||||
class SpineBone;
|
class SpineBone;
|
||||||
|
|
||||||
class SpineSlot : public Reference{
|
class SpineSlot : public Reference {
|
||||||
GDCLASS(SpineSlot, Reference);
|
GDCLASS(SpineSlot, Reference);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -54,10 +54,10 @@ public:
|
|||||||
SpineSlot();
|
SpineSlot();
|
||||||
~SpineSlot();
|
~SpineSlot();
|
||||||
|
|
||||||
inline void set_spine_object(spine::Slot *s){
|
inline void set_spine_object(spine::Slot *s) {
|
||||||
slot = s;
|
slot = s;
|
||||||
}
|
}
|
||||||
inline spine::Slot *get_spine_object(){
|
inline spine::Slot *get_spine_object() {
|
||||||
return slot;
|
return slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,4 +90,4 @@ public:
|
|||||||
void set_deform(Array v);
|
void set_deform(Array v);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINESLOT_H
|
#endif//GODOT_SPINESLOT_H
|
||||||
|
|||||||
@ -51,62 +51,62 @@ void SpineSlotData::_bind_methods() {
|
|||||||
BIND_ENUM_CONSTANT(BLENDMODE_SCREEN);
|
BIND_ENUM_CONSTANT(BLENDMODE_SCREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineSlotData::SpineSlotData():slot_data(NULL) {}
|
SpineSlotData::SpineSlotData() : slot_data(NULL) {}
|
||||||
SpineSlotData::~SpineSlotData() {}
|
SpineSlotData::~SpineSlotData() {}
|
||||||
|
|
||||||
#define S_T(x) (spine::String(x.utf8()))
|
#define S_T(x) (spine::String(x.utf8()))
|
||||||
int SpineSlotData::get_index(){
|
int SpineSlotData::get_index() {
|
||||||
return slot_data->getIndex();
|
return slot_data->getIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
String SpineSlotData::get_slot_name(){
|
String SpineSlotData::get_slot_name() {
|
||||||
return slot_data->getName().buffer();
|
return slot_data->getName().buffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineBoneData> SpineSlotData::get_bone_data(){
|
Ref<SpineBoneData> SpineSlotData::get_bone_data() {
|
||||||
auto &bd = slot_data->getBoneData();
|
auto &bd = slot_data->getBoneData();
|
||||||
Ref<SpineBoneData> gd_bone_data(memnew(SpineBoneData));
|
Ref<SpineBoneData> gd_bone_data(memnew(SpineBoneData));
|
||||||
gd_bone_data->set_spine_object(&bd);
|
gd_bone_data->set_spine_object(&bd);
|
||||||
return gd_bone_data;
|
return gd_bone_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color SpineSlotData::get_color(){
|
Color SpineSlotData::get_color() {
|
||||||
auto &c = slot_data->getColor();
|
auto &c = slot_data->getColor();
|
||||||
return Color(c.r, c.g, c.b, c.a);
|
return Color(c.r, c.g, c.b, c.a);
|
||||||
}
|
}
|
||||||
void SpineSlotData::set_color(Color v){
|
void SpineSlotData::set_color(Color v) {
|
||||||
auto &c = slot_data->getColor();
|
auto &c = slot_data->getColor();
|
||||||
c.set(v.r, v.g, v.b, v.a);
|
c.set(v.r, v.g, v.b, v.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color SpineSlotData::get_dark_color(){
|
Color SpineSlotData::get_dark_color() {
|
||||||
auto &c = slot_data->getDarkColor();
|
auto &c = slot_data->getDarkColor();
|
||||||
return Color(c.r, c.g, c.b, c.a);
|
return Color(c.r, c.g, c.b, c.a);
|
||||||
}
|
}
|
||||||
void SpineSlotData::set_dark_color(Color v){
|
void SpineSlotData::set_dark_color(Color v) {
|
||||||
auto &c = slot_data->getDarkColor();
|
auto &c = slot_data->getDarkColor();
|
||||||
c.set(v.r, v.g, v.b, v.a);
|
c.set(v.r, v.g, v.b, v.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineSlotData::has_dark_color(){
|
bool SpineSlotData::has_dark_color() {
|
||||||
return slot_data->hasDarkColor();
|
return slot_data->hasDarkColor();
|
||||||
}
|
}
|
||||||
void SpineSlotData::set_has_dark_color(bool v){
|
void SpineSlotData::set_has_dark_color(bool v) {
|
||||||
slot_data->setHasDarkColor(v);
|
slot_data->setHasDarkColor(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
String SpineSlotData::get_attachment_name(){
|
String SpineSlotData::get_attachment_name() {
|
||||||
return slot_data->getAttachmentName().buffer();
|
return slot_data->getAttachmentName().buffer();
|
||||||
}
|
}
|
||||||
void SpineSlotData::set_attachment_name(const String &v){
|
void SpineSlotData::set_attachment_name(const String &v) {
|
||||||
slot_data->setAttachmentName(S_T(v));
|
slot_data->setAttachmentName(S_T(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineSlotData::BlendMode SpineSlotData::get_blend_mode(){
|
SpineSlotData::BlendMode SpineSlotData::get_blend_mode() {
|
||||||
auto bm = (int) slot_data->getBlendMode();
|
auto bm = (int) slot_data->getBlendMode();
|
||||||
return (BlendMode) bm;
|
return (BlendMode) bm;
|
||||||
}
|
}
|
||||||
void SpineSlotData::set_blend_mode(BlendMode v){
|
void SpineSlotData::set_blend_mode(BlendMode v) {
|
||||||
auto bm = (int) v;
|
auto bm = (int) v;
|
||||||
slot_data->setBlendMode((spine::BlendMode) bm);
|
slot_data->setBlendMode((spine::BlendMode) bm);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,10 +48,10 @@ public:
|
|||||||
SpineSlotData();
|
SpineSlotData();
|
||||||
~SpineSlotData();
|
~SpineSlotData();
|
||||||
|
|
||||||
inline void set_spine_object(spine::SlotData *s){
|
inline void set_spine_object(spine::SlotData *s) {
|
||||||
slot_data = s;
|
slot_data = s;
|
||||||
}
|
}
|
||||||
inline spine::SlotData *get_spine_object(){
|
inline spine::SlotData *get_spine_object() {
|
||||||
return slot_data;
|
return slot_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,4 +85,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
VARIANT_ENUM_CAST(SpineSlotData::BlendMode);
|
VARIANT_ENUM_CAST(SpineSlotData::BlendMode);
|
||||||
#endif //GODOT_SPINESLOTDATA_H
|
#endif//GODOT_SPINESLOTDATA_H
|
||||||
|
|||||||
@ -98,11 +98,9 @@ void SpineSprite::_bind_methods() {
|
|||||||
BIND_ENUM_CONSTANT(ProcessMode::ProcessMode_Manual);
|
BIND_ENUM_CONSTANT(ProcessMode::ProcessMode_Manual);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineSprite::SpineSprite() :
|
SpineSprite::SpineSprite() : select_track_id(0), empty_animation_duration(0.2f), skeleton_clipper(NULL),
|
||||||
select_track_id(0), empty_animation_duration(0.2f), skeleton_clipper(NULL),
|
|
||||||
overlap(false),
|
overlap(false),
|
||||||
process_mode(ProcessMode_Process)
|
process_mode(ProcessMode_Process) {
|
||||||
{
|
|
||||||
skeleton_clipper = new spine::SkeletonClipping();
|
skeleton_clipper = new spine::SkeletonClipping();
|
||||||
}
|
}
|
||||||
SpineSprite::~SpineSprite() {
|
SpineSprite::~SpineSprite() {
|
||||||
@ -111,7 +109,7 @@ SpineSprite::~SpineSprite() {
|
|||||||
|
|
||||||
void SpineSprite::_notification(int p_what) {
|
void SpineSprite::_notification(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case NOTIFICATION_READY:{
|
case NOTIFICATION_READY: {
|
||||||
set_process_internal(process_mode == ProcessMode_Process);
|
set_process_internal(process_mode == ProcessMode_Process);
|
||||||
set_physics_process_internal(process_mode == ProcessMode_Physics);
|
set_physics_process_internal(process_mode == ProcessMode_Physics);
|
||||||
remove_redundant_mesh_instances();
|
remove_redundant_mesh_instances();
|
||||||
@ -146,74 +144,70 @@ void SpineSprite::_update_all(float delta) {
|
|||||||
update_bind_slot_nodes();
|
update_bind_slot_nodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSprite::update_bind_slot_nodes(){
|
void SpineSprite::update_bind_slot_nodes() {
|
||||||
if(animation_state.is_valid() && skeleton.is_valid()){
|
if (animation_state.is_valid() && skeleton.is_valid()) {
|
||||||
for(size_t i=0, n=bind_slot_nodes.size(); i<n; ++i){
|
for (size_t i = 0, n = bind_slot_nodes.size(); i < n; ++i) {
|
||||||
auto a = bind_slot_nodes[i];
|
auto a = bind_slot_nodes[i];
|
||||||
if(a.get_type() == Variant::DICTIONARY){
|
if (a.get_type() == Variant::DICTIONARY) {
|
||||||
auto d = (Dictionary) a;
|
auto d = (Dictionary) a;
|
||||||
if(d.has("slot_name") && d.has("node_path")){
|
if (d.has("slot_name") && d.has("node_path")) {
|
||||||
NodePath node_path = d["node_path"];
|
NodePath node_path = d["node_path"];
|
||||||
Node *node = get_node_or_null(node_path);
|
Node *node = get_node_or_null(node_path);
|
||||||
if(node && node->is_class("Node2D")){
|
if (node && node->is_class("Node2D")) {
|
||||||
Node2D *node2d = (Node2D*) node;
|
Node2D *node2d = (Node2D *) node;
|
||||||
|
|
||||||
String slot_name = d["slot_name"];
|
String slot_name = d["slot_name"];
|
||||||
auto slot = skeleton->find_slot(slot_name);
|
auto slot = skeleton->find_slot(slot_name);
|
||||||
if(slot.is_valid()){
|
if (slot.is_valid()) {
|
||||||
auto bone = slot->get_bone();
|
auto bone = slot->get_bone();
|
||||||
if(bone.is_valid())
|
if (bone.is_valid()) {
|
||||||
{
|
|
||||||
update_bind_slot_node_transform(bone, node2d);
|
update_bind_slot_node_transform(bone, node2d);
|
||||||
update_bind_slot_node_draw_order(slot_name, node2d);
|
update_bind_slot_node_draw_order(slot_name, node2d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if(a.get_type() == Variant::ARRAY){
|
} else if (a.get_type() == Variant::ARRAY) {
|
||||||
auto as = (Array) a;// 0: slot_name, 1: node_path
|
auto as = (Array) a;// 0: slot_name, 1: node_path
|
||||||
if(as.size() >= 2 && as[0].get_type() == Variant::STRING && as[1].get_type() == Variant::NODE_PATH){
|
if (as.size() >= 2 && as[0].get_type() == Variant::STRING && as[1].get_type() == Variant::NODE_PATH) {
|
||||||
NodePath node_path = as[1];
|
NodePath node_path = as[1];
|
||||||
Node *node = get_node_or_null(node_path);
|
Node *node = get_node_or_null(node_path);
|
||||||
if(node && node->is_class("Node2D")){
|
if (node && node->is_class("Node2D")) {
|
||||||
Node2D *node2d = (Node2D*) node;
|
Node2D *node2d = (Node2D *) node;
|
||||||
|
|
||||||
String slot_name = as[0];
|
String slot_name = as[0];
|
||||||
auto slot = skeleton->find_slot(slot_name);
|
auto slot = skeleton->find_slot(slot_name);
|
||||||
if(slot.is_valid()){
|
if (slot.is_valid()) {
|
||||||
auto bone = slot->get_bone();
|
auto bone = slot->get_bone();
|
||||||
if(bone.is_valid())
|
if (bone.is_valid()) {
|
||||||
{
|
|
||||||
update_bind_slot_node_transform(bone, node2d);
|
update_bind_slot_node_transform(bone, node2d);
|
||||||
update_bind_slot_node_draw_order(slot_name, node2d);
|
update_bind_slot_node_draw_order(slot_name, node2d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SpineSprite::update_bind_slot_node_transform(Ref<SpineBone> bone, Node2D *node2d){
|
void SpineSprite::update_bind_slot_node_transform(Ref<SpineBone> bone, Node2D *node2d) {
|
||||||
bone->apply_world_transform_2d(node2d);
|
bone->apply_world_transform_2d(node2d);
|
||||||
}
|
}
|
||||||
void SpineSprite::update_bind_slot_node_draw_order(const String &slot_name, Node2D *node2d){
|
void SpineSprite::update_bind_slot_node_draw_order(const String &slot_name, Node2D *node2d) {
|
||||||
auto mesh_ins = find_node(slot_name);
|
auto mesh_ins = find_node(slot_name);
|
||||||
if(mesh_ins){
|
if (mesh_ins) {
|
||||||
auto pos = mesh_ins->get_index();
|
auto pos = mesh_ins->get_index();
|
||||||
|
|
||||||
// get child
|
// get child
|
||||||
auto node = find_child_node_by_node(node2d);
|
auto node = find_child_node_by_node(node2d);
|
||||||
if(node && node->get_index() != pos+1){
|
if (node && node->get_index() != pos + 1) {
|
||||||
move_child(node, pos+1);
|
move_child(node, pos + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Node *SpineSprite::find_child_node_by_node(Node *node){
|
Node *SpineSprite::find_child_node_by_node(Node *node) {
|
||||||
if(node == NULL) return NULL;
|
if (node == NULL) return NULL;
|
||||||
while(node && node->get_parent() != this) node = node->get_parent();
|
while (node && node->get_parent() != this) node = node->get_parent();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,17 +221,17 @@ Ref<SpineAnimationStateDataResource> SpineSprite::get_animation_state_data_res()
|
|||||||
return animation_state_data_res;
|
return animation_state_data_res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSprite::_on_animation_data_created(){
|
void SpineSprite::_on_animation_data_created() {
|
||||||
// print_line("_on_animation_data_created");
|
// print_line("_on_animation_data_created");
|
||||||
skeleton = Ref<SpineSkeleton>(memnew(SpineSkeleton));
|
skeleton = Ref<SpineSkeleton>(memnew(SpineSkeleton));
|
||||||
skeleton->load_skeleton(animation_state_data_res->get_skeleton());
|
skeleton->load_skeleton(animation_state_data_res->get_skeleton());
|
||||||
skeleton->set_spine_sprite(this);
|
skeleton->set_spine_sprite(this);
|
||||||
// print_line("Run time skeleton created.");
|
// print_line("Run time skeleton created.");
|
||||||
|
|
||||||
animation_state = Ref<SpineAnimationState>(memnew(SpineAnimationState));
|
animation_state = Ref<SpineAnimationState>(memnew(SpineAnimationState));
|
||||||
animation_state->load_animation_state(animation_state_data_res);
|
animation_state->load_animation_state(animation_state_data_res);
|
||||||
animation_state->get_animation_state()->setListener(this);
|
animation_state->get_animation_state()->setListener(this);
|
||||||
// print_line("Run time animation state created.");
|
// print_line("Run time animation state created.");
|
||||||
|
|
||||||
// add mesh instances related by current skeleton
|
// add mesh instances related by current skeleton
|
||||||
animation_state->update(0);
|
animation_state->update(0);
|
||||||
@ -254,21 +248,19 @@ void SpineSprite::_on_animation_data_created(){
|
|||||||
emit_signal("animation_state_ready", animation_state, skeleton);
|
emit_signal("animation_state_ready", animation_state, skeleton);
|
||||||
}
|
}
|
||||||
void SpineSprite::_on_animation_data_changed() {
|
void SpineSprite::_on_animation_data_changed() {
|
||||||
// print_line("_on_animation_data_changed");
|
// print_line("_on_animation_data_changed");
|
||||||
remove_mesh_instances();
|
remove_mesh_instances();
|
||||||
skeleton.unref();
|
skeleton.unref();
|
||||||
animation_state.unref();
|
animation_state.unref();
|
||||||
if(!animation_state_data_res.is_null())
|
if (!animation_state_data_res.is_null()) {
|
||||||
{
|
if (!animation_state_data_res->is_connected("animation_state_data_created", this, "_on_animation_data_created"))
|
||||||
if(!animation_state_data_res->is_connected("animation_state_data_created", this, "_on_animation_data_created"))
|
|
||||||
animation_state_data_res->connect("animation_state_data_created", this, "_on_animation_data_created");
|
animation_state_data_res->connect("animation_state_data_created", this, "_on_animation_data_created");
|
||||||
if(!animation_state_data_res->is_connected("skeleton_data_res_changed", this, "_on_animation_data_changed"))
|
if (!animation_state_data_res->is_connected("skeleton_data_res_changed", this, "_on_animation_data_changed"))
|
||||||
animation_state_data_res->connect("skeleton_data_res_changed", this, "_on_animation_data_changed");
|
animation_state_data_res->connect("skeleton_data_res_changed", this, "_on_animation_data_changed");
|
||||||
if(!animation_state_data_res->is_connected("animation_state_data_changed", this, "_on_animation_data_changed"))
|
if (!animation_state_data_res->is_connected("animation_state_data_changed", this, "_on_animation_data_changed"))
|
||||||
animation_state_data_res->connect("animation_state_data_changed", this, "_on_animation_data_changed");
|
animation_state_data_res->connect("animation_state_data_changed", this, "_on_animation_data_changed");
|
||||||
|
|
||||||
if(animation_state_data_res->is_animation_state_data_created())
|
if (animation_state_data_res->is_animation_state_data_created()) {
|
||||||
{
|
|
||||||
_on_animation_data_created();
|
_on_animation_data_created();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,8 +275,7 @@ Ref<SpineAnimationState> SpineSprite::get_animation_state() {
|
|||||||
|
|
||||||
void SpineSprite::gen_mesh_from_skeleton(Ref<SpineSkeleton> s) {
|
void SpineSprite::gen_mesh_from_skeleton(Ref<SpineSkeleton> s) {
|
||||||
auto sk = s->get_spine_object();
|
auto sk = s->get_spine_object();
|
||||||
for(size_t i=0, n = sk->getSlots().size(); i < n; ++i)
|
for (size_t i = 0, n = sk->getSlots().size(); i < n; ++i) {
|
||||||
{
|
|
||||||
// creat a mesh instance 2d for every slot
|
// creat a mesh instance 2d for every slot
|
||||||
auto mesh_ins = memnew(SpineSpriteMeshInstance2D);
|
auto mesh_ins = memnew(SpineSpriteMeshInstance2D);
|
||||||
add_child(mesh_ins);
|
add_child(mesh_ins);
|
||||||
@ -323,8 +314,7 @@ void SpineSprite::gen_mesh_from_skeleton(Ref<SpineSkeleton> s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpineSprite::remove_mesh_instances() {
|
void SpineSprite::remove_mesh_instances() {
|
||||||
for(size_t i=0;i < mesh_instances.size();++i)
|
for (size_t i = 0; i < mesh_instances.size(); ++i) {
|
||||||
{
|
|
||||||
remove_child(mesh_instances[i]);
|
remove_child(mesh_instances[i]);
|
||||||
memdelete(mesh_instances[i]);
|
memdelete(mesh_instances[i]);
|
||||||
}
|
}
|
||||||
@ -332,43 +322,42 @@ void SpineSprite::remove_mesh_instances() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpineSprite::remove_redundant_mesh_instances() {
|
void SpineSprite::remove_redundant_mesh_instances() {
|
||||||
Vector<Node*> ms;
|
Vector<Node *> ms;
|
||||||
// remove the redundant mesh instances that added by duplicating
|
// remove the redundant mesh instances that added by duplicating
|
||||||
// print_line("start clearing");
|
// print_line("start clearing");
|
||||||
for(size_t i=0, n=get_child_count(); i<n; ++i){
|
for (size_t i = 0, n = get_child_count(); i < n; ++i) {
|
||||||
auto node = get_child(i);
|
auto node = get_child(i);
|
||||||
// print_line(String("get a node: ") + node->get_name());
|
// print_line(String("get a node: ") + node->get_name());
|
||||||
if(node && node->is_class("SpineSpriteMeshInstance2D")){
|
if (node && node->is_class("SpineSpriteMeshInstance2D")) {
|
||||||
if(mesh_instances.find((SpineSpriteMeshInstance2D*)node) == -1)
|
if (mesh_instances.find((SpineSpriteMeshInstance2D *) node) == -1) {
|
||||||
{
|
// print_line("marked clear");
|
||||||
// print_line("marked clear");
|
|
||||||
ms.push_back(node);
|
ms.push_back(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(size_t i=0, n=ms.size(); i<n; ++i){
|
for (size_t i = 0, n = ms.size(); i < n; ++i) {
|
||||||
remove_child(ms[i]);
|
remove_child(ms[i]);
|
||||||
memdelete(ms[i]);
|
memdelete(ms[i]);
|
||||||
}
|
}
|
||||||
ms.clear();
|
ms.clear();
|
||||||
// print_line("end clearing");
|
// print_line("end clearing");
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TEMP_COPY(t, get_res) do{auto &temp_uvs = get_res; \
|
#define TEMP_COPY(t, get_res) \
|
||||||
|
do { \
|
||||||
|
auto &temp_uvs = get_res; \
|
||||||
t.setSize(temp_uvs.size(), 0); \
|
t.setSize(temp_uvs.size(), 0); \
|
||||||
for(size_t j=0;j<t.size();++j) \
|
for (size_t j = 0; j < t.size(); ++j) { \
|
||||||
{ \
|
|
||||||
t[j] = temp_uvs[j]; \
|
t[j] = temp_uvs[j]; \
|
||||||
}}while(false);
|
} \
|
||||||
|
} while (false);
|
||||||
void SpineSprite::update_mesh_from_skeleton(Ref<SpineSkeleton> s) {
|
void SpineSprite::update_mesh_from_skeleton(Ref<SpineSkeleton> s) {
|
||||||
static const unsigned short VERTEX_STRIDE = 2;
|
static const unsigned short VERTEX_STRIDE = 2;
|
||||||
static const unsigned short UV_STRIDE = 2;
|
static const unsigned short UV_STRIDE = 2;
|
||||||
static unsigned short quad_indices[] = { 0, 1, 2, 2, 3, 0 };
|
static unsigned short quad_indices[] = {0, 1, 2, 2, 3, 0};
|
||||||
|
|
||||||
auto sk = s->get_spine_object();
|
auto sk = s->get_spine_object();
|
||||||
for(size_t i=0, n = sk->getSlots().size(); i < n; ++i)
|
for (size_t i = 0, n = sk->getSlots().size(); i < n; ++i) {
|
||||||
{
|
|
||||||
spine::Vector<float> vertices;
|
spine::Vector<float> vertices;
|
||||||
spine::Vector<float> uvs;
|
spine::Vector<float> uvs;
|
||||||
spine::Vector<unsigned short> indices;
|
spine::Vector<unsigned short> indices;
|
||||||
@ -376,7 +365,7 @@ void SpineSprite::update_mesh_from_skeleton(Ref<SpineSkeleton> s) {
|
|||||||
spine::Slot *slot = sk->getDrawOrder()[i];
|
spine::Slot *slot = sk->getDrawOrder()[i];
|
||||||
|
|
||||||
spine::Attachment *attachment = slot->getAttachment();
|
spine::Attachment *attachment = slot->getAttachment();
|
||||||
if(!attachment){
|
if (!attachment) {
|
||||||
// set invisible to mesh instance
|
// set invisible to mesh instance
|
||||||
mesh_instances[i]->set_visible(false);
|
mesh_instances[i]->set_visible(false);
|
||||||
|
|
||||||
@ -393,11 +382,10 @@ void SpineSprite::update_mesh_from_skeleton(Ref<SpineSkeleton> s) {
|
|||||||
Ref<Texture> normal_tex;
|
Ref<Texture> normal_tex;
|
||||||
size_t v_num = 0;
|
size_t v_num = 0;
|
||||||
|
|
||||||
if(attachment->getRTTI().isExactly(spine::RegionAttachment::rtti))
|
if (attachment->getRTTI().isExactly(spine::RegionAttachment::rtti)) {
|
||||||
{
|
spine::RegionAttachment *region_attachment = (spine::RegionAttachment *) attachment;
|
||||||
spine::RegionAttachment *region_attachment = (spine::RegionAttachment*)attachment;
|
|
||||||
|
|
||||||
auto p_spine_renderer_object = (SpineRendererObject*) ((spine::AtlasRegion*)region_attachment->getRendererObject())->page->getRendererObject();
|
auto p_spine_renderer_object = (SpineRendererObject *) ((spine::AtlasRegion *) region_attachment->getRendererObject())->page->getRendererObject();
|
||||||
tex = p_spine_renderer_object->tex;
|
tex = p_spine_renderer_object->tex;
|
||||||
normal_tex = p_spine_renderer_object->normal_tex;
|
normal_tex = p_spine_renderer_object->normal_tex;
|
||||||
|
|
||||||
@ -409,7 +397,7 @@ void SpineSprite::update_mesh_from_skeleton(Ref<SpineSkeleton> s) {
|
|||||||
TEMP_COPY(uvs, region_attachment->getUVs());
|
TEMP_COPY(uvs, region_attachment->getUVs());
|
||||||
|
|
||||||
indices.setSize(sizeof(quad_indices) / sizeof(unsigned short), 0);
|
indices.setSize(sizeof(quad_indices) / sizeof(unsigned short), 0);
|
||||||
for (size_t j = 0, qn = indices.size();j<qn;++j) {
|
for (size_t j = 0, qn = indices.size(); j < qn; ++j) {
|
||||||
indices[j] = quad_indices[j];
|
indices[j] = quad_indices[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,20 +406,20 @@ void SpineSprite::update_mesh_from_skeleton(Ref<SpineSkeleton> s) {
|
|||||||
tint.g *= attachment_color.g;
|
tint.g *= attachment_color.g;
|
||||||
tint.b *= attachment_color.b;
|
tint.b *= attachment_color.b;
|
||||||
tint.a *= attachment_color.a;
|
tint.a *= attachment_color.a;
|
||||||
}else if(attachment->getRTTI().isExactly(spine::MeshAttachment::rtti)) {
|
} else if (attachment->getRTTI().isExactly(spine::MeshAttachment::rtti)) {
|
||||||
spine::MeshAttachment *mesh = (spine::MeshAttachment*) attachment;
|
spine::MeshAttachment *mesh = (spine::MeshAttachment *) attachment;
|
||||||
|
|
||||||
auto p_spine_renderer_object = (SpineRendererObject*) ((spine::AtlasRegion*)mesh->getRendererObject())->page->getRendererObject();
|
auto p_spine_renderer_object = (SpineRendererObject *) ((spine::AtlasRegion *) mesh->getRendererObject())->page->getRendererObject();
|
||||||
tex = p_spine_renderer_object->tex;
|
tex = p_spine_renderer_object->tex;
|
||||||
normal_tex = p_spine_renderer_object->normal_tex;
|
normal_tex = p_spine_renderer_object->normal_tex;
|
||||||
|
|
||||||
v_num = mesh->getWorldVerticesLength()/VERTEX_STRIDE;
|
v_num = mesh->getWorldVerticesLength() / VERTEX_STRIDE;
|
||||||
vertices.setSize(mesh->getWorldVerticesLength(), 0);
|
vertices.setSize(mesh->getWorldVerticesLength(), 0);
|
||||||
|
|
||||||
mesh->computeWorldVertices(*slot, vertices);
|
mesh->computeWorldVertices(*slot, vertices);
|
||||||
|
|
||||||
// uvs = mesh->getUVs();
|
// uvs = mesh->getUVs();
|
||||||
// indices = mesh->getTriangles();
|
// indices = mesh->getTriangles();
|
||||||
TEMP_COPY(uvs, mesh->getUVs());
|
TEMP_COPY(uvs, mesh->getUVs());
|
||||||
TEMP_COPY(indices, mesh->getTriangles());
|
TEMP_COPY(indices, mesh->getTriangles());
|
||||||
|
|
||||||
@ -461,7 +449,7 @@ void SpineSprite::update_mesh_from_skeleton(Ref<SpineSkeleton> s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto &clipped_vertices = skeleton_clipper->getClippedVertices();
|
auto &clipped_vertices = skeleton_clipper->getClippedVertices();
|
||||||
v_num = clipped_vertices.size()/VERTEX_STRIDE;
|
v_num = clipped_vertices.size() / VERTEX_STRIDE;
|
||||||
auto &clipped_uvs = skeleton_clipper->getClippedUVs();
|
auto &clipped_uvs = skeleton_clipper->getClippedUVs();
|
||||||
auto &clipped_indices = skeleton_clipper->getClippedTriangles();
|
auto &clipped_indices = skeleton_clipper->getClippedTriangles();
|
||||||
|
|
||||||
@ -473,8 +461,8 @@ void SpineSprite::update_mesh_from_skeleton(Ref<SpineSkeleton> s) {
|
|||||||
p_uvs.resize(v_num);
|
p_uvs.resize(v_num);
|
||||||
p_colors.resize(v_num);
|
p_colors.resize(v_num);
|
||||||
for (size_t j = 0; j < v_num; j++) {
|
for (size_t j = 0; j < v_num; j++) {
|
||||||
p_points.set(j, Vector2(clipped_vertices[j*VERTEX_STRIDE], -clipped_vertices[j*VERTEX_STRIDE+1]));
|
p_points.set(j, Vector2(clipped_vertices[j * VERTEX_STRIDE], -clipped_vertices[j * VERTEX_STRIDE + 1]));
|
||||||
p_uvs.set(j, Vector2(clipped_uvs[j*VERTEX_STRIDE], clipped_uvs[j*VERTEX_STRIDE+1]));
|
p_uvs.set(j, Vector2(clipped_uvs[j * VERTEX_STRIDE], clipped_uvs[j * VERTEX_STRIDE + 1]));
|
||||||
p_colors.set(j, Color(tint.r, tint.g, tint.b, tint.a));
|
p_colors.set(j, Color(tint.r, tint.g, tint.b, tint.a));
|
||||||
}
|
}
|
||||||
p_indices.resize(clipped_indices.size());
|
p_indices.resize(clipped_indices.size());
|
||||||
@ -493,7 +481,7 @@ void SpineSprite::update_mesh_from_skeleton(Ref<SpineSkeleton> s) {
|
|||||||
-1,
|
-1,
|
||||||
normal_tex.is_null() ? RID() : normal_tex->get_rid());
|
normal_tex.is_null() ? RID() : normal_tex->get_rid());
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
if (indices.size() > 0) {
|
if (indices.size() > 0) {
|
||||||
Vector<Vector2> p_points, p_uvs;
|
Vector<Vector2> p_points, p_uvs;
|
||||||
Vector<Color> p_colors;
|
Vector<Color> p_colors;
|
||||||
@ -502,8 +490,8 @@ void SpineSprite::update_mesh_from_skeleton(Ref<SpineSkeleton> s) {
|
|||||||
p_uvs.resize(v_num);
|
p_uvs.resize(v_num);
|
||||||
p_colors.resize(v_num);
|
p_colors.resize(v_num);
|
||||||
for (size_t j = 0; j < v_num; j++) {
|
for (size_t j = 0; j < v_num; j++) {
|
||||||
p_points.set(j, Vector2(vertices[j*VERTEX_STRIDE], -vertices[j*VERTEX_STRIDE+1]));
|
p_points.set(j, Vector2(vertices[j * VERTEX_STRIDE], -vertices[j * VERTEX_STRIDE + 1]));
|
||||||
p_uvs.set(j, Vector2(uvs[j*VERTEX_STRIDE], uvs[j*VERTEX_STRIDE+1]));
|
p_uvs.set(j, Vector2(uvs[j * VERTEX_STRIDE], uvs[j * VERTEX_STRIDE + 1]));
|
||||||
p_colors.set(j, Color(tint.r, tint.g, tint.b, tint.a));
|
p_colors.set(j, Color(tint.r, tint.g, tint.b, tint.a));
|
||||||
}
|
}
|
||||||
p_indices.resize(indices.size());
|
p_indices.resize(indices.size());
|
||||||
@ -525,7 +513,7 @@ void SpineSprite::update_mesh_from_skeleton(Ref<SpineSkeleton> s) {
|
|||||||
}
|
}
|
||||||
skeleton_clipper->clipEnd(*slot);
|
skeleton_clipper->clipEnd(*slot);
|
||||||
|
|
||||||
if (mesh_ins->get_material()->is_class("CanvasItemMaterial")){
|
if (mesh_ins->get_material()->is_class("CanvasItemMaterial")) {
|
||||||
Ref<CanvasItemMaterial> mat = mesh_ins->get_material();
|
Ref<CanvasItemMaterial> mat = mesh_ins->get_material();
|
||||||
CanvasItemMaterial::BlendMode blend_mode;
|
CanvasItemMaterial::BlendMode blend_mode;
|
||||||
switch (slot->getData().getBlendMode()) {
|
switch (slot->getData().getBlendMode()) {
|
||||||
@ -554,40 +542,34 @@ void SpineSprite::callback(spine::AnimationState *state, spine::EventType type,
|
|||||||
Ref<SpineTrackEntry> gd_entry(NULL);
|
Ref<SpineTrackEntry> gd_entry(NULL);
|
||||||
Ref<SpineEvent> gd_event(NULL);
|
Ref<SpineEvent> gd_event(NULL);
|
||||||
|
|
||||||
if(entry){
|
if (entry) {
|
||||||
gd_entry = Ref<SpineTrackEntry>(memnew(SpineTrackEntry));
|
gd_entry = Ref<SpineTrackEntry>(memnew(SpineTrackEntry));
|
||||||
gd_entry->set_spine_object(entry);
|
gd_entry->set_spine_object(entry);
|
||||||
}
|
}
|
||||||
if(event){
|
if (event) {
|
||||||
gd_event = Ref<SpineEvent>(memnew(SpineEvent));
|
gd_event = Ref<SpineEvent>(memnew(SpineEvent));
|
||||||
gd_event->set_spine_object(event);
|
gd_event->set_spine_object(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case spine::EventType_Start:
|
case spine::EventType_Start: {
|
||||||
{
|
|
||||||
emit_signal("animation_start", animation_state, gd_entry, gd_event);
|
emit_signal("animation_start", animation_state, gd_entry, gd_event);
|
||||||
}break;
|
} break;
|
||||||
case spine::EventType_Interrupt:
|
case spine::EventType_Interrupt: {
|
||||||
{
|
|
||||||
emit_signal("animation_interrupt", animation_state, gd_entry, gd_event);
|
emit_signal("animation_interrupt", animation_state, gd_entry, gd_event);
|
||||||
}break;
|
} break;
|
||||||
case spine::EventType_End:
|
case spine::EventType_End: {
|
||||||
{
|
|
||||||
emit_signal("animation_end", animation_state, gd_entry, gd_event);
|
emit_signal("animation_end", animation_state, gd_entry, gd_event);
|
||||||
}break;
|
} break;
|
||||||
case spine::EventType_Complete:
|
case spine::EventType_Complete: {
|
||||||
{
|
|
||||||
emit_signal("animation_complete", animation_state, gd_entry, gd_event);
|
emit_signal("animation_complete", animation_state, gd_entry, gd_event);
|
||||||
}break;
|
} break;
|
||||||
case spine::EventType_Dispose:
|
case spine::EventType_Dispose: {
|
||||||
{
|
|
||||||
emit_signal("animation_dispose", animation_state, gd_entry, gd_event);
|
emit_signal("animation_dispose", animation_state, gd_entry, gd_event);
|
||||||
}break;
|
} break;
|
||||||
case spine::EventType_Event:
|
case spine::EventType_Event: {
|
||||||
{
|
|
||||||
emit_signal("animation_event", animation_state, gd_entry, gd_event);
|
emit_signal("animation_event", animation_state, gd_entry, gd_event);
|
||||||
}break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -602,141 +584,137 @@ void SpineSprite::set_current_animations(Array as) {
|
|||||||
_validate_and_play_current_animations();
|
_validate_and_play_current_animations();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SpineSprite::get_select_track_id(){
|
int SpineSprite::get_select_track_id() {
|
||||||
return select_track_id;
|
return select_track_id;
|
||||||
}
|
}
|
||||||
void SpineSprite::set_select_track_id(int v){
|
void SpineSprite::set_select_track_id(int v) {
|
||||||
select_track_id = v;
|
select_track_id = v;
|
||||||
|
|
||||||
if(select_track_id < 0) select_track_id = 0;
|
if (select_track_id < 0) select_track_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineSprite::get_clear_track(){
|
bool SpineSprite::get_clear_track() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void SpineSprite::set_clear_track(bool v){
|
void SpineSprite::set_clear_track(bool v) {
|
||||||
if(v && animation_state.is_valid() && skeleton.is_valid())
|
if (v && animation_state.is_valid() && skeleton.is_valid())
|
||||||
animation_state->clear_track(select_track_id);
|
animation_state->clear_track(select_track_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineSprite::get_clear_tracks(){
|
bool SpineSprite::get_clear_tracks() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void SpineSprite::set_clear_tracks(bool v){
|
void SpineSprite::set_clear_tracks(bool v) {
|
||||||
if(v && animation_state.is_valid() && skeleton.is_valid())
|
if (v && animation_state.is_valid() && skeleton.is_valid())
|
||||||
animation_state->clear_tracks();
|
animation_state->clear_tracks();
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineSprite::get_empty_animation_duration(){
|
float SpineSprite::get_empty_animation_duration() {
|
||||||
return empty_animation_duration;
|
return empty_animation_duration;
|
||||||
}
|
}
|
||||||
void SpineSprite::set_empty_animation_duration(float v){
|
void SpineSprite::set_empty_animation_duration(float v) {
|
||||||
empty_animation_duration = v;
|
empty_animation_duration = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineSprite::get_set_empty_animation(){
|
bool SpineSprite::get_set_empty_animation() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void SpineSprite::set_set_empty_animation(bool v){
|
void SpineSprite::set_set_empty_animation(bool v) {
|
||||||
if(v && animation_state.is_valid() && skeleton.is_valid())
|
if (v && animation_state.is_valid() && skeleton.is_valid())
|
||||||
animation_state->set_empty_animation(select_track_id, empty_animation_duration);
|
animation_state->set_empty_animation(select_track_id, empty_animation_duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineSprite::get_set_empty_animations(){
|
bool SpineSprite::get_set_empty_animations() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void SpineSprite::set_set_empty_animations(bool v){
|
void SpineSprite::set_set_empty_animations(bool v) {
|
||||||
if(v && animation_state.is_valid() && skeleton.is_valid())
|
if (v && animation_state.is_valid() && skeleton.is_valid())
|
||||||
animation_state->set_empty_animations(empty_animation_duration);
|
animation_state->set_empty_animations(empty_animation_duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
Array SpineSprite::get_bind_slot_nodes(){
|
Array SpineSprite::get_bind_slot_nodes() {
|
||||||
return bind_slot_nodes;
|
return bind_slot_nodes;
|
||||||
}
|
}
|
||||||
void SpineSprite::set_bind_slot_nodes(Array v) {
|
void SpineSprite::set_bind_slot_nodes(Array v) {
|
||||||
bind_slot_nodes = v;
|
bind_slot_nodes = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineSprite::get_overlap(){
|
bool SpineSprite::get_overlap() {
|
||||||
return overlap;
|
return overlap;
|
||||||
}
|
}
|
||||||
void SpineSprite::set_overlap(bool v){
|
void SpineSprite::set_overlap(bool v) {
|
||||||
overlap = v;
|
overlap = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSprite::set_skin(Ref<PackedSpineSkinResource> v)
|
void SpineSprite::set_skin(Ref<PackedSpineSkinResource> v) {
|
||||||
{
|
if (v != skin && skin.is_valid()) {
|
||||||
if(v != skin && skin.is_valid()){
|
if (skin->is_connected("property_changed", this, "_on_skin_property_changed"))
|
||||||
if(skin->is_connected("property_changed", this, "_on_skin_property_changed"))
|
|
||||||
skin->disconnect("property_changed", this, "_on_skin_property_changed");
|
skin->disconnect("property_changed", this, "_on_skin_property_changed");
|
||||||
}
|
}
|
||||||
|
|
||||||
skin = v;
|
skin = v;
|
||||||
|
|
||||||
if(skin.is_valid()){
|
if (skin.is_valid()) {
|
||||||
if(!skin->is_connected("property_changed", this, "_on_skin_property_changed"))
|
if (!skin->is_connected("property_changed", this, "_on_skin_property_changed"))
|
||||||
skin->connect("property_changed", this, "_on_skin_property_changed");
|
skin->connect("property_changed", this, "_on_skin_property_changed");
|
||||||
update_runtime_skin();
|
update_runtime_skin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ref<PackedSpineSkinResource> SpineSprite::get_skin(){
|
Ref<PackedSpineSkinResource> SpineSprite::get_skin() {
|
||||||
return skin;
|
return skin;
|
||||||
}
|
}
|
||||||
void SpineSprite::update_runtime_skin(){
|
void SpineSprite::update_runtime_skin() {
|
||||||
auto new_skin = gen_spine_skin_from_packed_resource(skin);
|
auto new_skin = gen_spine_skin_from_packed_resource(skin);
|
||||||
|
|
||||||
if(new_skin.is_valid())
|
if (new_skin.is_valid()) {
|
||||||
{
|
|
||||||
skeleton->set_skin(new_skin);
|
skeleton->set_skin(new_skin);
|
||||||
skeleton->set_to_setup_pose();
|
skeleton->set_to_setup_pose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SpineSprite::_on_skin_property_changed(){
|
void SpineSprite::_on_skin_property_changed() {
|
||||||
update_runtime_skin();
|
update_runtime_skin();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineSkin> SpineSprite::gen_spine_skin_from_packed_resource(Ref<PackedSpineSkinResource> res){
|
Ref<SpineSkin> SpineSprite::gen_spine_skin_from_packed_resource(Ref<PackedSpineSkinResource> res) {
|
||||||
if(!(animation_state.is_valid() && skeleton.is_valid()))
|
if (!(animation_state.is_valid() && skeleton.is_valid()))
|
||||||
return NULL;
|
return NULL;
|
||||||
if(!res.is_valid())
|
if (!res.is_valid())
|
||||||
return NULL;
|
return NULL;
|
||||||
if(res->get_skin_name().empty())
|
if (res->get_skin_name().empty())
|
||||||
return NULL;
|
return NULL;
|
||||||
auto exist_skin = animation_state_data_res->get_skeleton()->find_skin(res->get_skin_name());
|
auto exist_skin = animation_state_data_res->get_skeleton()->find_skin(res->get_skin_name());
|
||||||
if(exist_skin.is_valid())
|
if (exist_skin.is_valid()) {
|
||||||
{
|
|
||||||
return exist_skin;
|
return exist_skin;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto new_skin = Ref<SpineSkin>(memnew(SpineSkin))->init(res->get_skin_name());
|
auto new_skin = Ref<SpineSkin>(memnew(SpineSkin))->init(res->get_skin_name());
|
||||||
auto sub_skin_names = res->get_sub_skin_names();
|
auto sub_skin_names = res->get_sub_skin_names();
|
||||||
for(size_t i=0;i<sub_skin_names.size();++i)
|
for (size_t i = 0; i < sub_skin_names.size(); ++i) {
|
||||||
{
|
auto skin_name = (String) sub_skin_names[i];
|
||||||
auto skin_name = (String)sub_skin_names[i];
|
|
||||||
auto sub_skin = animation_state_data_res->get_skeleton()->find_skin(skin_name);
|
auto sub_skin = animation_state_data_res->get_skeleton()->find_skin(skin_name);
|
||||||
if(sub_skin.is_valid())
|
if (sub_skin.is_valid())
|
||||||
new_skin->add_skin(sub_skin);
|
new_skin->add_skin(sub_skin);
|
||||||
}
|
}
|
||||||
return new_skin;
|
return new_skin;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSprite::bind_slot_with_node_2d(const String &slot_name, Node2D *n){
|
void SpineSprite::bind_slot_with_node_2d(const String &slot_name, Node2D *n) {
|
||||||
auto node_path = n->get_path_to(this);
|
auto node_path = n->get_path_to(this);
|
||||||
|
|
||||||
// check if has the same binding
|
// check if has the same binding
|
||||||
for(size_t i=0, size=bind_slot_nodes.size(); i<size; ++i){
|
for (size_t i = 0, size = bind_slot_nodes.size(); i < size; ++i) {
|
||||||
auto a = bind_slot_nodes[i];
|
auto a = bind_slot_nodes[i];
|
||||||
if(a.get_type() == Variant::DICTIONARY){
|
if (a.get_type() == Variant::DICTIONARY) {
|
||||||
auto d = (Dictionary) a;
|
auto d = (Dictionary) a;
|
||||||
if(d.has("slot_name") && d.has("node_path")){
|
if (d.has("slot_name") && d.has("node_path")) {
|
||||||
if(slot_name == d["slot_name"] && node_path == d["node_path"]){
|
if (slot_name == d["slot_name"] && node_path == d["node_path"]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if(a.get_type() == Variant::ARRAY){
|
} else if (a.get_type() == Variant::ARRAY) {
|
||||||
auto as = (Array) a;
|
auto as = (Array) a;
|
||||||
if(as.size() >= 2 && as[0].get_type() == Variant::STRING && as[1].get_type() == Variant::NODE_PATH){
|
if (as.size() >= 2 && as[0].get_type() == Variant::STRING && as[1].get_type() == Variant::NODE_PATH) {
|
||||||
if(slot_name == as[0] && node_path == as[1]){
|
if (slot_name == as[0] && node_path == as[1]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -750,23 +728,23 @@ void SpineSprite::bind_slot_with_node_2d(const String &slot_name, Node2D *n){
|
|||||||
|
|
||||||
bind_slot_nodes.append(bound);
|
bind_slot_nodes.append(bound);
|
||||||
}
|
}
|
||||||
void SpineSprite::unbind_slot_with_node_2d(const String &slot_name, Node2D *n){
|
void SpineSprite::unbind_slot_with_node_2d(const String &slot_name, Node2D *n) {
|
||||||
auto node_path = n->get_path_to(this);
|
auto node_path = n->get_path_to(this);
|
||||||
|
|
||||||
for(size_t i=0, size=bind_slot_nodes.size(); i<size; ++i){
|
for (size_t i = 0, size = bind_slot_nodes.size(); i < size; ++i) {
|
||||||
auto a = bind_slot_nodes[i];
|
auto a = bind_slot_nodes[i];
|
||||||
if(a.get_type() == Variant::DICTIONARY){
|
if (a.get_type() == Variant::DICTIONARY) {
|
||||||
auto d = (Dictionary) a;
|
auto d = (Dictionary) a;
|
||||||
if(d.has("slot_name") && d.has("node_path")){
|
if (d.has("slot_name") && d.has("node_path")) {
|
||||||
if(slot_name == d["slot_name"] && node_path == d["node_path"]){
|
if (slot_name == d["slot_name"] && node_path == d["node_path"]) {
|
||||||
bind_slot_nodes.remove(i);
|
bind_slot_nodes.remove(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if(a.get_type() == Variant::ARRAY){
|
} else if (a.get_type() == Variant::ARRAY) {
|
||||||
auto as = (Array) a;
|
auto as = (Array) a;
|
||||||
if(as.size() >= 2 && as[0].get_type() == Variant::STRING && as[1].get_type() == Variant::NODE_PATH){
|
if (as.size() >= 2 && as[0].get_type() == Variant::STRING && as[1].get_type() == Variant::NODE_PATH) {
|
||||||
if(slot_name == as[0] && node_path == as[1]){
|
if (slot_name == as[0] && node_path == as[1]) {
|
||||||
bind_slot_nodes.remove(i);
|
bind_slot_nodes.remove(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -816,9 +794,9 @@ void SpineSprite::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||||||
p_list->push_back(PropertyInfo(Variant::REAL, "empty_animation_duration"));
|
p_list->push_back(PropertyInfo(Variant::REAL, "empty_animation_duration"));
|
||||||
p_list->push_back(PropertyInfo(Variant::INT, "track_count", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
|
p_list->push_back(PropertyInfo(Variant::INT, "track_count", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
|
||||||
|
|
||||||
for (size_t i=0; i<current_animations.size(); ++i) {
|
for (size_t i = 0; i < current_animations.size(); ++i) {
|
||||||
String prefix = vformat("ca/%d/", (unsigned int)i);
|
String prefix = vformat("ca/%d/", (unsigned int) i);
|
||||||
p_list->push_back(PropertyInfo(Variant::NIL, vformat("ID %d", (unsigned int)i), PROPERTY_HINT_NONE, prefix, PROPERTY_USAGE_GROUP));
|
p_list->push_back(PropertyInfo(Variant::NIL, vformat("ID %d", (unsigned int) i), PROPERTY_HINT_NONE, prefix, PROPERTY_USAGE_GROUP));
|
||||||
p_list->push_back(PropertyInfo(Variant::INT, vformat("%strack_id", prefix), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
|
p_list->push_back(PropertyInfo(Variant::INT, vformat("%strack_id", prefix), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
|
||||||
|
|
||||||
Vector<String> anim_list;
|
Vector<String> anim_list;
|
||||||
@ -865,13 +843,20 @@ bool SpineSprite::_get(const StringName &p_property, Variant &r_value) const {
|
|||||||
r_value = dic[key];
|
r_value = dic[key];
|
||||||
} else {
|
} else {
|
||||||
if (key == "track_id") r_value = 0;
|
if (key == "track_id") r_value = 0;
|
||||||
else if (key == "animation") r_value = "";
|
else if (key == "animation")
|
||||||
else if (key == "loop") r_value = true;
|
r_value = "";
|
||||||
else if (key == "empty") r_value = false;
|
else if (key == "loop")
|
||||||
else if (key == "empty_animation_duration") r_value = 0.3;
|
r_value = true;
|
||||||
else if (key == "clear") r_value = false;
|
else if (key == "empty")
|
||||||
else if (key == "delay") r_value = 0;
|
r_value = false;
|
||||||
else return false;
|
else if (key == "empty_animation_duration")
|
||||||
|
r_value = 0.3;
|
||||||
|
else if (key == "clear")
|
||||||
|
r_value = false;
|
||||||
|
else if (key == "delay")
|
||||||
|
r_value = 0;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -961,10 +946,10 @@ void SpineSprite::set_current_animation_count(int64_t v) {
|
|||||||
if (back.has("track_id")) {
|
if (back.has("track_id")) {
|
||||||
int64_t track_id = back["track_id"];
|
int64_t track_id = back["track_id"];
|
||||||
int track_cnt = 0;
|
int track_cnt = 0;
|
||||||
for (size_t i=0; i<current_animations.size(); ++i) {
|
for (size_t i = 0; i < current_animations.size(); ++i) {
|
||||||
if (current_animations[i].get_type() == Variant::DICTIONARY) {
|
if (current_animations[i].get_type() == Variant::DICTIONARY) {
|
||||||
Dictionary d = current_animations[i];
|
Dictionary d = current_animations[i];
|
||||||
if (d.has("track_id") && track_id == (int64_t)d["track_id"]) {
|
if (d.has("track_id") && track_id == (int64_t) d["track_id"]) {
|
||||||
track_cnt += 1;
|
track_cnt += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -980,12 +965,12 @@ void SpineSprite::set_current_animation_count(int64_t v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpineSprite::_validate_and_play_current_animations() {
|
void SpineSprite::_validate_and_play_current_animations() {
|
||||||
if(animation_state.is_valid() && skeleton.is_valid()){
|
if (animation_state.is_valid() && skeleton.is_valid()) {
|
||||||
int64_t track_cnt = 0;
|
int64_t track_cnt = 0;
|
||||||
HashMap<int64_t, bool> has_track;
|
HashMap<int64_t, bool> has_track;
|
||||||
for(size_t i=0; i<current_animations.size(); ++i) {
|
for (size_t i = 0; i < current_animations.size(); ++i) {
|
||||||
auto a = current_animations[i];
|
auto a = current_animations[i];
|
||||||
if(a.get_type() == Variant::DICTIONARY){
|
if (a.get_type() == Variant::DICTIONARY) {
|
||||||
Dictionary d = a;
|
Dictionary d = a;
|
||||||
|
|
||||||
int64_t track_id = 0;
|
int64_t track_id = 0;
|
||||||
@ -1005,7 +990,7 @@ void SpineSprite::_validate_and_play_current_animations() {
|
|||||||
if (d.has("clear")) clear = d["clear"];
|
if (d.has("clear")) clear = d["clear"];
|
||||||
|
|
||||||
if (track_id < 0) {
|
if (track_id < 0) {
|
||||||
print_line(vformat("track_id at 'ID %d' can not be less than 0!", (unsigned int)i));
|
print_line(vformat("track_id at 'ID %d' can not be less than 0!", (unsigned int) i));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1027,13 +1012,9 @@ void SpineSprite::_validate_and_play_current_animations() {
|
|||||||
animation_state->set_animation(animation, loop, track_id);
|
animation_state->set_animation(animation, loop, track_id);
|
||||||
has_track[track_id] = true;
|
has_track[track_id] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (track_cnt == 0) animation_state->clear_tracks();
|
if (track_cnt == 0) animation_state->clear_tracks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
class SpineSprite : public Node2D, public spine::AnimationStateListenerObject {
|
class SpineSprite : public Node2D, public spine::AnimationStateListenerObject {
|
||||||
GDCLASS(SpineSprite, Node2D);
|
GDCLASS(SpineSprite, Node2D);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
@ -52,20 +53,21 @@ protected:
|
|||||||
bool _set(const StringName &p_property, const Variant &p_value);
|
bool _set(const StringName &p_property, const Variant &p_value);
|
||||||
|
|
||||||
void _validate_and_play_current_animations();
|
void _validate_and_play_current_animations();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum ProcessMode {
|
enum ProcessMode {
|
||||||
ProcessMode_Process,
|
ProcessMode_Process,
|
||||||
ProcessMode_Physics,
|
ProcessMode_Physics,
|
||||||
ProcessMode_Manual
|
ProcessMode_Manual
|
||||||
};
|
};
|
||||||
private:
|
|
||||||
|
|
||||||
|
private:
|
||||||
Ref<SpineAnimationStateDataResource> animation_state_data_res;
|
Ref<SpineAnimationStateDataResource> animation_state_data_res;
|
||||||
|
|
||||||
Ref<SpineSkeleton> skeleton;
|
Ref<SpineSkeleton> skeleton;
|
||||||
Ref<SpineAnimationState> animation_state;
|
Ref<SpineAnimationState> animation_state;
|
||||||
|
|
||||||
Vector<SpineSpriteMeshInstance2D*> mesh_instances;
|
Vector<SpineSpriteMeshInstance2D *> mesh_instances;
|
||||||
|
|
||||||
Array current_animations;
|
Array current_animations;
|
||||||
int select_track_id;
|
int select_track_id;
|
||||||
@ -100,7 +102,7 @@ public:
|
|||||||
void update_bind_slot_node_draw_order(const String &slot_name, Node2D *node2d);
|
void update_bind_slot_node_draw_order(const String &slot_name, Node2D *node2d);
|
||||||
Node *find_child_node_by_node(Node *node);
|
Node *find_child_node_by_node(Node *node);
|
||||||
|
|
||||||
virtual void callback(spine::AnimationState* state, spine::EventType type, spine::TrackEntry* entry, spine::Event* event);
|
virtual void callback(spine::AnimationState *state, spine::EventType type, spine::TrackEntry *entry, spine::Event *event);
|
||||||
|
|
||||||
void _on_animation_data_created();
|
void _on_animation_data_created();
|
||||||
void _on_animation_data_changed();
|
void _on_animation_data_changed();
|
||||||
@ -159,4 +161,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
VARIANT_ENUM_CAST(SpineSprite::ProcessMode);
|
VARIANT_ENUM_CAST(SpineSprite::ProcessMode);
|
||||||
#endif //GODOT_SPINESPRITE_H
|
#endif//GODOT_SPINESPRITE_H
|
||||||
|
|||||||
@ -61,7 +61,7 @@ SpineSpriteAnimateDialog::SpineSpriteAnimateDialog() {
|
|||||||
auto scroll = memnew(ScrollContainer);
|
auto scroll = memnew(ScrollContainer);
|
||||||
scroll->set_h_size_flags(SIZE_EXPAND_FILL);
|
scroll->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
scroll->set_v_size_flags(SIZE_EXPAND_FILL);
|
scroll->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||||
// vb->add_margin_child("Animations", scroll);
|
// vb->add_margin_child("Animations", scroll);
|
||||||
vb->add_child(scroll);
|
vb->add_child(scroll);
|
||||||
|
|
||||||
animate_dialog_tree = memnew(Tree);
|
animate_dialog_tree = memnew(Tree);
|
||||||
@ -103,7 +103,6 @@ SpineSpriteAnimateDialog::SpineSpriteAnimateDialog() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SpineSpriteAnimateDialog::~SpineSpriteAnimateDialog() {
|
SpineSpriteAnimateDialog::~SpineSpriteAnimateDialog() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSpriteAnimateDialog::set_animate_button(ToolButton *b) {
|
void SpineSpriteAnimateDialog::set_animate_button(ToolButton *b) {
|
||||||
@ -135,7 +134,12 @@ void SpineSpriteAnimateDialog::error(const String &text, const String &title) {
|
|||||||
error_dialog->popup_centered();
|
error_dialog->popup_centered();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ERROR_MSG(x) do{error(x);err=true;return;}while(false)
|
#define ERROR_MSG(x) \
|
||||||
|
do { \
|
||||||
|
error(x); \
|
||||||
|
err = true; \
|
||||||
|
return; \
|
||||||
|
} while (false)
|
||||||
void SpineSpriteAnimateDialog::load_data_from_sprite(SpineSprite *sprite, bool &err) {
|
void SpineSpriteAnimateDialog::load_data_from_sprite(SpineSprite *sprite, bool &err) {
|
||||||
if (sprite == nullptr) {
|
if (sprite == nullptr) {
|
||||||
ERROR_MSG("The sprite is null.");
|
ERROR_MSG("The sprite is null.");
|
||||||
@ -148,7 +152,7 @@ void SpineSpriteAnimateDialog::load_data_from_sprite(SpineSprite *sprite, bool &
|
|||||||
Vector<String> animations;
|
Vector<String> animations;
|
||||||
sprite->get_skeleton()->get_data()->get_animation_names(animations);
|
sprite->get_skeleton()->get_data()->get_animation_names(animations);
|
||||||
|
|
||||||
for (size_t i=0; i<animations.size(); ++i) {
|
for (size_t i = 0; i < animations.size(); ++i) {
|
||||||
add_row(animations[i]);
|
add_row(animations[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +212,7 @@ void SpineSpriteAnimateDialog::gen_animations(SpineSprite *sprite, AnimationPlay
|
|||||||
auto path_to_sprite = anim_player->get_node(anim_player->get_root())->get_path_to(sprite);
|
auto path_to_sprite = anim_player->get_node(anim_player->get_root())->get_path_to(sprite);
|
||||||
|
|
||||||
Array animations = sprite->get_skeleton()->get_data()->get_animations();
|
Array animations = sprite->get_skeleton()->get_data()->get_animations();
|
||||||
for (size_t i=0; i<animations.size(); ++i) {
|
for (size_t i = 0; i < animations.size(); ++i) {
|
||||||
auto spine_anim = (Ref<SpineAnimation>) animations[i];
|
auto spine_anim = (Ref<SpineAnimation>) animations[i];
|
||||||
|
|
||||||
Dictionary ca;
|
Dictionary ca;
|
||||||
@ -279,7 +283,6 @@ void SpineSpriteAnimateDialog::load_data_from_anim_player(AnimationPlayer *anim_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
item = item->get_next();
|
item = item->get_next();
|
||||||
@ -290,7 +293,7 @@ void SpineSpriteAnimateDialog::load_data_from_anim_player(AnimationPlayer *anim_
|
|||||||
|
|
||||||
//----- Signals -----
|
//----- Signals -----
|
||||||
void SpineSpriteAnimateDialog::_on_scene_tree_selected(NodePath path) {
|
void SpineSpriteAnimateDialog::_on_scene_tree_selected(NodePath path) {
|
||||||
// print_line(vformat("anime: %s", path));
|
// print_line(vformat("anime: %s", path));
|
||||||
auto node = get_node_or_null(path);
|
auto node = get_node_or_null(path);
|
||||||
if (node == nullptr) {
|
if (node == nullptr) {
|
||||||
error("The node you chose is null.");
|
error("The node you chose is null.");
|
||||||
@ -305,10 +308,10 @@ void SpineSpriteAnimateDialog::_on_scene_tree_selected(NodePath path) {
|
|||||||
|
|
||||||
void SpineSpriteAnimateDialog::_on_animate_button_pressed() {
|
void SpineSpriteAnimateDialog::_on_animate_button_pressed() {
|
||||||
anim_player_path = String("");
|
anim_player_path = String("");
|
||||||
auto node = (Node*)the_plugin->get_editor_interface()->get_selection()->get_selected_nodes().back();
|
auto node = (Node *) the_plugin->get_editor_interface()->get_selection()->get_selected_nodes().back();
|
||||||
spine_sprite_path = node->get_path();
|
spine_sprite_path = node->get_path();
|
||||||
|
|
||||||
// print_line(vformat("sp: %s", spine_sprite_path));
|
// print_line(vformat("sp: %s", spine_sprite_path));
|
||||||
|
|
||||||
animate_dialog_override_button->set_visible(false);
|
animate_dialog_override_button->set_visible(false);
|
||||||
scene_tree_dialog->popup_centered_ratio();
|
scene_tree_dialog->popup_centered_ratio();
|
||||||
@ -318,28 +321,26 @@ void SpineSpriteAnimateDialog::_on_scene_tree_hide() {
|
|||||||
animate_dialog->popup_centered();
|
animate_dialog->popup_centered();
|
||||||
|
|
||||||
bool err = false;
|
bool err = false;
|
||||||
load_data_from_sprite((SpineSprite*)get_node_or_null(spine_sprite_path), err);
|
load_data_from_sprite((SpineSprite *) get_node_or_null(spine_sprite_path), err);
|
||||||
|
|
||||||
if (err) animate_dialog->hide();
|
if (err) animate_dialog->hide();
|
||||||
|
|
||||||
err = false;
|
err = false;
|
||||||
auto node = get_node_or_null(anim_player_path);
|
auto node = get_node_or_null(anim_player_path);
|
||||||
if (node != nullptr) {
|
if (node != nullptr) {
|
||||||
load_data_from_anim_player((AnimationPlayer*)node, err);
|
load_data_from_anim_player((AnimationPlayer *) node, err);
|
||||||
animate_dialog_override_button->set_visible(!err);
|
animate_dialog_override_button->set_visible(!err);
|
||||||
} else {
|
} else {
|
||||||
animate_dialog_override_button->set_visible(false);
|
animate_dialog_override_button->set_visible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSpriteAnimateDialog::_on_animate_dialog_action(const String &act) {
|
void SpineSpriteAnimateDialog::_on_animate_dialog_action(const String &act) {
|
||||||
bool err = false;
|
bool err = false;
|
||||||
if (act == "confirmed") {
|
if (act == "confirmed") {
|
||||||
gen_new_animation_player((SpineSprite*)get_node_or_null(spine_sprite_path), err);
|
gen_new_animation_player((SpineSprite *) get_node_or_null(spine_sprite_path), err);
|
||||||
} else if (act == "override") {
|
} else if (act == "override") {
|
||||||
gen_animations((SpineSprite*)get_node_or_null(spine_sprite_path), (AnimationPlayer*)get_node_or_null(anim_player_path), get_data_from_tree(), MIN_TRACK_LENGTH, err);
|
gen_animations((SpineSprite *) get_node_or_null(spine_sprite_path), (AnimationPlayer *) get_node_or_null(anim_player_path), get_data_from_tree(), MIN_TRACK_LENGTH, err);
|
||||||
}
|
}
|
||||||
if (!err) {
|
if (!err) {
|
||||||
animate_dialog->hide();
|
animate_dialog->hide();
|
||||||
|
|||||||
@ -54,10 +54,10 @@ protected:
|
|||||||
NodePath spine_sprite_path;
|
NodePath spine_sprite_path;
|
||||||
NodePath anim_player_path;
|
NodePath anim_player_path;
|
||||||
|
|
||||||
void add_row(const String &animation, bool loop=true, int64_t track_id=0);
|
void add_row(const String &animation, bool loop = true, int64_t track_id = 0);
|
||||||
void clear_tree();
|
void clear_tree();
|
||||||
|
|
||||||
void error(const String &text, const String &title="Error");
|
void error(const String &text, const String &title = "Error");
|
||||||
|
|
||||||
void load_data_from_sprite(SpineSprite *sprite, bool &err);
|
void load_data_from_sprite(SpineSprite *sprite, bool &err);
|
||||||
void load_data_from_anim_player(AnimationPlayer *anim_player, bool &err);
|
void load_data_from_anim_player(AnimationPlayer *anim_player, bool &err);
|
||||||
@ -67,14 +67,15 @@ protected:
|
|||||||
void gen_new_animation_player(SpineSprite *sprite, bool &err);
|
void gen_new_animation_player(SpineSprite *sprite, bool &err);
|
||||||
void gen_animations(SpineSprite *sprite, AnimationPlayer *anim_player, const Dictionary &config, float min_duration, bool &err);
|
void gen_animations(SpineSprite *sprite, AnimationPlayer *anim_player, const Dictionary &config, float min_duration, bool &err);
|
||||||
Dictionary gen_current_animation_data(const String &animation, int64_t track_id, bool loop, bool clear, bool empty, bool empty_duration, float delay);
|
Dictionary gen_current_animation_data(const String &animation, int64_t track_id, bool loop, bool clear, bool empty, bool empty_duration, float delay);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SpineSpriteAnimateDialog();
|
SpineSpriteAnimateDialog();
|
||||||
~SpineSpriteAnimateDialog();
|
~SpineSpriteAnimateDialog();
|
||||||
|
|
||||||
void set_animate_button(ToolButton *b);
|
void set_animate_button(ToolButton *b);
|
||||||
inline ToolButton *get_animate_button() {return animate_button;}
|
inline ToolButton *get_animate_button() { return animate_button; }
|
||||||
|
|
||||||
inline void set_plugin(EditorPlugin *p) {the_plugin = p;}
|
inline void set_plugin(EditorPlugin *p) { the_plugin = p; }
|
||||||
|
|
||||||
void _on_animate_button_pressed();
|
void _on_animate_button_pressed();
|
||||||
void _on_scene_tree_selected(NodePath path);
|
void _on_scene_tree_selected(NodePath path);
|
||||||
@ -83,4 +84,4 @@ public:
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif //GODOT_SPINESPRITEANIMATEDIALOG_H
|
#endif//GODOT_SPINESPRITEANIMATEDIALOG_H
|
||||||
|
|||||||
@ -43,6 +43,6 @@ Ref<SpineSlot> SpineSpriteMeshInstance2D::get_slot() {
|
|||||||
return slot;
|
return slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSpriteMeshInstance2D::apply_transform_2d(Variant o){
|
void SpineSpriteMeshInstance2D::apply_transform_2d(Variant o) {
|
||||||
slot->get_bone()->apply_world_transform_2d(o);
|
slot->get_bone()->apply_world_transform_2d(o);
|
||||||
}
|
}
|
||||||
@ -41,11 +41,12 @@ protected:
|
|||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
Ref<SpineSlot> slot;
|
Ref<SpineSlot> slot;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SpineSpriteMeshInstance2D();
|
SpineSpriteMeshInstance2D();
|
||||||
~SpineSpriteMeshInstance2D();
|
~SpineSpriteMeshInstance2D();
|
||||||
|
|
||||||
inline void set_slot(Ref<SpineSlot> s){
|
inline void set_slot(Ref<SpineSlot> s) {
|
||||||
slot = s;
|
slot = s;
|
||||||
}
|
}
|
||||||
Ref<SpineSlot> get_slot();
|
Ref<SpineSlot> get_slot();
|
||||||
@ -53,4 +54,4 @@ public:
|
|||||||
void apply_transform_2d(Variant o);
|
void apply_transform_2d(Variant o);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINESPRITEMESHINSTANCE2D_H
|
#endif//GODOT_SPINESPRITEMESHINSTANCE2D_H
|
||||||
|
|||||||
@ -45,20 +45,18 @@ void SpineTimeline::_bind_methods() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SpineTimeline::SpineTimeline():timeline(nullptr) {
|
SpineTimeline::SpineTimeline() : timeline(nullptr) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineTimeline::~SpineTimeline() {
|
SpineTimeline::~SpineTimeline() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineTimeline::apply(Ref<SpineSkeleton> skeleton, float lastTime, float time, Array pEvents, float alpha,
|
void SpineTimeline::apply(Ref<SpineSkeleton> skeleton, float lastTime, float time, Array pEvents, float alpha,
|
||||||
SpineConstant::MixBlend blend, SpineConstant::MixDirection direction) {
|
SpineConstant::MixBlend blend, SpineConstant::MixDirection direction) {
|
||||||
spine::Vector<spine::Event*> events;
|
spine::Vector<spine::Event *> events;
|
||||||
events.setSize(pEvents.size(), nullptr);
|
events.setSize(pEvents.size(), nullptr);
|
||||||
for (size_t i=0; i<events.size(); ++i) {
|
for (size_t i = 0; i < events.size(); ++i) {
|
||||||
events[i] = ((Ref<SpineEvent>)pEvents[i])->get_spine_object();
|
events[i] = ((Ref<SpineEvent>) pEvents[i])->get_spine_object();
|
||||||
}
|
}
|
||||||
|
|
||||||
timeline->apply(*(skeleton->get_spine_object()), lastTime, time, &events, alpha, (spine::MixBlend) blend, (spine::MixDirection) direction);
|
timeline->apply(*(skeleton->get_spine_object()), lastTime, time, &events, alpha, (spine::MixBlend) blend, (spine::MixDirection) direction);
|
||||||
@ -77,7 +75,7 @@ Array SpineTimeline::get_frames() {
|
|||||||
Array res;
|
Array res;
|
||||||
res.resize(frames.size());
|
res.resize(frames.size());
|
||||||
|
|
||||||
for (size_t i=0; i<res.size(); ++i) {
|
for (size_t i = 0; i < res.size(); ++i) {
|
||||||
res[i] = frames[i];
|
res[i] = frames[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,11 +91,9 @@ Array SpineTimeline::getPropertyIds() {
|
|||||||
Array res;
|
Array res;
|
||||||
res.resize(ids.size());
|
res.resize(ids.size());
|
||||||
|
|
||||||
for (size_t i=0; i<res.size(); ++i) {
|
for (size_t i = 0; i < res.size(); ++i) {
|
||||||
res[i] = ids[i];
|
res[i] = ids[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -39,18 +39,21 @@
|
|||||||
class SpineSkeleton;
|
class SpineSkeleton;
|
||||||
class SpineEvent;
|
class SpineEvent;
|
||||||
|
|
||||||
class SpineTimeline : public Reference{
|
class SpineTimeline : public Reference {
|
||||||
GDCLASS(SpineTimeline, Reference);
|
GDCLASS(SpineTimeline, Reference);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
spine::Timeline *timeline;
|
spine::Timeline *timeline;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SpineTimeline();
|
SpineTimeline();
|
||||||
~SpineTimeline();
|
~SpineTimeline();
|
||||||
|
|
||||||
inline void set_spine_object(spine::Timeline *v) {timeline = v;}
|
inline void set_spine_object(spine::Timeline *v) { timeline = v; }
|
||||||
inline spine::Timeline *get_spine_object() {return timeline;}
|
inline spine::Timeline *get_spine_object() { return timeline; }
|
||||||
|
|
||||||
// Vector<Event *>
|
// Vector<Event *>
|
||||||
void apply(Ref<SpineSkeleton> skeleton, float lastTime, float time, Array pEvents, float alpha, SpineConstant::MixBlend blend, SpineConstant::MixDirection direction);
|
void apply(Ref<SpineSkeleton> skeleton, float lastTime, float time, Array pEvents, float alpha, SpineConstant::MixBlend blend, SpineConstant::MixDirection direction);
|
||||||
@ -69,4 +72,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //GODOT_SPINETIMELINE_H
|
#endif//GODOT_SPINETIMELINE_H
|
||||||
|
|||||||
@ -99,160 +99,160 @@ void SpineTrackEntry::_bind_methods() {
|
|||||||
BIND_ENUM_CONSTANT(MIXBLEND_ADD);
|
BIND_ENUM_CONSTANT(MIXBLEND_ADD);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineTrackEntry::SpineTrackEntry():track_entry(NULL) {}
|
SpineTrackEntry::SpineTrackEntry() : track_entry(NULL) {}
|
||||||
SpineTrackEntry::~SpineTrackEntry() {}
|
SpineTrackEntry::~SpineTrackEntry() {}
|
||||||
|
|
||||||
int SpineTrackEntry::get_track_index(){
|
int SpineTrackEntry::get_track_index() {
|
||||||
return track_entry->getTrackIndex();
|
return track_entry->getTrackIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineAnimation> SpineTrackEntry::get_animation(){
|
Ref<SpineAnimation> SpineTrackEntry::get_animation() {
|
||||||
Ref<SpineAnimation> gd_anim(memnew(SpineAnimation));
|
Ref<SpineAnimation> gd_anim(memnew(SpineAnimation));
|
||||||
auto anim = track_entry->getAnimation();
|
auto anim = track_entry->getAnimation();
|
||||||
if(anim == NULL) return NULL;
|
if (anim == NULL) return NULL;
|
||||||
gd_anim->set_spine_object(anim);
|
gd_anim->set_spine_object(anim);
|
||||||
return gd_anim;
|
return gd_anim;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineTrackEntry::get_loop(){
|
bool SpineTrackEntry::get_loop() {
|
||||||
return track_entry->getLoop();
|
return track_entry->getLoop();
|
||||||
}
|
}
|
||||||
void SpineTrackEntry::set_loop(bool v){
|
void SpineTrackEntry::set_loop(bool v) {
|
||||||
track_entry->setLoop(v);
|
track_entry->setLoop(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineTrackEntry::get_hold_previous(){
|
bool SpineTrackEntry::get_hold_previous() {
|
||||||
return track_entry->getHoldPrevious();
|
return track_entry->getHoldPrevious();
|
||||||
}
|
}
|
||||||
void SpineTrackEntry::set_hold_previous(bool v){
|
void SpineTrackEntry::set_hold_previous(bool v) {
|
||||||
track_entry->setHoldPrevious(v);
|
track_entry->setHoldPrevious(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTrackEntry::get_delay(){
|
float SpineTrackEntry::get_delay() {
|
||||||
return track_entry->getDelay();
|
return track_entry->getDelay();
|
||||||
}
|
}
|
||||||
void SpineTrackEntry::set_delay(float v){
|
void SpineTrackEntry::set_delay(float v) {
|
||||||
track_entry->setDelay(v);
|
track_entry->setDelay(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTrackEntry::get_track_time(){
|
float SpineTrackEntry::get_track_time() {
|
||||||
return track_entry->getTrackTime();
|
return track_entry->getTrackTime();
|
||||||
}
|
}
|
||||||
void SpineTrackEntry::set_track_time(float v){
|
void SpineTrackEntry::set_track_time(float v) {
|
||||||
track_entry->setTrackTime(v);
|
track_entry->setTrackTime(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTrackEntry::get_track_end(){
|
float SpineTrackEntry::get_track_end() {
|
||||||
return track_entry->getTrackEnd();
|
return track_entry->getTrackEnd();
|
||||||
}
|
}
|
||||||
void SpineTrackEntry::set_track_end(float v){
|
void SpineTrackEntry::set_track_end(float v) {
|
||||||
track_entry->setTrackEnd(v);
|
track_entry->setTrackEnd(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTrackEntry::get_animation_start(){
|
float SpineTrackEntry::get_animation_start() {
|
||||||
return track_entry->getAnimationStart();
|
return track_entry->getAnimationStart();
|
||||||
}
|
}
|
||||||
void SpineTrackEntry::set_animation_start(float v){
|
void SpineTrackEntry::set_animation_start(float v) {
|
||||||
track_entry->setAnimationStart(v);
|
track_entry->setAnimationStart(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTrackEntry::get_animation_last(){
|
float SpineTrackEntry::get_animation_last() {
|
||||||
return track_entry->getAnimationLast();
|
return track_entry->getAnimationLast();
|
||||||
}
|
}
|
||||||
void SpineTrackEntry::set_animation_last(float v){
|
void SpineTrackEntry::set_animation_last(float v) {
|
||||||
track_entry->setAnimationLast(v);
|
track_entry->setAnimationLast(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTrackEntry::get_animation_time(){
|
float SpineTrackEntry::get_animation_time() {
|
||||||
return track_entry->getAnimationTime();
|
return track_entry->getAnimationTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTrackEntry::get_time_scale(){
|
float SpineTrackEntry::get_time_scale() {
|
||||||
return track_entry->getTimeScale();
|
return track_entry->getTimeScale();
|
||||||
}
|
}
|
||||||
void SpineTrackEntry::set_time_scale(float v){
|
void SpineTrackEntry::set_time_scale(float v) {
|
||||||
track_entry->setTimeScale(v);
|
track_entry->setTimeScale(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTrackEntry::get_alpha(){
|
float SpineTrackEntry::get_alpha() {
|
||||||
return track_entry->getAlpha();
|
return track_entry->getAlpha();
|
||||||
}
|
}
|
||||||
void SpineTrackEntry::set_alpha(float v){
|
void SpineTrackEntry::set_alpha(float v) {
|
||||||
track_entry->setAlpha(v);
|
track_entry->setAlpha(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTrackEntry::get_event_threshold(){
|
float SpineTrackEntry::get_event_threshold() {
|
||||||
return track_entry->getEventThreshold();
|
return track_entry->getEventThreshold();
|
||||||
}
|
}
|
||||||
void SpineTrackEntry::set_event_threshold(float v){
|
void SpineTrackEntry::set_event_threshold(float v) {
|
||||||
track_entry->setEventThreshold(v);
|
track_entry->setEventThreshold(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTrackEntry::get_attachment_threshold(){
|
float SpineTrackEntry::get_attachment_threshold() {
|
||||||
return track_entry->getAttachmentThreshold();
|
return track_entry->getAttachmentThreshold();
|
||||||
}
|
}
|
||||||
void SpineTrackEntry::set_attachment_threshold(float v){
|
void SpineTrackEntry::set_attachment_threshold(float v) {
|
||||||
track_entry->setAttachmentThreshold(v);
|
track_entry->setAttachmentThreshold(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTrackEntry::get_draw_order_threshold(){
|
float SpineTrackEntry::get_draw_order_threshold() {
|
||||||
return track_entry->getDrawOrderThreshold();
|
return track_entry->getDrawOrderThreshold();
|
||||||
}
|
}
|
||||||
void SpineTrackEntry::set_draw_order_threshold(float v){
|
void SpineTrackEntry::set_draw_order_threshold(float v) {
|
||||||
track_entry->setDrawOrderThreshold(v);
|
track_entry->setDrawOrderThreshold(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineTrackEntry> SpineTrackEntry::get_next(){
|
Ref<SpineTrackEntry> SpineTrackEntry::get_next() {
|
||||||
Ref<SpineTrackEntry> gd_entry(memnew(SpineTrackEntry));
|
Ref<SpineTrackEntry> gd_entry(memnew(SpineTrackEntry));
|
||||||
auto entry = track_entry->getNext();
|
auto entry = track_entry->getNext();
|
||||||
if(entry == NULL) return NULL;
|
if (entry == NULL) return NULL;
|
||||||
gd_entry->set_spine_object(entry);
|
gd_entry->set_spine_object(entry);
|
||||||
return gd_entry;
|
return gd_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineTrackEntry::is_complete(){
|
bool SpineTrackEntry::is_complete() {
|
||||||
return track_entry->isComplete();
|
return track_entry->isComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTrackEntry::get_mix_time(){
|
float SpineTrackEntry::get_mix_time() {
|
||||||
return track_entry->getMixTime();
|
return track_entry->getMixTime();
|
||||||
}
|
}
|
||||||
void SpineTrackEntry::set_mix_time(float v){
|
void SpineTrackEntry::set_mix_time(float v) {
|
||||||
track_entry->setMixTime(v);
|
track_entry->setMixTime(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTrackEntry::get_mix_duration(){
|
float SpineTrackEntry::get_mix_duration() {
|
||||||
return track_entry->getMixDuration();
|
return track_entry->getMixDuration();
|
||||||
}
|
}
|
||||||
void SpineTrackEntry::set_mix_duration(float v){
|
void SpineTrackEntry::set_mix_duration(float v) {
|
||||||
track_entry->setMixDuration(v);
|
track_entry->setMixDuration(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineTrackEntry::MixBlend SpineTrackEntry::get_mix_blend(){
|
SpineTrackEntry::MixBlend SpineTrackEntry::get_mix_blend() {
|
||||||
int mb = track_entry->getMixBlend();
|
int mb = track_entry->getMixBlend();
|
||||||
return (MixBlend) mb;
|
return (MixBlend) mb;
|
||||||
}
|
}
|
||||||
void SpineTrackEntry::set_mix_blend(SpineTrackEntry::MixBlend v){
|
void SpineTrackEntry::set_mix_blend(SpineTrackEntry::MixBlend v) {
|
||||||
int mb = (int) v;
|
int mb = (int) v;
|
||||||
track_entry->setMixBlend((spine::MixBlend)mb);
|
track_entry->setMixBlend((spine::MixBlend) mb);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineTrackEntry> SpineTrackEntry::get_mixing_from(){
|
Ref<SpineTrackEntry> SpineTrackEntry::get_mixing_from() {
|
||||||
Ref<SpineTrackEntry> gd_entry(memnew(SpineTrackEntry));
|
Ref<SpineTrackEntry> gd_entry(memnew(SpineTrackEntry));
|
||||||
auto entry = track_entry->getMixingFrom();
|
auto entry = track_entry->getMixingFrom();
|
||||||
if(entry == NULL) return NULL;
|
if (entry == NULL) return NULL;
|
||||||
gd_entry->set_spine_object(entry);
|
gd_entry->set_spine_object(entry);
|
||||||
return gd_entry;
|
return gd_entry;
|
||||||
}
|
}
|
||||||
Ref<SpineTrackEntry> SpineTrackEntry::get_mixing_to(){
|
Ref<SpineTrackEntry> SpineTrackEntry::get_mixing_to() {
|
||||||
Ref<SpineTrackEntry> gd_entry(memnew(SpineTrackEntry));
|
Ref<SpineTrackEntry> gd_entry(memnew(SpineTrackEntry));
|
||||||
auto entry = track_entry->getMixingTo();
|
auto entry = track_entry->getMixingTo();
|
||||||
if(entry == NULL) return NULL;
|
if (entry == NULL) return NULL;
|
||||||
gd_entry->set_spine_object(entry);
|
gd_entry->set_spine_object(entry);
|
||||||
return gd_entry;
|
return gd_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineTrackEntry::reset_rotation_directions(){
|
void SpineTrackEntry::reset_rotation_directions() {
|
||||||
track_entry->resetRotationDirections();
|
track_entry->resetRotationDirections();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
#include "SpineAnimation.h"
|
#include "SpineAnimation.h"
|
||||||
|
|
||||||
class SpineTrackEntry : public Reference{
|
class SpineTrackEntry : public Reference {
|
||||||
GDCLASS(SpineTrackEntry, Reference);
|
GDCLASS(SpineTrackEntry, Reference);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -49,10 +49,10 @@ public:
|
|||||||
SpineTrackEntry();
|
SpineTrackEntry();
|
||||||
~SpineTrackEntry();
|
~SpineTrackEntry();
|
||||||
|
|
||||||
inline void set_spine_object(spine::TrackEntry *t){
|
inline void set_spine_object(spine::TrackEntry *t) {
|
||||||
track_entry = t;
|
track_entry = t;
|
||||||
}
|
}
|
||||||
inline spine::TrackEntry *get_spine_object(){
|
inline spine::TrackEntry *get_spine_object() {
|
||||||
return track_entry;
|
return track_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,4 +128,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
VARIANT_ENUM_CAST(SpineTrackEntry::MixBlend);
|
VARIANT_ENUM_CAST(SpineTrackEntry::MixBlend);
|
||||||
#endif //GODOT_SPINETRACKENTRY_H
|
#endif//GODOT_SPINETRACKENTRY_H
|
||||||
|
|||||||
@ -51,31 +51,31 @@ void SpineTransformConstraint::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_active", "v"), &SpineTransformConstraint::set_active);
|
ClassDB::bind_method(D_METHOD("set_active", "v"), &SpineTransformConstraint::set_active);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineTransformConstraint::SpineTransformConstraint():transform_constraint(NULL) {}
|
SpineTransformConstraint::SpineTransformConstraint() : transform_constraint(NULL) {}
|
||||||
SpineTransformConstraint::~SpineTransformConstraint() {}
|
SpineTransformConstraint::~SpineTransformConstraint() {}
|
||||||
|
|
||||||
void SpineTransformConstraint::update(){
|
void SpineTransformConstraint::update() {
|
||||||
transform_constraint->update();
|
transform_constraint->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SpineTransformConstraint::get_order(){
|
int SpineTransformConstraint::get_order() {
|
||||||
return transform_constraint->getOrder();
|
return transform_constraint->getOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineTransformConstraintData> SpineTransformConstraint::get_data(){
|
Ref<SpineTransformConstraintData> SpineTransformConstraint::get_data() {
|
||||||
auto &d = transform_constraint->getData();
|
auto &d = transform_constraint->getData();
|
||||||
Ref<SpineTransformConstraintData> gd_d(memnew(SpineTransformConstraintData));
|
Ref<SpineTransformConstraintData> gd_d(memnew(SpineTransformConstraintData));
|
||||||
gd_d->set_spine_object(&d);
|
gd_d->set_spine_object(&d);
|
||||||
return gd_d;
|
return gd_d;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array SpineTransformConstraint::get_bones(){
|
Array SpineTransformConstraint::get_bones() {
|
||||||
auto &bs = transform_constraint->getBones();
|
auto &bs = transform_constraint->getBones();
|
||||||
Array gd_bs;
|
Array gd_bs;
|
||||||
gd_bs.resize(bs.size());
|
gd_bs.resize(bs.size());
|
||||||
for(size_t i=0; i<bs.size(); ++i){
|
for (size_t i = 0; i < bs.size(); ++i) {
|
||||||
auto b = bs[i];
|
auto b = bs[i];
|
||||||
if(b == NULL) gd_bs[i] = Ref<SpineBone>(NULL);
|
if (b == NULL) gd_bs[i] = Ref<SpineBone>(NULL);
|
||||||
Ref<SpineBone> gd_b(memnew(SpineBone));
|
Ref<SpineBone> gd_b(memnew(SpineBone));
|
||||||
gd_b->set_spine_object(b);
|
gd_b->set_spine_object(b);
|
||||||
gd_bs[i] = gd_b;
|
gd_bs[i] = gd_b;
|
||||||
@ -83,66 +83,66 @@ Array SpineTransformConstraint::get_bones(){
|
|||||||
return gd_bs;
|
return gd_bs;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineBone> SpineTransformConstraint::get_target(){
|
Ref<SpineBone> SpineTransformConstraint::get_target() {
|
||||||
auto b = transform_constraint->getTarget();
|
auto b = transform_constraint->getTarget();
|
||||||
if(b == NULL) return NULL;
|
if (b == NULL) return NULL;
|
||||||
Ref<SpineBone> gd_b(memnew(SpineBone));
|
Ref<SpineBone> gd_b(memnew(SpineBone));
|
||||||
gd_b->set_spine_object(b);
|
gd_b->set_spine_object(b);
|
||||||
return gd_b;
|
return gd_b;
|
||||||
}
|
}
|
||||||
void SpineTransformConstraint::set_target(Ref<SpineBone> v){
|
void SpineTransformConstraint::set_target(Ref<SpineBone> v) {
|
||||||
if(v.is_valid()){
|
if (v.is_valid()) {
|
||||||
transform_constraint->setTarget(v->get_spine_object());
|
transform_constraint->setTarget(v->get_spine_object());
|
||||||
} else{
|
} else {
|
||||||
transform_constraint->setTarget(NULL);
|
transform_constraint->setTarget(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTransformConstraint::get_mix_rotate(){
|
float SpineTransformConstraint::get_mix_rotate() {
|
||||||
return transform_constraint->getMixRotate();
|
return transform_constraint->getMixRotate();
|
||||||
}
|
}
|
||||||
void SpineTransformConstraint::set_mix_rotate(float v){
|
void SpineTransformConstraint::set_mix_rotate(float v) {
|
||||||
transform_constraint->setMixRotate(v);
|
transform_constraint->setMixRotate(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTransformConstraint::get_mix_x(){
|
float SpineTransformConstraint::get_mix_x() {
|
||||||
return transform_constraint->getMixX();
|
return transform_constraint->getMixX();
|
||||||
}
|
}
|
||||||
void SpineTransformConstraint::set_mix_x(float v){
|
void SpineTransformConstraint::set_mix_x(float v) {
|
||||||
transform_constraint->setMixX(v);
|
transform_constraint->setMixX(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTransformConstraint::get_mix_y(){
|
float SpineTransformConstraint::get_mix_y() {
|
||||||
return transform_constraint->getMixY();
|
return transform_constraint->getMixY();
|
||||||
}
|
}
|
||||||
void SpineTransformConstraint::set_mix_y(float v){
|
void SpineTransformConstraint::set_mix_y(float v) {
|
||||||
transform_constraint->setMixY(v);
|
transform_constraint->setMixY(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTransformConstraint::get_mix_scale_x(){
|
float SpineTransformConstraint::get_mix_scale_x() {
|
||||||
return transform_constraint->getMixScaleX();
|
return transform_constraint->getMixScaleX();
|
||||||
}
|
}
|
||||||
void SpineTransformConstraint::set_mix_scale_x(float v){
|
void SpineTransformConstraint::set_mix_scale_x(float v) {
|
||||||
transform_constraint->setMixScaleX(v);
|
transform_constraint->setMixScaleX(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTransformConstraint::get_mix_scale_y(){
|
float SpineTransformConstraint::get_mix_scale_y() {
|
||||||
return transform_constraint->getMixScaleY();
|
return transform_constraint->getMixScaleY();
|
||||||
}
|
}
|
||||||
void SpineTransformConstraint::set_mix_scale_y(float v){
|
void SpineTransformConstraint::set_mix_scale_y(float v) {
|
||||||
transform_constraint->setMixScaleY(v);
|
transform_constraint->setMixScaleY(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTransformConstraint::get_mix_shear_y(){
|
float SpineTransformConstraint::get_mix_shear_y() {
|
||||||
return transform_constraint->getMixShearY();
|
return transform_constraint->getMixShearY();
|
||||||
}
|
}
|
||||||
void SpineTransformConstraint::set_mix_shear_y(float v){
|
void SpineTransformConstraint::set_mix_shear_y(float v) {
|
||||||
transform_constraint->setMixShearY(v);
|
transform_constraint->setMixShearY(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineTransformConstraint::is_active(){
|
bool SpineTransformConstraint::is_active() {
|
||||||
return transform_constraint->isActive();
|
return transform_constraint->isActive();
|
||||||
}
|
}
|
||||||
void SpineTransformConstraint::set_active(bool v){
|
void SpineTransformConstraint::set_active(bool v) {
|
||||||
transform_constraint->setActive(v);
|
transform_constraint->setActive(v);
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@
|
|||||||
#include "SpineTransformConstraintData.h"
|
#include "SpineTransformConstraintData.h"
|
||||||
#include "SpineBone.h"
|
#include "SpineBone.h"
|
||||||
|
|
||||||
class SpineTransformConstraint : public Reference{
|
class SpineTransformConstraint : public Reference {
|
||||||
GDCLASS(SpineTransformConstraint, Reference);
|
GDCLASS(SpineTransformConstraint, Reference);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -50,10 +50,10 @@ public:
|
|||||||
SpineTransformConstraint();
|
SpineTransformConstraint();
|
||||||
~SpineTransformConstraint();
|
~SpineTransformConstraint();
|
||||||
|
|
||||||
inline void set_spine_object(spine::TransformConstraint *tc){
|
inline void set_spine_object(spine::TransformConstraint *tc) {
|
||||||
transform_constraint = tc;
|
transform_constraint = tc;
|
||||||
}
|
}
|
||||||
inline spine::TransformConstraint *get_spine_object(){
|
inline spine::TransformConstraint *get_spine_object() {
|
||||||
return transform_constraint;
|
return transform_constraint;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,4 +90,4 @@ public:
|
|||||||
void set_active(bool v);
|
void set_active(bool v);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINETRANSFORMCONSTRAINT_H
|
#endif//GODOT_SPINETRANSFORMCONSTRAINT_H
|
||||||
|
|||||||
@ -51,12 +51,12 @@ void SpineTransformConstraintData::_bind_methods() {
|
|||||||
SpineTransformConstraintData::SpineTransformConstraintData() {}
|
SpineTransformConstraintData::SpineTransformConstraintData() {}
|
||||||
SpineTransformConstraintData::~SpineTransformConstraintData() {}
|
SpineTransformConstraintData::~SpineTransformConstraintData() {}
|
||||||
|
|
||||||
Array SpineTransformConstraintData::get_bones(){
|
Array SpineTransformConstraintData::get_bones() {
|
||||||
auto bs = get_spine_data()->getBones();
|
auto bs = get_spine_data()->getBones();
|
||||||
Array gd_bs;
|
Array gd_bs;
|
||||||
gd_bs.resize(bs.size());
|
gd_bs.resize(bs.size());
|
||||||
for(size_t i=0; i < bs.size(); ++i){
|
for (size_t i = 0; i < bs.size(); ++i) {
|
||||||
if(bs[i] == NULL) gd_bs[i] = Ref<SpineBoneData>(NULL);
|
if (bs[i] == NULL) gd_bs[i] = Ref<SpineBoneData>(NULL);
|
||||||
else {
|
else {
|
||||||
Ref<SpineBoneData> gd_b(memnew(SpineBoneData));
|
Ref<SpineBoneData> gd_b(memnew(SpineBoneData));
|
||||||
gd_b->set_spine_object(bs[i]);
|
gd_b->set_spine_object(bs[i]);
|
||||||
@ -65,54 +65,54 @@ Array SpineTransformConstraintData::get_bones(){
|
|||||||
}
|
}
|
||||||
return gd_bs;
|
return gd_bs;
|
||||||
}
|
}
|
||||||
Ref<SpineBoneData> SpineTransformConstraintData::get_target(){
|
Ref<SpineBoneData> SpineTransformConstraintData::get_target() {
|
||||||
auto b = get_spine_data()->getTarget();
|
auto b = get_spine_data()->getTarget();
|
||||||
if(b == NULL) return NULL;
|
if (b == NULL) return NULL;
|
||||||
Ref<SpineBoneData> gd_b(memnew(SpineBoneData));
|
Ref<SpineBoneData> gd_b(memnew(SpineBoneData));
|
||||||
gd_b->set_spine_object(b);
|
gd_b->set_spine_object(b);
|
||||||
return gd_b;
|
return gd_b;
|
||||||
}
|
}
|
||||||
float SpineTransformConstraintData::get_mix_rotate(){
|
float SpineTransformConstraintData::get_mix_rotate() {
|
||||||
return get_spine_data()->getMixRotate();
|
return get_spine_data()->getMixRotate();
|
||||||
}
|
}
|
||||||
float SpineTransformConstraintData::get_mix_x(){
|
float SpineTransformConstraintData::get_mix_x() {
|
||||||
return get_spine_data()->getMixX();
|
return get_spine_data()->getMixX();
|
||||||
}
|
}
|
||||||
float SpineTransformConstraintData::get_mix_y(){
|
float SpineTransformConstraintData::get_mix_y() {
|
||||||
return get_spine_data()->getMixY();
|
return get_spine_data()->getMixY();
|
||||||
}
|
}
|
||||||
float SpineTransformConstraintData::get_mix_scale_x(){
|
float SpineTransformConstraintData::get_mix_scale_x() {
|
||||||
return get_spine_data()->getMixScaleX();
|
return get_spine_data()->getMixScaleX();
|
||||||
}
|
}
|
||||||
float SpineTransformConstraintData::get_mix_scale_y(){
|
float SpineTransformConstraintData::get_mix_scale_y() {
|
||||||
return get_spine_data()->getMixScaleY();
|
return get_spine_data()->getMixScaleY();
|
||||||
}
|
}
|
||||||
float SpineTransformConstraintData::get_mix_shear_y(){
|
float SpineTransformConstraintData::get_mix_shear_y() {
|
||||||
return get_spine_data()->getMixShearY();
|
return get_spine_data()->getMixShearY();
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTransformConstraintData::get_offset_rotation(){
|
float SpineTransformConstraintData::get_offset_rotation() {
|
||||||
return get_spine_data()->getOffsetRotation();
|
return get_spine_data()->getOffsetRotation();
|
||||||
}
|
}
|
||||||
float SpineTransformConstraintData::get_offset_x(){
|
float SpineTransformConstraintData::get_offset_x() {
|
||||||
return get_spine_data()->getOffsetX();
|
return get_spine_data()->getOffsetX();
|
||||||
}
|
}
|
||||||
float SpineTransformConstraintData::get_offset_y(){
|
float SpineTransformConstraintData::get_offset_y() {
|
||||||
return get_spine_data()->getOffsetY();
|
return get_spine_data()->getOffsetY();
|
||||||
}
|
}
|
||||||
float SpineTransformConstraintData::get_offset_scale_x(){
|
float SpineTransformConstraintData::get_offset_scale_x() {
|
||||||
return get_spine_data()->getOffsetScaleX();
|
return get_spine_data()->getOffsetScaleX();
|
||||||
}
|
}
|
||||||
float SpineTransformConstraintData::get_offset_scale_y(){
|
float SpineTransformConstraintData::get_offset_scale_y() {
|
||||||
return get_spine_data()->getOffsetScaleY();
|
return get_spine_data()->getOffsetScaleY();
|
||||||
}
|
}
|
||||||
float SpineTransformConstraintData::get_offset_shear_y(){
|
float SpineTransformConstraintData::get_offset_shear_y() {
|
||||||
return get_spine_data()->getOffsetShearY();
|
return get_spine_data()->getOffsetShearY();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineTransformConstraintData::is_relative(){
|
bool SpineTransformConstraintData::is_relative() {
|
||||||
return get_spine_data()->isRelative();
|
return get_spine_data()->isRelative();
|
||||||
}
|
}
|
||||||
bool SpineTransformConstraintData::is_local(){
|
bool SpineTransformConstraintData::is_local() {
|
||||||
return get_spine_data()->isLocal();
|
return get_spine_data()->isLocal();
|
||||||
}
|
}
|
||||||
@ -47,8 +47,8 @@ public:
|
|||||||
SpineTransformConstraintData();
|
SpineTransformConstraintData();
|
||||||
~SpineTransformConstraintData();
|
~SpineTransformConstraintData();
|
||||||
|
|
||||||
virtual inline spine::TransformConstraintData *get_spine_data(){
|
virtual inline spine::TransformConstraintData *get_spine_data() {
|
||||||
return (spine::TransformConstraintData*) SpineConstraintData::get_spine_object();
|
return (spine::TransformConstraintData *) SpineConstraintData::get_spine_object();
|
||||||
}
|
}
|
||||||
|
|
||||||
Array get_bones();
|
Array get_bones();
|
||||||
@ -71,4 +71,4 @@ public:
|
|||||||
bool is_local();
|
bool is_local();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //GODOT_SPINETRANSFORMCONSTRAINTDATA_H
|
#endif//GODOT_SPINETRANSFORMCONSTRAINTDATA_H
|
||||||
|
|||||||
@ -80,7 +80,7 @@ static void editor_init_callback() {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void register_spine_godot_types(){
|
void register_spine_godot_types() {
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
ClassDB::register_class<SpineSpriteAnimateDialog>();
|
ClassDB::register_class<SpineSpriteAnimateDialog>();
|
||||||
|
|
||||||
@ -131,10 +131,9 @@ void register_spine_godot_types(){
|
|||||||
|
|
||||||
json_skeleton_saver.instance();
|
json_skeleton_saver.instance();
|
||||||
ResourceSaver::add_resource_format_saver(json_skeleton_saver);
|
ResourceSaver::add_resource_format_saver(json_skeleton_saver);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void unregister_spine_godot_types(){
|
void unregister_spine_godot_types() {
|
||||||
ResourceLoader::remove_resource_format_loader(atlas_loader);
|
ResourceLoader::remove_resource_format_loader(atlas_loader);
|
||||||
atlas_loader.unref();
|
atlas_loader.unref();
|
||||||
|
|
||||||
|
|||||||
@ -29,4 +29,3 @@
|
|||||||
|
|
||||||
void register_spine_godot_types();
|
void register_spine_godot_types();
|
||||||
void unregister_spine_godot_types();
|
void unregister_spine_godot_types();
|
||||||
|
|
||||||
|
|||||||
@ -1095,24 +1095,24 @@ export enum EventType {
|
|||||||
* {@link AnimationState#addListener()}. */
|
* {@link AnimationState#addListener()}. */
|
||||||
export interface AnimationStateListener {
|
export interface AnimationStateListener {
|
||||||
/** Invoked when this entry has been set as the current entry. */
|
/** Invoked when this entry has been set as the current entry. */
|
||||||
start? (entry: TrackEntry): void;
|
start?(entry: TrackEntry): void;
|
||||||
|
|
||||||
/** Invoked when another entry has replaced this entry as the current entry. This entry may continue being applied for
|
/** Invoked when another entry has replaced this entry as the current entry. This entry may continue being applied for
|
||||||
* mixing. */
|
* mixing. */
|
||||||
interrupt? (entry: TrackEntry): void;
|
interrupt?(entry: TrackEntry): void;
|
||||||
|
|
||||||
/** Invoked when this entry is no longer the current entry and will never be applied again. */
|
/** Invoked when this entry is no longer the current entry and will never be applied again. */
|
||||||
end? (entry: TrackEntry): void;
|
end?(entry: TrackEntry): void;
|
||||||
|
|
||||||
/** Invoked when this entry will be disposed. This may occur without the entry ever being set as the current entry.
|
/** Invoked when this entry will be disposed. This may occur without the entry ever being set as the current entry.
|
||||||
* References to the entry should not be kept after dispose is called, as it may be destroyed or reused. */
|
* References to the entry should not be kept after dispose is called, as it may be destroyed or reused. */
|
||||||
dispose? (entry: TrackEntry): void;
|
dispose?(entry: TrackEntry): void;
|
||||||
|
|
||||||
/** Invoked every time this entry's animation completes a loop. */
|
/** Invoked every time this entry's animation completes a loop. */
|
||||||
complete? (entry: TrackEntry): void;
|
complete?(entry: TrackEntry): void;
|
||||||
|
|
||||||
/** Invoked when this entry's animation triggers an event. */
|
/** Invoked when this entry's animation triggers an event. */
|
||||||
event? (entry: TrackEntry, event: Event): void;
|
event?(entry: TrackEntry, event: Event): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export abstract class AnimationStateAdapter implements AnimationStateListener {
|
export abstract class AnimationStateAdapter implements AnimationStateListener {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user