mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Prefixed all spine-c structs and functions with "sp".
Holy refuctoring! Sorry for the change, but some libraries were having naming conflicts. You can define SPINE_SHORT_NAMES before including spine-c headers if you want to use structs and functions without the "sp" prefix, as it was before.
This commit is contained in:
parent
819b100a51
commit
2bff08de4b
@ -9,47 +9,47 @@
|
|||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
void _AtlasPage_createTexture (AtlasPage* self, const char* path) {
|
void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) {
|
||||||
self->rendererObject = 0;
|
self->rendererObject = 0;
|
||||||
self->width = 123;
|
self->width = 123;
|
||||||
self->height = 456;
|
self->height = 456;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _AtlasPage_disposeTexture (AtlasPage* self) {
|
void _spAtlasPage_disposeTexture (spAtlasPage* self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char* _Util_readFile (const char* path, int* length) {
|
char* _spUtil_readFile (const char* path, int* length) {
|
||||||
return _readFile(path, length);
|
return _readFile(path, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
int main (void) {
|
int main (void) {
|
||||||
Atlas* atlas = Atlas_readAtlasFile("data/spineboy.atlas");
|
spAtlas* atlas = spAtlas_readAtlasFile("data/spineboy.atlas");
|
||||||
printf("First region name: %s, x: %d, y: %d\n", atlas->regions->name, atlas->regions->x, atlas->regions->y);
|
printf("First region name: %s, x: %d, y: %d\n", atlas->regions->name, atlas->regions->x, atlas->regions->y);
|
||||||
printf("First page name: %s, size: %d, %d\n", atlas->pages->name, atlas->pages->width, atlas->pages->height);
|
printf("First page name: %s, size: %d, %d\n", atlas->pages->name, atlas->pages->width, atlas->pages->height);
|
||||||
|
|
||||||
SkeletonJson* json = SkeletonJson_create(atlas);
|
spSkeletonJson* json = spSkeletonJson_create(atlas);
|
||||||
SkeletonData *skeletonData = SkeletonJson_readSkeletonDataFile(json, "data/spineboy.json");
|
spSkeletonData *skeletonData = spSkeletonJson_readSkeletonDataFile(json, "data/spineboy.json");
|
||||||
if (!skeletonData) {
|
if (!skeletonData) {
|
||||||
printf("Error: %s\n", json->error);
|
printf("Error: %s\n", json->error);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
printf("Default skin name: %s\n", skeletonData->defaultSkin->name);
|
printf("Default skin name: %s\n", skeletonData->defaultSkin->name);
|
||||||
|
|
||||||
Skeleton* skeleton = Skeleton_create(skeletonData);
|
spSkeleton* skeleton = spSkeleton_create(skeletonData);
|
||||||
|
|
||||||
Animation* animation = SkeletonData_findAnimation(skeletonData, "walk");
|
spAnimation* animation = spSkeletonData_findAnimation(skeletonData, "walk");
|
||||||
if (!animation) {
|
if (!animation) {
|
||||||
printf("Error: Animation not found: walk\n");
|
printf("Error: Animation not found: walk\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
printf("Animation timelineCount: %d\n", animation->timelineCount);
|
printf("Animation timelineCount: %d\n", animation->timelineCount);
|
||||||
|
|
||||||
Skeleton_dispose(skeleton);
|
spSkeleton_dispose(skeleton);
|
||||||
SkeletonData_dispose(skeletonData);
|
spSkeletonData_dispose(skeletonData);
|
||||||
SkeletonJson_dispose(json);
|
spSkeletonJson_dispose(json);
|
||||||
Atlas_dispose(atlas);
|
spAtlas_dispose(atlas);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -40,142 +40,206 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct Timeline Timeline;
|
typedef struct spTimeline spTimeline;
|
||||||
struct Skeleton;
|
struct spSkeleton;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char* const name;
|
const char* const name;
|
||||||
float duration;
|
float duration;
|
||||||
|
|
||||||
int timelineCount;
|
int timelineCount;
|
||||||
Timeline** timelines;
|
spTimeline** timelines;
|
||||||
} Animation;
|
} spAnimation;
|
||||||
|
|
||||||
Animation* Animation_create (const char* name, int timelineCount);
|
spAnimation* spAnimation_create (const char* name, int timelineCount);
|
||||||
void Animation_dispose (Animation* self);
|
void spAnimation_dispose (spAnimation* self);
|
||||||
|
|
||||||
/** Poses the skeleton at the specified time for this animation.
|
/** Poses the skeleton at the specified time for this animation.
|
||||||
* @param lastTime The last time the animation was applied.
|
* @param lastTime The last time the animation was applied.
|
||||||
* @param events Any triggered events are added. */
|
* @param events Any triggered events are added. */
|
||||||
void Animation_apply (const Animation* self, struct Skeleton* skeleton, float lastTime, float time, int loop,
|
void spAnimation_apply (const spAnimation* self, struct spSkeleton* skeleton, float lastTime, float time, int loop,
|
||||||
Event** events, int* eventCount);
|
spEvent** events, int* eventCount);
|
||||||
|
|
||||||
/** Poses the skeleton at the specified time for this animation mixed with the current pose.
|
/** Poses the skeleton at the specified time for this animation mixed with the current pose.
|
||||||
* @param lastTime The last time the animation was applied.
|
* @param lastTime The last time the animation was applied.
|
||||||
* @param events Any triggered events are added.
|
* @param events Any triggered events are added.
|
||||||
* @param alpha The amount of this animation that affects the current pose. */
|
* @param alpha The amount of this animation that affects the current pose. */
|
||||||
void Animation_mix (const Animation* self, struct Skeleton* skeleton, float lastTime, float time, int loop, Event** events,
|
void spAnimation_mix (const spAnimation* self, struct spSkeleton* skeleton, float lastTime, float time, int loop, spEvent** events,
|
||||||
int* eventCount, float alpha);
|
int* eventCount, float alpha);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spAnimation Animation;
|
||||||
|
#define Animation_create(...) spAnimation_create(__VA_ARGS__)
|
||||||
|
#define Animation_dispose(...) spAnimation_dispose(__VA_ARGS__)
|
||||||
|
#define Animation_apply(...) spAnimation_apply(__VA_ARGS__)
|
||||||
|
#define Animation_mix(...) spAnimation_mix(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
struct Timeline {
|
struct spTimeline {
|
||||||
const void* const vtable;
|
const void* const vtable;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Timeline_dispose (Timeline* self);
|
void spTimeline_dispose (spTimeline* self);
|
||||||
void Timeline_apply (const Timeline* self, struct Skeleton* skeleton, float lastTime, float time, Event** firedEvents,
|
void spTimeline_apply (const spTimeline* self, struct spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int* eventCount, float alpha);
|
int* eventCount, float alpha);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spTimeline Timeline;
|
||||||
|
#define Timeline_dispose(...) spTimeline_dispose(__VA_ARGS__)
|
||||||
|
#define Timeline_apply(...) spTimeline_apply(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Timeline super;
|
spTimeline super;
|
||||||
float* curves; /* dfx, dfy, ddfx, ddfy, dddfx, dddfy, ... */
|
float* curves; /* dfx, dfy, ddfx, ddfy, dddfx, dddfy, ... */
|
||||||
} CurveTimeline;
|
} spCurveTimeline;
|
||||||
|
|
||||||
void CurveTimeline_setLinear (CurveTimeline* self, int frameIndex);
|
void spCurveTimeline_setLinear (spCurveTimeline* self, int frameIndex);
|
||||||
void CurveTimeline_setStepped (CurveTimeline* self, int frameIndex);
|
void spCurveTimeline_setStepped (spCurveTimeline* self, int frameIndex);
|
||||||
|
|
||||||
/* Sets the control handle positions for an interpolation bezier curve used to transition from this keyframe to the next.
|
/* Sets the control handle positions for an interpolation bezier curve used to transition from this keyframe to the next.
|
||||||
* cx1 and cx2 are from 0 to 1, representing the percent of time between the two keyframes. cy1 and cy2 are the percent of
|
* cx1 and cx2 are from 0 to 1, representing the percent of time between the two keyframes. cy1 and cy2 are the percent of
|
||||||
* the difference between the keyframe's values. */
|
* the difference between the keyframe's values. */
|
||||||
void CurveTimeline_setCurve (CurveTimeline* self, int frameIndex, float cx1, float cy1, float cx2, float cy2);
|
void spCurveTimeline_setCurve (spCurveTimeline* self, int frameIndex, float cx1, float cy1, float cx2, float cy2);
|
||||||
float CurveTimeline_getCurvePercent (const CurveTimeline* self, int frameIndex, float percent);
|
float spCurveTimeline_getCurvePercent (const spCurveTimeline* self, int frameIndex, float percent);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spCurveTimeline CurveTimeline;
|
||||||
|
#define CurveTimeline_setLinear(...) spCurveTimeline_setLinear(__VA_ARGS__)
|
||||||
|
#define CurveTimeline_setStepped(...) spCurveTimeline_setStepped(__VA_ARGS__)
|
||||||
|
#define CurveTimeline_setCurve(...) spCurveTimeline_setCurve(__VA_ARGS__)
|
||||||
|
#define CurveTimeline_getCurvePercent(...) spCurveTimeline_getCurvePercent(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
typedef struct BaseTimeline {
|
typedef struct spBaseTimeline {
|
||||||
CurveTimeline super;
|
spCurveTimeline super;
|
||||||
int const framesLength;
|
int const framesLength;
|
||||||
float* const frames; /* time, angle, ... for rotate. time, x, y, ... for translate and scale. */
|
float* const frames; /* time, angle, ... for rotate. time, x, y, ... for translate and scale. */
|
||||||
int boneIndex;
|
int boneIndex;
|
||||||
} RotateTimeline;
|
} spRotateTimeline;
|
||||||
|
|
||||||
RotateTimeline* RotateTimeline_create (int frameCount);
|
spRotateTimeline* spRotateTimeline_create (int frameCount);
|
||||||
|
|
||||||
void RotateTimeline_setFrame (RotateTimeline* self, int frameIndex, float time, float angle);
|
void spRotateTimeline_setFrame (spRotateTimeline* self, int frameIndex, float time, float angle);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spRotateTimeline RotateTimeline;
|
||||||
|
#define RotateTimeline_create(...) spRotateTimeline_create(__VA_ARGS__)
|
||||||
|
#define RotateTimeline_setFrame(...) spRotateTimeline_setFrame(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
typedef struct BaseTimeline TranslateTimeline;
|
typedef struct spBaseTimeline spTranslateTimeline;
|
||||||
|
|
||||||
TranslateTimeline* TranslateTimeline_create (int frameCount);
|
spTranslateTimeline* spTranslateTimeline_create (int frameCount);
|
||||||
|
|
||||||
void TranslateTimeline_setFrame (TranslateTimeline* self, int frameIndex, float time, float x, float y);
|
void spTranslateTimeline_setFrame (spTranslateTimeline* self, int frameIndex, float time, float x, float y);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spTranslateTimeline TranslateTimeline;
|
||||||
|
#define TranslateTimeline_create(...) spTranslateTimeline_create(__VA_ARGS__)
|
||||||
|
#define TranslateTimeline_setFrame(...) spTranslateTimeline_setFrame(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
typedef struct BaseTimeline ScaleTimeline;
|
typedef struct spBaseTimeline spScaleTimeline;
|
||||||
|
|
||||||
ScaleTimeline* ScaleTimeline_create (int frameCount);
|
spScaleTimeline* spScaleTimeline_create (int frameCount);
|
||||||
|
|
||||||
void ScaleTimeline_setFrame (ScaleTimeline* self, int frameIndex, float time, float x, float y);
|
void spScaleTimeline_setFrame (spScaleTimeline* self, int frameIndex, float time, float x, float y);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spScaleTimeline ScaleTimeline;
|
||||||
|
#define ScaleTimeline_create(...) spScaleTimeline_create(__VA_ARGS__)
|
||||||
|
#define ScaleTimeline_setFrame(...) spScaleTimeline_setFrame(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
CurveTimeline super;
|
spCurveTimeline super;
|
||||||
int const framesLength;
|
int const framesLength;
|
||||||
float* const frames; /* time, r, g, b, a, ... */
|
float* const frames; /* time, r, g, b, a, ... */
|
||||||
int slotIndex;
|
int slotIndex;
|
||||||
} ColorTimeline;
|
} spColorTimeline;
|
||||||
|
|
||||||
ColorTimeline* ColorTimeline_create (int frameCount);
|
spColorTimeline* spColorTimeline_create (int frameCount);
|
||||||
|
|
||||||
void ColorTimeline_setFrame (ColorTimeline* self, int frameIndex, float time, float r, float g, float b, float a);
|
void spColorTimeline_setFrame (spColorTimeline* self, int frameIndex, float time, float r, float g, float b, float a);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spColorTimeline ColorTimeline;
|
||||||
|
#define ColorTimeline_create(...) spColorTimeline_create(__VA_ARGS__)
|
||||||
|
#define ColorTimeline_setFrame(...) spColorTimeline_setFrame(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Timeline super;
|
spTimeline super;
|
||||||
int const framesLength;
|
int const framesLength;
|
||||||
float* const frames; /* time, ... */
|
float* const frames; /* time, ... */
|
||||||
int slotIndex;
|
int slotIndex;
|
||||||
const char** const attachmentNames;
|
const char** const attachmentNames;
|
||||||
} AttachmentTimeline;
|
} spAttachmentTimeline;
|
||||||
|
|
||||||
AttachmentTimeline* AttachmentTimeline_create (int frameCount);
|
spAttachmentTimeline* spAttachmentTimeline_create (int frameCount);
|
||||||
|
|
||||||
/* @param attachmentName May be 0. */
|
/* @param attachmentName May be 0. */
|
||||||
void AttachmentTimeline_setFrame (AttachmentTimeline* self, int frameIndex, float time, const char* attachmentName);
|
void spAttachmentTimeline_setFrame (spAttachmentTimeline* self, int frameIndex, float time, const char* attachmentName);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spAttachmentTimeline AttachmentTimeline;
|
||||||
|
#define AttachmentTimeline_create(...) spAttachmentTimeline_create(__VA_ARGS__)
|
||||||
|
#define AttachmentTimeline_setFrame(...) spAttachmentTimeline_setFrame(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Timeline super;
|
spTimeline super;
|
||||||
int const framesLength;
|
int const framesLength;
|
||||||
float* const frames; /* time, ... */
|
float* const frames; /* time, ... */
|
||||||
Event** const events;
|
spEvent** const events;
|
||||||
} EventTimeline;
|
} spEventTimeline;
|
||||||
|
|
||||||
EventTimeline* EventTimeline_create (int frameCount);
|
spEventTimeline* spEventTimeline_create (int frameCount);
|
||||||
|
|
||||||
void EventTimeline_setFrame (EventTimeline* self, int frameIndex, float time, Event* event);
|
void spEventTimeline_setFrame (spEventTimeline* self, int frameIndex, float time, spEvent* event);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spEventTimeline EventTimeline;
|
||||||
|
#define EventTimeline_create(...) spEventTimeline_create(__VA_ARGS__)
|
||||||
|
#define EventTimeline_setFrame(...) spEventTimeline_setFrame(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Timeline super;
|
spTimeline super;
|
||||||
int const framesLength;
|
int const framesLength;
|
||||||
float* const frames; /* time, ... */
|
float* const frames; /* time, ... */
|
||||||
const int** const drawOrders;
|
const int** const drawOrders;
|
||||||
int const slotCount;
|
int const slotCount;
|
||||||
} DrawOrderTimeline;
|
} spDrawOrderTimeline;
|
||||||
|
|
||||||
DrawOrderTimeline* DrawOrderTimeline_create (int frameCount, int slotCount);
|
spDrawOrderTimeline* spDrawOrderTimeline_create (int frameCount, int slotCount);
|
||||||
|
|
||||||
void DrawOrderTimeline_setFrame (DrawOrderTimeline* self, int frameIndex, float time, const int* drawOrder);
|
void spDrawOrderTimeline_setFrame (spDrawOrderTimeline* self, int frameIndex, float time, const int* drawOrder);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spDrawOrderTimeline DrawOrderTimeline;
|
||||||
|
#define DrawOrderTimeline_create(...) spDrawOrderTimeline_create(__VA_ARGS__)
|
||||||
|
#define DrawOrderTimeline_setFrame(...) spDrawOrderTimeline_setFrame(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,6 +34,7 @@
|
|||||||
#ifndef SPINE_ANIMATIONSTATE_H_
|
#ifndef SPINE_ANIMATIONSTATE_H_
|
||||||
#define SPINE_ANIMATIONSTATE_H_
|
#define SPINE_ANIMATIONSTATE_H_
|
||||||
|
|
||||||
|
#include <spine/Animation.h>
|
||||||
#include <spine/AnimationStateData.h>
|
#include <spine/AnimationStateData.h>
|
||||||
#include <spine/Event.h>
|
#include <spine/Event.h>
|
||||||
|
|
||||||
@ -43,55 +44,75 @@ extern "C" {
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ANIMATION_START, ANIMATION_END, ANIMATION_COMPLETE, ANIMATION_EVENT
|
ANIMATION_START, ANIMATION_END, ANIMATION_COMPLETE, ANIMATION_EVENT
|
||||||
} EventType;
|
} spEventType;
|
||||||
|
|
||||||
typedef struct AnimationState AnimationState;
|
typedef struct spAnimationState spAnimationState;
|
||||||
|
|
||||||
typedef void (*AnimationStateListener) (AnimationState* state, int trackIndex, EventType type, Event* event, int loopCount);
|
typedef void (*spAnimationStateListener) (spAnimationState* state, int trackIndex, spEventType type, spEvent* event,
|
||||||
|
int loopCount);
|
||||||
|
|
||||||
typedef struct TrackEntry TrackEntry;
|
typedef struct spTrackEntry spTrackEntry;
|
||||||
struct TrackEntry {
|
struct spTrackEntry {
|
||||||
TrackEntry* next;
|
spTrackEntry* next;
|
||||||
TrackEntry* previous;
|
spTrackEntry* previous;
|
||||||
Animation* animation;
|
spAnimation* animation;
|
||||||
int/*bool*/loop;
|
int/*bool*/loop;
|
||||||
float delay, time, lastTime, endTime, timeScale;
|
float delay, time, lastTime, endTime, timeScale;
|
||||||
AnimationStateListener listener;
|
spAnimationStateListener listener;
|
||||||
float mixTime, mixDuration;
|
float mixTime, mixDuration;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AnimationState {
|
struct spAnimationState {
|
||||||
AnimationStateData* const data;
|
spAnimationStateData* const data;
|
||||||
float timeScale;
|
float timeScale;
|
||||||
AnimationStateListener listener;
|
spAnimationStateListener listener;
|
||||||
void* context;
|
void* context;
|
||||||
|
|
||||||
int trackCount;
|
int trackCount;
|
||||||
TrackEntry** tracks;
|
spTrackEntry** tracks;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* @param data May be 0 for no mixing. */
|
/* @param data May be 0 for no mixing. */
|
||||||
AnimationState* AnimationState_create (AnimationStateData* data);
|
spAnimationState* spAnimationState_create (spAnimationStateData* data);
|
||||||
void AnimationState_dispose (AnimationState* self);
|
void spAnimationState_dispose (spAnimationState* self);
|
||||||
|
|
||||||
void AnimationState_update (AnimationState* self, float delta);
|
void spAnimationState_update (spAnimationState* self, float delta);
|
||||||
void AnimationState_apply (AnimationState* self, struct Skeleton* skeleton);
|
void spAnimationState_apply (spAnimationState* self, struct spSkeleton* skeleton);
|
||||||
|
|
||||||
void AnimationState_clearTracks (AnimationState* self);
|
void spAnimationState_clearTracks (spAnimationState* self);
|
||||||
void AnimationState_clearTrack (AnimationState* self, int trackIndex);
|
void spAnimationState_clearTrack (spAnimationState* self, int trackIndex);
|
||||||
|
|
||||||
/** Set the current animation. Any queued animations are cleared. */
|
/** Set the current animation. Any queued animations are cleared. */
|
||||||
TrackEntry* AnimationState_setAnimationByName (AnimationState* self, int trackIndex, const char* animationName, int/*bool*/loop);
|
spTrackEntry* spAnimationState_setAnimationByName (spAnimationState* self, int trackIndex, const char* animationName,
|
||||||
TrackEntry* AnimationState_setAnimation (AnimationState* self, int trackIndex, Animation* animation, int/*bool*/loop);
|
int/*bool*/loop);
|
||||||
|
spTrackEntry* spAnimationState_setAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop);
|
||||||
|
|
||||||
/** Adds an animation to be played delay seconds after the current or last queued animation, taking into account any mix
|
/** Adds an animation to be played delay seconds after the current or last queued animation, taking into account any mix
|
||||||
* duration. */
|
* duration. */
|
||||||
TrackEntry* AnimationState_addAnimationByName (AnimationState* self, int trackIndex, const char* animationName, int/*bool*/loop,
|
spTrackEntry* spAnimationState_addAnimationByName (spAnimationState* self, int trackIndex, const char* animationName,
|
||||||
float delay);
|
int/*bool*/loop, float delay);
|
||||||
TrackEntry* AnimationState_addAnimation (AnimationState* self, int trackIndex, Animation* animation, int/*bool*/loop,
|
spTrackEntry* spAnimationState_addAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop,
|
||||||
float delay);
|
float delay);
|
||||||
|
|
||||||
TrackEntry* AnimationState_getCurrent (AnimationState* self, int trackIndex);
|
spTrackEntry* spAnimationState_getCurrent (spAnimationState* self, int trackIndex);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spEventType EventType;
|
||||||
|
typedef spAnimationStateListener AnimationStateListener;
|
||||||
|
typedef spTrackEntry TrackEntry;
|
||||||
|
typedef spAnimationState AnimationState;
|
||||||
|
#define AnimationState_create(...) spAnimationState_create(__VA_ARGS__)
|
||||||
|
#define AnimationState_dispose(...) spAnimationState_dispose(__VA_ARGS__)
|
||||||
|
#define AnimationState_update(...) spAnimationState_update(__VA_ARGS__)
|
||||||
|
#define AnimationState_apply(...) spAnimationState_apply(__VA_ARGS__)
|
||||||
|
#define AnimationState_clearTracks(...) spAnimationState_clearTracks(__VA_ARGS__)
|
||||||
|
#define AnimationState_clearTrack(...) spAnimationState_clearTrack(__VA_ARGS__)
|
||||||
|
#define AnimationState_setAnimationByName(...) spAnimationState_setAnimationByName(__VA_ARGS__)
|
||||||
|
#define AnimationState_setAnimation(...) spAnimationState_setAnimation(__VA_ARGS__)
|
||||||
|
#define AnimationState_addAnimationByName(...) spAnimationState_addAnimationByName(__VA_ARGS__)
|
||||||
|
#define AnimationState_addAnimation(...) spAnimationState_addAnimation(__VA_ARGS__)
|
||||||
|
#define AnimationState_getCurrent(...) spAnimationState_getCurrent(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,18 +42,27 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SkeletonData* const skeletonData;
|
spSkeletonData* const skeletonData;
|
||||||
float defaultMix;
|
float defaultMix;
|
||||||
const void* const entries;
|
const void* const entries;
|
||||||
} AnimationStateData;
|
} spAnimationStateData;
|
||||||
|
|
||||||
AnimationStateData* AnimationStateData_create (SkeletonData* skeletonData);
|
spAnimationStateData* spAnimationStateData_create (spSkeletonData* skeletonData);
|
||||||
void AnimationStateData_dispose (AnimationStateData* self);
|
void spAnimationStateData_dispose (spAnimationStateData* self);
|
||||||
|
|
||||||
void AnimationStateData_setMixByName (AnimationStateData* self, const char* fromName, const char* toName, float duration);
|
void spAnimationStateData_setMixByName (spAnimationStateData* self, const char* fromName, const char* toName, float duration);
|
||||||
void AnimationStateData_setMix (AnimationStateData* self, Animation* from, Animation* to, float duration);
|
void spAnimationStateData_setMix (spAnimationStateData* self, spAnimation* from, spAnimation* to, float duration);
|
||||||
/* Returns 0 if there is no mixing between the animations. */
|
/* Returns 0 if there is no mixing between the animations. */
|
||||||
float AnimationStateData_getMix (AnimationStateData* self, Animation* from, Animation* to);
|
float spAnimationStateData_getMix (spAnimationStateData* self, spAnimation* from, spAnimation* to);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spAnimationStateData AnimationStateData;
|
||||||
|
#define AnimationStateData_create(...) spAnimationStateData_create(__VA_ARGS__)
|
||||||
|
#define AnimationStateData_dispose(...) spAnimationStateData_dispose(__VA_ARGS__)
|
||||||
|
#define AnimationStateData_setMixByName(...) spAnimationStateData_setMixByName(__VA_ARGS__)
|
||||||
|
#define AnimationStateData_setMix(...) spAnimationStateData_setMix(__VA_ARGS__)
|
||||||
|
#define AnimationStateData_getMix(...) spAnimationStateData_getMix(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,7 +40,7 @@ extern "C" {
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ATLAS_ALPHA, ATLAS_INTENSITY, ATLAS_LUMINANCE_ALPHA, ATLAS_RGB565, ATLAS_RGBA4444, ATLAS_RGB888, ATLAS_RGBA8888
|
ATLAS_ALPHA, ATLAS_INTENSITY, ATLAS_LUMINANCE_ALPHA, ATLAS_RGB565, ATLAS_RGBA4444, ATLAS_RGB888, ATLAS_RGBA8888
|
||||||
} AtlasFormat;
|
} spAtlasFormat;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ATLAS_NEAREST,
|
ATLAS_NEAREST,
|
||||||
@ -50,32 +50,41 @@ typedef enum {
|
|||||||
ATLAS_MIPMAP_LINEAR_NEAREST,
|
ATLAS_MIPMAP_LINEAR_NEAREST,
|
||||||
ATLAS_MIPMAP_NEAREST_LINEAR,
|
ATLAS_MIPMAP_NEAREST_LINEAR,
|
||||||
ATLAS_MIPMAP_LINEAR_LINEAR
|
ATLAS_MIPMAP_LINEAR_LINEAR
|
||||||
} AtlasFilter;
|
} spAtlasFilter;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ATLAS_MIRROREDREPEAT, ATLAS_CLAMPTOEDGE, ATLAS_REPEAT
|
ATLAS_MIRROREDREPEAT, ATLAS_CLAMPTOEDGE, ATLAS_REPEAT
|
||||||
} AtlasWrap;
|
} spAtlasWrap;
|
||||||
|
|
||||||
typedef struct AtlasPage AtlasPage;
|
typedef struct spAtlasPage spAtlasPage;
|
||||||
struct AtlasPage {
|
struct spAtlasPage {
|
||||||
const char* name;
|
const char* name;
|
||||||
AtlasFormat format;
|
spAtlasFormat format;
|
||||||
AtlasFilter minFilter, magFilter;
|
spAtlasFilter minFilter, magFilter;
|
||||||
AtlasWrap uWrap, vWrap;
|
spAtlasWrap uWrap, vWrap;
|
||||||
|
|
||||||
void* rendererObject;
|
void* rendererObject;
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
AtlasPage* next;
|
spAtlasPage* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
AtlasPage* AtlasPage_create (const char* name);
|
spAtlasPage* spAtlasPage_create (const char* name);
|
||||||
void AtlasPage_dispose (AtlasPage* self);
|
void spAtlasPage_dispose (spAtlasPage* self);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spAtlasFormat AtlasFormat;
|
||||||
|
typedef spAtlasFilter AtlasFilter;
|
||||||
|
typedef spAtlasWrap AtlasWrap;
|
||||||
|
typedef spAtlasPage AtlasPage;
|
||||||
|
#define AtlasPage_create(...) spAtlasPage_create(__VA_ARGS__)
|
||||||
|
#define AtlasPage_dispose(...) spAtlasPage_dispose(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
typedef struct AtlasRegion AtlasRegion;
|
typedef struct spAtlasRegion spAtlasRegion;
|
||||||
struct AtlasRegion {
|
struct spAtlasRegion {
|
||||||
const char* name;
|
const char* name;
|
||||||
int x, y, width, height;
|
int x, y, width, height;
|
||||||
float u, v, u2, v2;
|
float u, v, u2, v2;
|
||||||
@ -87,29 +96,43 @@ struct AtlasRegion {
|
|||||||
int* splits;
|
int* splits;
|
||||||
int* pads;
|
int* pads;
|
||||||
|
|
||||||
AtlasPage* page;
|
spAtlasPage* page;
|
||||||
|
|
||||||
AtlasRegion* next;
|
spAtlasRegion* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
AtlasRegion* AtlasRegion_create ();
|
spAtlasRegion* spAtlasRegion_create ();
|
||||||
void AtlasRegion_dispose (AtlasRegion* self);
|
void spAtlasRegion_dispose (spAtlasRegion* self);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spAtlasRegion AtlasRegion;
|
||||||
|
#define AtlasRegion_create(...) spAtlasRegion_create(__VA_ARGS__)
|
||||||
|
#define AtlasRegion_dispose(...) spAtlasRegion_dispose(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
AtlasPage* pages;
|
spAtlasPage* pages;
|
||||||
AtlasRegion* regions;
|
spAtlasRegion* regions;
|
||||||
} Atlas;
|
} spAtlas;
|
||||||
|
|
||||||
/* Image files referenced in the atlas file will be prefixed with dir. */
|
/* Image files referenced in the atlas file will be prefixed with dir. */
|
||||||
Atlas* Atlas_readAtlas (const char* data, int length, const char* dir);
|
spAtlas* spAtlas_readAtlas (const char* data, int length, const char* dir);
|
||||||
/* Image files referenced in the atlas file will be prefixed with the directory containing the atlas file. */
|
/* Image files referenced in the atlas file will be prefixed with the directory containing the atlas file. */
|
||||||
Atlas* Atlas_readAtlasFile (const char* path);
|
spAtlas* spAtlas_readAtlasFile (const char* path);
|
||||||
void Atlas_dispose (Atlas* atlas);
|
void spAtlas_dispose (spAtlas* atlas);
|
||||||
|
|
||||||
/* Returns 0 if the region was not found. */
|
/* Returns 0 if the region was not found. */
|
||||||
AtlasRegion* Atlas_findRegion (const Atlas* self, const char* name);
|
spAtlasRegion* spAtlas_findRegion (const spAtlas* self, const char* name);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spAtlas Atlas;
|
||||||
|
#define Atlas_readAtlas(...) spAtlas_readAtlas(__VA_ARGS__)
|
||||||
|
#define Atlas_readAtlasFile(...) spAtlas_readAtlasFile(__VA_ARGS__)
|
||||||
|
#define Atlas_dispose(...) spAtlas_dispose(__VA_ARGS__)
|
||||||
|
#define Atlas_findRegion(...) spAtlas_findRegion(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,11 +42,16 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
AttachmentLoader super;
|
spAttachmentLoader super;
|
||||||
Atlas* atlas;
|
spAtlas* atlas;
|
||||||
} AtlasAttachmentLoader;
|
} spAtlasAttachmentLoader;
|
||||||
|
|
||||||
AtlasAttachmentLoader* AtlasAttachmentLoader_create (Atlas* atlas);
|
spAtlasAttachmentLoader* spAtlasAttachmentLoader_create (spAtlas* atlas);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spAtlasAttachmentLoader AtlasAttachmentLoader;
|
||||||
|
#define AtlasAttachmentLoader_create(...) spAtlasAttachmentLoader_create(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,21 +38,27 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct Slot;
|
struct spSlot;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ATTACHMENT_REGION, ATTACHMENT_REGION_SEQUENCE, ATTACHMENT_BOUNDING_BOX
|
ATTACHMENT_REGION, ATTACHMENT_REGION_SEQUENCE, ATTACHMENT_BOUNDING_BOX
|
||||||
} AttachmentType;
|
} spAttachmentType;
|
||||||
|
|
||||||
typedef struct Attachment Attachment;
|
typedef struct spAttachment spAttachment;
|
||||||
struct Attachment {
|
struct spAttachment {
|
||||||
const char* const name;
|
const char* const name;
|
||||||
AttachmentType type;
|
spAttachmentType type;
|
||||||
|
|
||||||
const void* const vtable;
|
const void* const vtable;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Attachment_dispose (Attachment* self);
|
void spAttachment_dispose (spAttachment* self);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spAttachmentType AttachmentType;
|
||||||
|
typedef spAttachment Attachment;
|
||||||
|
#define Attachment_dispose(...) spAttachment_dispose(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,21 +41,31 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct AttachmentLoader AttachmentLoader;
|
typedef struct spAttachmentLoader spAttachmentLoader;
|
||||||
struct AttachmentLoader {
|
struct spAttachmentLoader {
|
||||||
const char* error1;
|
const char* error1;
|
||||||
const char* error2;
|
const char* error2;
|
||||||
|
|
||||||
const void* const vtable;
|
const void* const vtable;
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
AttachmentLoader () : error1(0), error2(0), vtable(0) {}
|
spAttachmentLoader () :
|
||||||
|
error1(0),
|
||||||
|
error2(0),
|
||||||
|
vtable(0) {
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
void AttachmentLoader_dispose (AttachmentLoader* self);
|
void spAttachmentLoader_dispose (spAttachmentLoader* self);
|
||||||
|
|
||||||
/* Returns 0 to not load an attachment. If 0 is returned and AttachmentLoader.error1 is set, an error occurred. */
|
/* Returns 0 to not load an attachment. If 0 is returned and spAttachmentLoader.error1 is set, an error occurred. */
|
||||||
Attachment* AttachmentLoader_newAttachment (AttachmentLoader* self, Skin* skin, AttachmentType type, const char* name);
|
spAttachment* spAttachmentLoader_newAttachment (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spAttachmentLoader AttachmentLoader;
|
||||||
|
#define AttachmentLoader_dispose(...) spAttachmentLoader_dispose(__VA_ARGS__)
|
||||||
|
#define AttachmentLoader_newAttachment(...) spAttachmentLoader_newAttachment(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,10 +40,10 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct Bone Bone;
|
typedef struct spBone spBone;
|
||||||
struct Bone {
|
struct spBone {
|
||||||
BoneData* const data;
|
spBoneData* const data;
|
||||||
Bone* const parent;
|
spBone* const parent;
|
||||||
float x, y;
|
float x, y;
|
||||||
float rotation;
|
float rotation;
|
||||||
float scaleX, scaleY;
|
float scaleX, scaleY;
|
||||||
@ -54,15 +54,24 @@ struct Bone {
|
|||||||
float const worldScaleX, worldScaleY;
|
float const worldScaleX, worldScaleY;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Bone_setYDown (int/*bool*/yDown);
|
void spBone_setYDown (int/*bool*/yDown);
|
||||||
|
|
||||||
/* @param parent May be 0. */
|
/* @param parent May be 0. */
|
||||||
Bone* Bone_create (BoneData* data, Bone* parent);
|
spBone* spBone_create (spBoneData* data, spBone* parent);
|
||||||
void Bone_dispose (Bone* self);
|
void spBone_dispose (spBone* self);
|
||||||
|
|
||||||
void Bone_setToSetupPose (Bone* self);
|
void spBone_setToSetupPose (spBone* self);
|
||||||
|
|
||||||
void Bone_updateWorldTransform (Bone* self, int/*bool*/flipX, int/*bool*/flipY);
|
void spBone_updateWorldTransform (spBone* self, int/*bool*/flipX, int/*bool*/flipY);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spBone Bone;
|
||||||
|
#define Bone_setYDown(...) spBone_setYDown(__VA_ARGS__)
|
||||||
|
#define Bone_create(...) spBone_create(__VA_ARGS__)
|
||||||
|
#define Bone_dispose(...) spBone_dispose(__VA_ARGS__)
|
||||||
|
#define Bone_setToSetupPose(...) spBone_setToSetupPose(__VA_ARGS__)
|
||||||
|
#define Bone_updateWorldTransform(...) spBone_updateWorldTransform(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,10 +38,10 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct BoneData BoneData;
|
typedef struct spBoneData spBoneData;
|
||||||
struct BoneData {
|
struct spBoneData {
|
||||||
const char* const name;
|
const char* const name;
|
||||||
BoneData* const parent;
|
spBoneData* const parent;
|
||||||
float length;
|
float length;
|
||||||
float x, y;
|
float x, y;
|
||||||
float rotation;
|
float rotation;
|
||||||
@ -49,8 +49,14 @@ struct BoneData {
|
|||||||
int/*bool*/inheritScale, inheritRotation;
|
int/*bool*/inheritScale, inheritRotation;
|
||||||
};
|
};
|
||||||
|
|
||||||
BoneData* BoneData_create (const char* name, BoneData* parent);
|
spBoneData* spBoneData_create (const char* name, spBoneData* parent);
|
||||||
void BoneData_dispose (BoneData* self);
|
void spBoneData_dispose (spBoneData* self);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spBoneData BoneData;
|
||||||
|
#define BoneData_create(...) spBoneData_create(__VA_ARGS__)
|
||||||
|
#define BoneData_dispose(...) spBoneData_dispose(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,15 +42,21 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct BoundingBoxAttachment BoundingBoxAttachment;
|
typedef struct spBoundingBoxAttachment spBoundingBoxAttachment;
|
||||||
struct BoundingBoxAttachment {
|
struct spBoundingBoxAttachment {
|
||||||
Attachment super;
|
spAttachment super;
|
||||||
int verticesCount;
|
int verticesCount;
|
||||||
float* vertices;
|
float* vertices;
|
||||||
};
|
};
|
||||||
|
|
||||||
BoundingBoxAttachment* BoundingBoxAttachment_create (const char* name);
|
spBoundingBoxAttachment* spBoundingBoxAttachment_create (const char* name);
|
||||||
void BoundingBoxAttachment_computeWorldVertices (BoundingBoxAttachment* self, float x, float y, Bone* bone, float* vertices);
|
void spBoundingBoxAttachment_computeWorldVertices (spBoundingBoxAttachment* self, float x, float y, spBone* bone, float* vertices);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spBoundingBoxAttachment BoundingBoxAttachment;
|
||||||
|
#define BoundingBoxAttachment_create(...) spBoundingBoxAttachment_create(__VA_ARGS__)
|
||||||
|
#define BoundingBoxAttachment_computeWorldVertices(...) spBoundingBoxAttachment_computeWorldVertices(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,16 +40,22 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct Event Event;
|
typedef struct spEvent spEvent;
|
||||||
struct Event {
|
struct spEvent {
|
||||||
EventData* const data;
|
spEventData* const data;
|
||||||
int intValue;
|
int intValue;
|
||||||
float floatValue;
|
float floatValue;
|
||||||
const char* stringValue;
|
const char* stringValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
Event* Event_create (EventData* data);
|
spEvent* spEvent_create (spEventData* data);
|
||||||
void Event_dispose (Event* self);
|
void spEvent_dispose (spEvent* self);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spEvent Event;
|
||||||
|
#define Event_create(...) spEvent_create(__VA_ARGS__)
|
||||||
|
#define Event_dispose(...) spEvent_dispose(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,16 +38,22 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct EventData EventData;
|
typedef struct spEventData spEventData;
|
||||||
struct EventData {
|
struct spEventData {
|
||||||
const char* const name;
|
const char* const name;
|
||||||
int intValue;
|
int intValue;
|
||||||
float floatValue;
|
float floatValue;
|
||||||
const char* stringValue;
|
const char* stringValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
EventData* EventData_create (const char* name);
|
spEventData* spEventData_create (const char* name);
|
||||||
void EventData_dispose (EventData* self);
|
void spEventData_dispose (spEventData* self);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spEventData EventData;
|
||||||
|
#define EventData_create(...) spEventData_create(__VA_ARGS__)
|
||||||
|
#define EventData_dispose(...) spEventData_dispose(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,11 +44,11 @@ extern "C" {
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
VERTEX_X1 = 0, VERTEX_Y1, VERTEX_X2, VERTEX_Y2, VERTEX_X3, VERTEX_Y3, VERTEX_X4, VERTEX_Y4
|
VERTEX_X1 = 0, VERTEX_Y1, VERTEX_X2, VERTEX_Y2, VERTEX_X3, VERTEX_Y3, VERTEX_X4, VERTEX_Y4
|
||||||
} VertexIndex;
|
} spVertexIndex;
|
||||||
|
|
||||||
typedef struct RegionAttachment RegionAttachment;
|
typedef struct spRegionAttachment spRegionAttachment;
|
||||||
struct RegionAttachment {
|
struct spRegionAttachment {
|
||||||
Attachment super;
|
spAttachment super;
|
||||||
float x, y, scaleX, scaleY, rotation, width, height;
|
float x, y, scaleX, scaleY, rotation, width, height;
|
||||||
|
|
||||||
void* rendererObject;
|
void* rendererObject;
|
||||||
@ -60,10 +60,19 @@ struct RegionAttachment {
|
|||||||
float uvs[8];
|
float uvs[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
RegionAttachment* RegionAttachment_create (const char* name);
|
spRegionAttachment* spRegionAttachment_create (const char* name);
|
||||||
void RegionAttachment_setUVs (RegionAttachment* self, float u, float v, float u2, float v2, int/*bool*/rotate);
|
void spRegionAttachment_setUVs (spRegionAttachment* self, float u, float v, float u2, float v2, int/*bool*/rotate);
|
||||||
void RegionAttachment_updateOffset (RegionAttachment* self);
|
void spRegionAttachment_updateOffset (spRegionAttachment* self);
|
||||||
void RegionAttachment_computeWorldVertices (RegionAttachment* self, float x, float y, Bone* bone, float* vertices);
|
void spRegionAttachment_computeWorldVertices (spRegionAttachment* self, float x, float y, spBone* bone, float* vertices);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spVertexIndex VertexIndex;
|
||||||
|
typedef spRegionAttachment RegionAttachment;
|
||||||
|
#define RegionAttachment_create(...) spRegionAttachment_create(__VA_ARGS__)
|
||||||
|
#define RegionAttachment_setUVs(...) spRegionAttachment_setUVs(__VA_ARGS__)
|
||||||
|
#define RegionAttachment_updateOffset(...) spRegionAttachment_updateOffset(__VA_ARGS__)
|
||||||
|
#define RegionAttachment_computeWorldVertices(...) spRegionAttachment_computeWorldVertices(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,60 +42,80 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct Skeleton Skeleton;
|
typedef struct spSkeleton spSkeleton;
|
||||||
struct Skeleton {
|
struct spSkeleton {
|
||||||
SkeletonData* const data;
|
spSkeletonData* const data;
|
||||||
|
|
||||||
int boneCount;
|
int boneCount;
|
||||||
Bone** bones;
|
spBone** bones;
|
||||||
Bone* const root;
|
spBone* const root;
|
||||||
|
|
||||||
int slotCount;
|
int slotCount;
|
||||||
Slot** slots;
|
spSlot** slots;
|
||||||
Slot** drawOrder;
|
spSlot** drawOrder;
|
||||||
|
|
||||||
Skin* const skin;
|
spSkin* const skin;
|
||||||
float r, g, b, a;
|
float r, g, b, a;
|
||||||
float time;
|
float time;
|
||||||
int/*bool*/flipX, flipY;
|
int/*bool*/flipX, flipY;
|
||||||
float x, y;
|
float x, y;
|
||||||
};
|
};
|
||||||
|
|
||||||
Skeleton* Skeleton_create (SkeletonData* data);
|
spSkeleton* spSkeleton_create (spSkeletonData* data);
|
||||||
void Skeleton_dispose (Skeleton* self);
|
void spSkeleton_dispose (spSkeleton* self);
|
||||||
|
|
||||||
void Skeleton_updateWorldTransform (const Skeleton* self);
|
void spSkeleton_updateWorldTransform (const spSkeleton* self);
|
||||||
|
|
||||||
void Skeleton_setToSetupPose (const Skeleton* self);
|
void spSkeleton_setToSetupPose (const spSkeleton* self);
|
||||||
void Skeleton_setBonesToSetupPose (const Skeleton* self);
|
void spSkeleton_setBonesToSetupPose (const spSkeleton* self);
|
||||||
void Skeleton_setSlotsToSetupPose (const Skeleton* self);
|
void spSkeleton_setSlotsToSetupPose (const spSkeleton* self);
|
||||||
|
|
||||||
/* Returns 0 if the bone was not found. */
|
/* Returns 0 if the bone was not found. */
|
||||||
Bone* Skeleton_findBone (const Skeleton* self, const char* boneName);
|
spBone* spSkeleton_findBone (const spSkeleton* self, const char* boneName);
|
||||||
/* Returns -1 if the bone was not found. */
|
/* Returns -1 if the bone was not found. */
|
||||||
int Skeleton_findBoneIndex (const Skeleton* self, const char* boneName);
|
int spSkeleton_findBoneIndex (const spSkeleton* self, const char* boneName);
|
||||||
|
|
||||||
/* Returns 0 if the slot was not found. */
|
/* Returns 0 if the slot was not found. */
|
||||||
Slot* Skeleton_findSlot (const Skeleton* self, const char* slotName);
|
spSlot* spSkeleton_findSlot (const spSkeleton* self, const char* slotName);
|
||||||
/* Returns -1 if the slot was not found. */
|
/* Returns -1 if the slot was not found. */
|
||||||
int Skeleton_findSlotIndex (const Skeleton* self, const char* slotName);
|
int spSkeleton_findSlotIndex (const spSkeleton* self, const char* slotName);
|
||||||
|
|
||||||
/* Sets the skin used to look up attachments not found in the SkeletonData defaultSkin. Attachments from the new skin are
|
/* Sets the skin used to look up attachments not found in the SkeletonData defaultSkin. Attachments from the new skin are
|
||||||
* attached if the corresponding attachment from the old skin was attached.
|
* attached if the corresponding attachment from the old skin was attached.
|
||||||
* @param skin May be 0.*/
|
* @param skin May be 0.*/
|
||||||
void Skeleton_setSkin (Skeleton* self, Skin* skin);
|
void spSkeleton_setSkin (spSkeleton* self, spSkin* skin);
|
||||||
/* Returns 0 if the skin was not found. See Skeleton_setSkin.
|
/* Returns 0 if the skin was not found. See spSkeleton_setSkin.
|
||||||
* @param skinName May be 0. */
|
* @param skinName May be 0. */
|
||||||
int Skeleton_setSkinByName (Skeleton* self, const char* skinName);
|
int spSkeleton_setSkinByName (spSkeleton* self, const char* skinName);
|
||||||
|
|
||||||
/* Returns 0 if the slot or attachment was not found. */
|
/* Returns 0 if the slot or attachment was not found. */
|
||||||
Attachment* Skeleton_getAttachmentForSlotName (const Skeleton* self, const char* slotName, const char* attachmentName);
|
spAttachment* spSkeleton_getAttachmentForSlotName (const spSkeleton* self, const char* slotName, const char* attachmentName);
|
||||||
/* Returns 0 if the slot or attachment was not found. */
|
/* Returns 0 if the slot or attachment was not found. */
|
||||||
Attachment* Skeleton_getAttachmentForSlotIndex (const Skeleton* self, int slotIndex, const char* attachmentName);
|
spAttachment* spSkeleton_getAttachmentForSlotIndex (const spSkeleton* self, int slotIndex, const char* attachmentName);
|
||||||
/* Returns 0 if the slot or attachment was not found. */
|
/* Returns 0 if the slot or attachment was not found. */
|
||||||
int Skeleton_setAttachment (Skeleton* self, const char* slotName, const char* attachmentName);
|
int spSkeleton_setAttachment (spSkeleton* self, const char* slotName, const char* attachmentName);
|
||||||
|
|
||||||
void Skeleton_update (Skeleton* self, float deltaTime);
|
void spSkeleton_update (spSkeleton* self, float deltaTime);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spSkeleton Skeleton;
|
||||||
|
#define Skeleton_create(...) spSkeleton_create(__VA_ARGS__)
|
||||||
|
#define Skeleton_dispose(...) spSkeleton_dispose(__VA_ARGS__)
|
||||||
|
#define Skeleton_updateWorldTransform(...) spSkeleton_updateWorldTransform(__VA_ARGS__)
|
||||||
|
#define Skeleton_setToSetupPose(...) spSkeleton_setToSetupPose(__VA_ARGS__)
|
||||||
|
#define Skeleton_setBonesToSetupPose(...) spSkeleton_setBonesToSetupPose(__VA_ARGS__)
|
||||||
|
#define Skeleton_setSlotsToSetupPose(...) spSkeleton_setSlotsToSetupPose(__VA_ARGS__)
|
||||||
|
#define Skeleton_findBone(...) spSkeleton_findBone(__VA_ARGS__)
|
||||||
|
#define Skeleton_findBoneIndex(...) spSkeleton_findBoneIndex(__VA_ARGS__)
|
||||||
|
#define Skeleton_findSlot(...) spSkeleton_findSlot(__VA_ARGS__)
|
||||||
|
#define Skeleton_findSlotIndex(...) spSkeleton_findSlotIndex(__VA_ARGS__)
|
||||||
|
#define Skeleton_setSkin(...) spSkeleton_setSkin(__VA_ARGS__)
|
||||||
|
#define Skeleton_setSkinByName(...) spSkeleton_setSkinByName(__VA_ARGS__)
|
||||||
|
#define Skeleton_getAttachmentForSlotName(...) spSkeleton_getAttachmentForSlotName(__VA_ARGS__)
|
||||||
|
#define Skeleton_getAttachmentForSlotIndex(...) spSkeleton_getAttachmentForSlotIndex(__VA_ARGS__)
|
||||||
|
#define Skeleton_setAttachment(...) spSkeleton_setAttachment(__VA_ARGS__)
|
||||||
|
#define Skeleton_update(...) spSkeleton_update(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,47 +45,68 @@ typedef struct {
|
|||||||
float* const vertices;
|
float* const vertices;
|
||||||
int count;
|
int count;
|
||||||
int capacity;
|
int capacity;
|
||||||
} BoundingPolygon;
|
} spBoundingPolygon;
|
||||||
|
|
||||||
BoundingPolygon* BoundingPolygon_create (int capacity);
|
spBoundingPolygon* spBoundingPolygon_create (int capacity);
|
||||||
void BoundingPolygon_dispose (BoundingPolygon* self);
|
void spBoundingPolygon_dispose (spBoundingPolygon* self);
|
||||||
|
|
||||||
int/*bool*/BoundingPolygon_containsPoint (BoundingPolygon* polygon, float x, float y);
|
int/*bool*/spBoundingPolygon_containsPoint (spBoundingPolygon* polygon, float x, float y);
|
||||||
int/*bool*/BoundingPolygon_intersectsSegment (BoundingPolygon* polygon, float x1, float y1, float x2, float y2);
|
int/*bool*/spBoundingPolygon_intersectsSegment (spBoundingPolygon* polygon, float x1, float y1, float x2, float y2);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spBoundingPolygon BoundingPolygon;
|
||||||
|
#define BoundingPolygon_create(...) spBoundingPolygon_create(__VA_ARGS__)
|
||||||
|
#define BoundingPolygon_dispose(...) spBoundingPolygon_dispose(__VA_ARGS__)
|
||||||
|
#define BoundingPolygon_containsPoint(...) spBoundingPolygon_containsPoint(__VA_ARGS__)
|
||||||
|
#define BoundingPolygon_intersectsSegment(...) spBoundingPolygon_intersectsSegment(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int count;
|
int count;
|
||||||
BoundingBoxAttachment** boundingBoxes;
|
spBoundingBoxAttachment** boundingBoxes;
|
||||||
BoundingPolygon** polygons;
|
spBoundingPolygon** polygons;
|
||||||
|
|
||||||
float minX, minY, maxX, maxY;
|
float minX, minY, maxX, maxY;
|
||||||
} SkeletonBounds;
|
} spSkeletonBounds;
|
||||||
|
|
||||||
SkeletonBounds* SkeletonBounds_create ();
|
spSkeletonBounds* spSkeletonBounds_create ();
|
||||||
void SkeletonBounds_dispose (SkeletonBounds* self);
|
void spSkeletonBounds_dispose (spSkeletonBounds* self);
|
||||||
void SkeletonBounds_update (SkeletonBounds* self, Skeleton* skeleton, int/*bool*/updateAabb);
|
void spSkeletonBounds_update (spSkeletonBounds* self, spSkeleton* skeleton, int/*bool*/updateAabb);
|
||||||
|
|
||||||
/** Returns true if the axis aligned bounding box contains the point. */
|
/** Returns true if the axis aligned bounding box contains the point. */
|
||||||
int/*bool*/SkeletonBounds_aabbContainsPoint (SkeletonBounds* self, float x, float y);
|
int/*bool*/spSkeletonBounds_aabbContainsPoint (spSkeletonBounds* self, float x, float y);
|
||||||
|
|
||||||
/** Returns true if the axis aligned bounding box intersects the line segment. */
|
/** Returns true if the axis aligned bounding box intersects the line segment. */
|
||||||
int/*bool*/SkeletonBounds_aabbIntersectsSegment (SkeletonBounds* self, float x1, float y1, float x2, float y2);
|
int/*bool*/spSkeletonBounds_aabbIntersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2);
|
||||||
|
|
||||||
/** Returns true if the axis aligned bounding box intersects the axis aligned bounding box of the specified bounds. */
|
/** Returns true if the axis aligned bounding box intersects the axis aligned bounding box of the specified bounds. */
|
||||||
int/*bool*/SkeletonBounds_aabbIntersectsSkeleton (SkeletonBounds* self, SkeletonBounds* bounds);
|
int/*bool*/spSkeletonBounds_aabbIntersectsSkeleton (spSkeletonBounds* self, spSkeletonBounds* bounds);
|
||||||
|
|
||||||
/** Returns the first bounding box attachment that contains the point, or null. When doing many checks, it is usually more
|
/** Returns the first bounding box attachment that contains the point, or null. When doing many checks, it is usually more
|
||||||
* efficient to only call this method if SkeletonBounds_aabbContainsPoint returns true. */
|
* efficient to only call this method if spSkeletonBounds_aabbContainsPoint returns true. */
|
||||||
BoundingBoxAttachment* SkeletonBounds_containsPoint (SkeletonBounds* self, float x, float y);
|
spBoundingBoxAttachment* spSkeletonBounds_containsPoint (spSkeletonBounds* self, float x, float y);
|
||||||
|
|
||||||
/** Returns the first bounding box attachment that contains the line segment, or null. When doing many checks, it is usually
|
/** Returns the first bounding box attachment that contains the line segment, or null. When doing many checks, it is usually
|
||||||
* more efficient to only call this method if SkeletonBounds_aabbIntersectsSegment returns true. */
|
* more efficient to only call this method if spSkeletonBounds_aabbIntersectsSegment returns true. */
|
||||||
BoundingBoxAttachment* SkeletonBounds_intersectsSegment (SkeletonBounds* self, float x1, float y1, float x2, float y2);
|
spBoundingBoxAttachment* spSkeletonBounds_intersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2);
|
||||||
|
|
||||||
/** Returns the polygon for the specified bounding box, or null. */
|
/** Returns the polygon for the specified bounding box, or null. */
|
||||||
BoundingPolygon* SkeletonBounds_getPolygon (SkeletonBounds* self, BoundingBoxAttachment* boundingBox);
|
spBoundingPolygon* spSkeletonBounds_getPolygon (spSkeletonBounds* self, spBoundingBoxAttachment* boundingBox);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spSkeletonBounds SkeletonBounds;
|
||||||
|
#define SkeletonBounds_create(...) spSkeletonBounds_create(__VA_ARGS__)
|
||||||
|
#define SkeletonBounds_dispose(...) spSkeletonBounds_dispose(__VA_ARGS__)
|
||||||
|
#define SkeletonBounds_update(...) spSkeletonBounds_update(__VA_ARGS__)
|
||||||
|
#define SkeletonBounds_aabbContainsPoint(...) spSkeletonBounds_aabbContainsPoint(__VA_ARGS__)
|
||||||
|
#define SkeletonBounds_aabbIntersectsSegment(...) spSkeletonBounds_aabbIntersectsSegment(__VA_ARGS__)
|
||||||
|
#define SkeletonBounds_aabbIntersectsSkeleton(...) spSkeletonBounds_aabbIntersectsSkeleton(__VA_ARGS__)
|
||||||
|
#define SkeletonBounds_containsPoint(...) spSkeletonBounds_containsPoint(__VA_ARGS__)
|
||||||
|
#define SkeletonBounds_intersectsSegment(...) spSkeletonBounds_intersectsSegment(__VA_ARGS__)
|
||||||
|
#define SkeletonBounds_getPolygon(...) spSkeletonBounds_getPolygon(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,36 +46,49 @@ extern "C" {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int boneCount;
|
int boneCount;
|
||||||
BoneData** bones;
|
spBoneData** bones;
|
||||||
|
|
||||||
int slotCount;
|
int slotCount;
|
||||||
SlotData** slots;
|
spSlotData** slots;
|
||||||
|
|
||||||
int skinCount;
|
int skinCount;
|
||||||
Skin** skins;
|
spSkin** skins;
|
||||||
Skin* defaultSkin;
|
spSkin* defaultSkin;
|
||||||
|
|
||||||
int eventCount;
|
int eventCount;
|
||||||
EventData** events;
|
spEventData** events;
|
||||||
|
|
||||||
int animationCount;
|
int animationCount;
|
||||||
Animation** animations;
|
spAnimation** animations;
|
||||||
} SkeletonData;
|
} spSkeletonData;
|
||||||
|
|
||||||
SkeletonData* SkeletonData_create ();
|
spSkeletonData* spSkeletonData_create ();
|
||||||
void SkeletonData_dispose (SkeletonData* self);
|
void spSkeletonData_dispose (spSkeletonData* self);
|
||||||
|
|
||||||
BoneData* SkeletonData_findBone (const SkeletonData* self, const char* boneName);
|
spBoneData* spSkeletonData_findBone (const spSkeletonData* self, const char* boneName);
|
||||||
int SkeletonData_findBoneIndex (const SkeletonData* self, const char* boneName);
|
int spSkeletonData_findBoneIndex (const spSkeletonData* self, const char* boneName);
|
||||||
|
|
||||||
SlotData* SkeletonData_findSlot (const SkeletonData* self, const char* slotName);
|
spSlotData* spSkeletonData_findSlot (const spSkeletonData* self, const char* slotName);
|
||||||
int SkeletonData_findSlotIndex (const SkeletonData* self, const char* slotName);
|
int spSkeletonData_findSlotIndex (const spSkeletonData* self, const char* slotName);
|
||||||
|
|
||||||
Skin* SkeletonData_findSkin (const SkeletonData* self, const char* skinName);
|
spSkin* spSkeletonData_findSkin (const spSkeletonData* self, const char* skinName);
|
||||||
|
|
||||||
EventData* SkeletonData_findEvent (const SkeletonData* self, const char* eventName);
|
spEventData* spSkeletonData_findEvent (const spSkeletonData* self, const char* eventName);
|
||||||
|
|
||||||
Animation* SkeletonData_findAnimation (const SkeletonData* self, const char* animationName);
|
spAnimation* spSkeletonData_findAnimation (const spSkeletonData* self, const char* animationName);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spSkeletonData SkeletonData;
|
||||||
|
#define SkeletonData_create(...) spSkeletonData_create(__VA_ARGS__)
|
||||||
|
#define SkeletonData_dispose(...) spSkeletonData_dispose(__VA_ARGS__)
|
||||||
|
#define SkeletonData_findBone(...) spSkeletonData_findBone(__VA_ARGS__)
|
||||||
|
#define SkeletonData_findBoneIndex(...) spSkeletonData_findBoneIndex(__VA_ARGS__)
|
||||||
|
#define SkeletonData_findSlot(...) spSkeletonData_findSlot(__VA_ARGS__)
|
||||||
|
#define SkeletonData_findSlotIndex(...) spSkeletonData_findSlotIndex(__VA_ARGS__)
|
||||||
|
#define SkeletonData_findSkin(...) spSkeletonData_findSkin(__VA_ARGS__)
|
||||||
|
#define SkeletonData_findEvent(...) spSkeletonData_findEvent(__VA_ARGS__)
|
||||||
|
#define SkeletonData_findAnimation(...) spSkeletonData_findAnimation(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,16 +46,25 @@ extern "C" {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float scale;
|
float scale;
|
||||||
AttachmentLoader* attachmentLoader;
|
spAttachmentLoader* attachmentLoader;
|
||||||
const char* const error;
|
const char* const error;
|
||||||
} SkeletonJson;
|
} spSkeletonJson;
|
||||||
|
|
||||||
SkeletonJson* SkeletonJson_createWithLoader (AttachmentLoader* attachmentLoader);
|
spSkeletonJson* spSkeletonJson_createWithLoader (spAttachmentLoader* attachmentLoader);
|
||||||
SkeletonJson* SkeletonJson_create (Atlas* atlas);
|
spSkeletonJson* spSkeletonJson_create (spAtlas* atlas);
|
||||||
void SkeletonJson_dispose (SkeletonJson* self);
|
void spSkeletonJson_dispose (spSkeletonJson* self);
|
||||||
|
|
||||||
SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* json);
|
spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const char* json);
|
||||||
SkeletonData* SkeletonJson_readSkeletonDataFile (SkeletonJson* self, const char* path);
|
spSkeletonData* spSkeletonJson_readSkeletonDataFile (spSkeletonJson* self, const char* path);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spSkeletonJson SkeletonJson;
|
||||||
|
#define SkeletonJson_createWithLoader(...) spSkeletonJson_createWithLoader(__VA_ARGS__)
|
||||||
|
#define SkeletonJson_create(...) spSkeletonJson_create(__VA_ARGS__)
|
||||||
|
#define SkeletonJson_dispose(...) spSkeletonJson_dispose(__VA_ARGS__)
|
||||||
|
#define SkeletonJson_readSkeletonData(...) spSkeletonJson_readSkeletonData(__VA_ARGS__)
|
||||||
|
#define SkeletonJson_readSkeletonDataFile(...) spSkeletonJson_readSkeletonDataFile(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,25 +40,35 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct Skeleton;
|
struct spSkeleton;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char* const name;
|
const char* const name;
|
||||||
} Skin;
|
} spSkin;
|
||||||
|
|
||||||
Skin* Skin_create (const char* name);
|
spSkin* spSkin_create (const char* name);
|
||||||
void Skin_dispose (Skin* self);
|
void spSkin_dispose (spSkin* self);
|
||||||
|
|
||||||
/* The Skin owns the attachment. */
|
/* The Skin owns the attachment. */
|
||||||
void Skin_addAttachment (Skin* self, int slotIndex, const char* name, Attachment* attachment);
|
void spSkin_addAttachment (spSkin* self, int slotIndex, const char* name, spAttachment* attachment);
|
||||||
/* Returns 0 if the attachment was not found. */
|
/* Returns 0 if the attachment was not found. */
|
||||||
Attachment* Skin_getAttachment (const Skin* self, int slotIndex, const char* name);
|
spAttachment* spSkin_getAttachment (const spSkin* self, int slotIndex, const char* name);
|
||||||
|
|
||||||
/* Returns 0 if the slot or attachment was not found. */
|
/* Returns 0 if the slot or attachment was not found. */
|
||||||
const char* Skin_getAttachmentName (const Skin* self, int slotIndex, int attachmentIndex);
|
const char* spSkin_getAttachmentName (const spSkin* self, int slotIndex, int attachmentIndex);
|
||||||
|
|
||||||
/** Attach each attachment in this skin if the corresponding attachment in oldSkin is currently attached. */
|
/** Attach each attachment in this skin if the corresponding attachment in oldSkin is currently attached. */
|
||||||
void Skin_attachAll (const Skin* self, struct Skeleton* skeleton, const Skin* oldSkin);
|
void spSkin_attachAll (const spSkin* self, struct spSkeleton* skeleton, const spSkin* oldspSkin);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spSkin Skin;
|
||||||
|
#define Skin_create(...) spSkin_create(__VA_ARGS__)
|
||||||
|
#define Skin_dispose(...) spSkin_dispose(__VA_ARGS__)
|
||||||
|
#define Skin_addAttachment(...) spSkin_addAttachment(__VA_ARGS__)
|
||||||
|
#define Skin_getAttachment(...) spSkin_getAttachment(__VA_ARGS__)
|
||||||
|
#define Skin_getAttachmentName(...) spSkin_getAttachmentName(__VA_ARGS__)
|
||||||
|
#define Skin_attachAll(...) spSkin_attachAll(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,26 +42,36 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct Skeleton;
|
struct spSkeleton;
|
||||||
|
|
||||||
typedef struct Slot {
|
typedef struct spSlot {
|
||||||
SlotData* const data;
|
spSlotData* const data;
|
||||||
struct Skeleton* const skeleton;
|
struct spSkeleton* const skeleton;
|
||||||
Bone* const bone;
|
spBone* const bone;
|
||||||
float r, g, b, a;
|
float r, g, b, a;
|
||||||
Attachment* const attachment;
|
spAttachment* const attachment;
|
||||||
} Slot;
|
} spSlot;
|
||||||
|
|
||||||
Slot* Slot_create (SlotData* data, struct Skeleton* skeleton, Bone* bone);
|
spSlot* spSlot_create (spSlotData* data, struct spSkeleton* skeleton, spBone* bone);
|
||||||
void Slot_dispose (Slot* self);
|
void spSlot_dispose (spSlot* self);
|
||||||
|
|
||||||
/* @param attachment May be 0 to clear the attachment for the slot. */
|
/* @param attachment May be 0 to clear the attachment for the slot. */
|
||||||
void Slot_setAttachment (Slot* self, Attachment* attachment);
|
void spSlot_setAttachment (spSlot* self, spAttachment* attachment);
|
||||||
|
|
||||||
void Slot_setAttachmentTime (Slot* self, float time);
|
void spSlot_setAttachmentTime (spSlot* self, float time);
|
||||||
float Slot_getAttachmentTime (const Slot* self);
|
float spSlot_getAttachmentTime (const spSlot* self);
|
||||||
|
|
||||||
void Slot_setToSetupPose (Slot* self);
|
void spSlot_setToSetupPose (spSlot* self);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spSlot Slot;
|
||||||
|
#define Slot_create(...) spSlot_create(__VA_ARGS__)
|
||||||
|
#define Slot_dispose(...) spSlot_dispose(__VA_ARGS__)
|
||||||
|
#define Slot_setAttachment(...) spSlot_setAttachment(__VA_ARGS__)
|
||||||
|
#define Slot_setAttachmentTime(...) spSlot_setAttachmentTime(__VA_ARGS__)
|
||||||
|
#define Slot_getAttachmentTime(...) spSlot_getAttachmentTime(__VA_ARGS__)
|
||||||
|
#define Slot_setToSetupPose(...) spSlot_setToSetupPose(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,17 +42,24 @@ extern "C" {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char* const name;
|
const char* const name;
|
||||||
const BoneData* const boneData;
|
const spBoneData* const boneData;
|
||||||
const char* const attachmentName;
|
const char* const attachmentName;
|
||||||
float r, g, b, a;
|
float r, g, b, a;
|
||||||
int/*bool*/additiveBlending;
|
int/*bool*/additiveBlending;
|
||||||
} SlotData;
|
} spSlotData;
|
||||||
|
|
||||||
SlotData* SlotData_create (const char* name, BoneData* boneData);
|
spSlotData* spSlotData_create (const char* name, spBoneData* boneData);
|
||||||
void SlotData_dispose (SlotData* self);
|
void spSlotData_dispose (spSlotData* self);
|
||||||
|
|
||||||
/* @param attachmentName May be 0 for no setup pose attachment. */
|
/* @param attachmentName May be 0 for no setup pose attachment. */
|
||||||
void SlotData_setAttachmentName (SlotData* self, const char* attachmentName);
|
void spSlotData_setAttachmentName (spSlotData* self, const char* attachmentName);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
typedef spSlotData SlotData;
|
||||||
|
#define SlotData_create(...) spSlotData_create(__VA_ARGS__)
|
||||||
|
#define SlotData_dispose(...) spSlotData_dispose(__VA_ARGS__)
|
||||||
|
#define SlotData_setAttachmentName(...) spSlotData_setAttachmentName(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Implementation notes:
|
Implementation notes:
|
||||||
|
|
||||||
@ -58,9 +57,9 @@
|
|||||||
#define MALLOC_STR(TO,FROM) strcpy(CONST_CAST(char*, TO) = (char*)malloc(strlen(FROM) + 1), FROM)
|
#define MALLOC_STR(TO,FROM) strcpy(CONST_CAST(char*, TO) = (char*)malloc(strlen(FROM) + 1), FROM)
|
||||||
|
|
||||||
#ifdef __STDC_VERSION__
|
#ifdef __STDC_VERSION__
|
||||||
#define FMOD(A,B) fmodf(A, B)
|
#define FMOD(A,B) fmodf(A, B)
|
||||||
#else
|
#else
|
||||||
#define FMOD(A,B) (float)fmod(A, B)
|
#define FMOD(A,B) (float)fmod(A, B)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -81,9 +80,15 @@ extern "C" {
|
|||||||
* Functions that must be implemented:
|
* Functions that must be implemented:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void _AtlasPage_createTexture (AtlasPage* self, const char* path);
|
void _spAtlasPage_createTexture (spAtlasPage* self, const char* path);
|
||||||
void _AtlasPage_disposeTexture (AtlasPage* self);
|
void _spAtlasPage_disposeTexture (spAtlasPage* self);
|
||||||
char* _Util_readFile (const char* path, int* length);
|
char* _spUtil_readFile (const char* path, int* length);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
#define _AtlasPage_createTexture(...) _spAtlasPage_createTexture(__VA_ARGS__)
|
||||||
|
#define _AtlasPage_disposeTexture(...) _spAtlasPage_disposeTexture(__VA_ARGS__)
|
||||||
|
#define _Util_readFile(...) _spUtil_readFile(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Internal API available for extension:
|
* Internal API available for extension:
|
||||||
@ -100,34 +105,56 @@ char* _readFile (const char* path, int* length);
|
|||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
void _AttachmentLoader_init (AttachmentLoader* self, /**/
|
void _spAttachmentLoader_init (spAttachmentLoader* self, /**/
|
||||||
void (*dispose) (AttachmentLoader* self), /**/
|
void (*dispose) (spAttachmentLoader* self), /**/
|
||||||
Attachment* (*newAttachment) (AttachmentLoader* self, Skin* skin, AttachmentType type, const char* name));
|
spAttachment* (*newAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name));
|
||||||
void _AttachmentLoader_deinit (AttachmentLoader* self);
|
void _spAttachmentLoader_deinit (spAttachmentLoader* self);
|
||||||
void _AttachmentLoader_setError (AttachmentLoader* self, const char* error1, const char* error2);
|
void _spAttachmentLoader_setError (spAttachmentLoader* self, const char* error1, const char* error2);
|
||||||
void _AttachmentLoader_setUnknownTypeError (AttachmentLoader* self, AttachmentType type);
|
void _spAttachmentLoader_setUnknownTypeError (spAttachmentLoader* self, spAttachmentType type);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
#define _AttachmentLoader_init(...) _spAttachmentLoader_init(__VA_ARGS__)
|
||||||
|
#define _AttachmentLoader_deinit(...) _spAttachmentLoader_deinit(__VA_ARGS__)
|
||||||
|
#define _AttachmentLoader_setError(...) _spAttachmentLoader_setError(__VA_ARGS__)
|
||||||
|
#define _AttachmentLoader_setUnknownTypeError(...) _spAttachmentLoader_setUnknownTypeError(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
void _Attachment_init (Attachment* self, const char* name, AttachmentType type, /**/
|
void _spAttachment_init (spAttachment* self, const char* name, spAttachmentType type, /**/
|
||||||
void (*dispose) (Attachment* self));
|
void (*dispose) (spAttachment* self));
|
||||||
void _Attachment_deinit (Attachment* self);
|
void _spAttachment_deinit (spAttachment* self);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
#define _Attachment_init(...) _spAttachment_init(__VA_ARGS__)
|
||||||
|
#define _Attachment_deinit(...) _spAttachment_deinit(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
void _Timeline_init (Timeline* self, /**/
|
void _spTimeline_init (spTimeline* self, /**/
|
||||||
void (*dispose) (Timeline* self), /**/
|
void (*dispose) (spTimeline* self), /**/
|
||||||
void (*apply) (const Timeline* self, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, int* eventCount,
|
void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
float alpha));
|
int* eventCount, float alpha));
|
||||||
void _Timeline_deinit (Timeline* self);
|
void _spTimeline_deinit (spTimeline* self);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
#define _Timeline_init(...) _spTimeline_init(__VA_ARGS__)
|
||||||
|
#define _Timeline_deinit(...) _spTimeline_deinit(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
void _CurveTimeline_init (CurveTimeline* self, int frameCount, /**/
|
void _spCurveTimeline_init (spCurveTimeline* self, int frameCount, /**/
|
||||||
void (*dispose) (Timeline* self), /**/
|
void (*dispose) (spTimeline* self), /**/
|
||||||
void (*apply) (const Timeline* self, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, int* eventCount,
|
void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
float alpha));
|
int* eventCount, float alpha));
|
||||||
void _CurveTimeline_deinit (CurveTimeline* self);
|
void _spCurveTimeline_deinit (spCurveTimeline* self);
|
||||||
|
|
||||||
|
#ifdef SPINE_SHORT_NAMES
|
||||||
|
#define _CurveTimeline_init(...) _spCurveTimeline_init(__VA_ARGS__)
|
||||||
|
#define _CurveTimeline_deinit(...) _spCurveTimeline_deinit(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,53 +71,53 @@
|
|||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="include\spine\Animation.h" />
|
<ClInclude Include="include\spine\spAnimation.h" />
|
||||||
<ClInclude Include="include\spine\AnimationState.h" />
|
<ClInclude Include="include\spine\spAnimationState.h" />
|
||||||
<ClInclude Include="include\spine\AnimationStateData.h" />
|
<ClInclude Include="include\spine\spAnimationStateData.h" />
|
||||||
<ClInclude Include="include\spine\Atlas.h" />
|
<ClInclude Include="include\spine\Atlas.h" />
|
||||||
<ClInclude Include="include\spine\AtlasAttachmentLoader.h" />
|
<ClInclude Include="include\spine\spAtlasAttachmentLoader.h" />
|
||||||
<ClInclude Include="include\spine\Attachment.h" />
|
<ClInclude Include="include\spine\Attachment.h" />
|
||||||
<ClInclude Include="include\spine\AttachmentLoader.h" />
|
<ClInclude Include="include\spine\spAttachmentLoader.h" />
|
||||||
<ClInclude Include="include\spine\Bone.h" />
|
<ClInclude Include="include\spine\spBone.h" />
|
||||||
<ClInclude Include="include\spine\BoneData.h" />
|
<ClInclude Include="include\spine\spBoneData.h" />
|
||||||
<ClInclude Include="include\spine\BoundingBoxAttachment.h" />
|
<ClInclude Include="include\spine\spBoundingBoxAttachment.h" />
|
||||||
<ClInclude Include="include\spine\Event.h" />
|
<ClInclude Include="include\spine\spEvent.h" />
|
||||||
<ClInclude Include="include\spine\EventData.h" />
|
<ClInclude Include="include\spine\spEventData.h" />
|
||||||
<ClInclude Include="include\spine\extension.h" />
|
<ClInclude Include="include\spine\extension.h" />
|
||||||
<ClInclude Include="include\spine\RegionAttachment.h" />
|
<ClInclude Include="include\spine\spRegionAttachment.h" />
|
||||||
<ClInclude Include="include\spine\Skeleton.h" />
|
<ClInclude Include="include\spine\Skeleton.h" />
|
||||||
<ClInclude Include="include\spine\SkeletonBounds.h" />
|
<ClInclude Include="include\spine\spSkeletonBounds.h" />
|
||||||
<ClInclude Include="include\spine\SkeletonData.h" />
|
<ClInclude Include="include\spine\spSkeletonData.h" />
|
||||||
<ClInclude Include="include\spine\SkeletonJson.h" />
|
<ClInclude Include="include\spine\spSkeletonJson.h" />
|
||||||
<ClInclude Include="include\spine\Skin.h" />
|
<ClInclude Include="include\spine\spSkin.h" />
|
||||||
<ClInclude Include="include\spine\Slot.h" />
|
<ClInclude Include="include\spine\spSlot.h" />
|
||||||
<ClInclude Include="include\spine\SlotData.h" />
|
<ClInclude Include="include\spine\spSlotData.h" />
|
||||||
<ClInclude Include="include\spine\spine.h" />
|
<ClInclude Include="include\spine\spine.h" />
|
||||||
<ClInclude Include="src\spine\Json.h" />
|
<ClInclude Include="src\spine\Json.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\spine\Animation.c" />
|
<ClCompile Include="src\spine\spAnimation.c" />
|
||||||
<ClCompile Include="src\spine\AnimationState.c" />
|
<ClCompile Include="src\spine\spAnimationState.c" />
|
||||||
<ClCompile Include="src\spine\AnimationStateData.c" />
|
<ClCompile Include="src\spine\spAnimationStateData.c" />
|
||||||
<ClCompile Include="src\spine\Atlas.c" />
|
<ClCompile Include="src\spine\Atlas.c" />
|
||||||
<ClCompile Include="src\spine\AtlasAttachmentLoader.c" />
|
<ClCompile Include="src\spine\AtlasspAttachmentLoader.c" />
|
||||||
<ClCompile Include="src\spine\Attachment.c" />
|
<ClCompile Include="src\spine\Attachment.c" />
|
||||||
<ClCompile Include="src\spine\AttachmentLoader.c" />
|
<ClCompile Include="src\spine\spAttachmentLoader.c" />
|
||||||
<ClCompile Include="src\spine\Bone.c" />
|
<ClCompile Include="src\spine\spBone.c" />
|
||||||
<ClCompile Include="src\spine\BoneData.c" />
|
<ClCompile Include="src\spine\spBoneData.c" />
|
||||||
<ClCompile Include="src\spine\BoundingBoxAttachment.c" />
|
<ClCompile Include="src\spine\spBoundingBoxAttachment.c" />
|
||||||
<ClCompile Include="src\spine\Event.c" />
|
<ClCompile Include="src\spine\spEvent.c" />
|
||||||
<ClCompile Include="src\spine\EventData.c" />
|
<ClCompile Include="src\spine\spEventData.c" />
|
||||||
<ClCompile Include="src\spine\extension.c" />
|
<ClCompile Include="src\spine\extension.c" />
|
||||||
<ClCompile Include="src\spine\Json.c" />
|
<ClCompile Include="src\spine\Json.c" />
|
||||||
<ClCompile Include="src\spine\RegionAttachment.c" />
|
<ClCompile Include="src\spine\spRegionAttachment.c" />
|
||||||
<ClCompile Include="src\spine\Skeleton.c" />
|
<ClCompile Include="src\spine\Skeleton.c" />
|
||||||
<ClCompile Include="src\spine\SkeletonBounds.c" />
|
<ClCompile Include="src\spine\spSkeletonBounds.c" />
|
||||||
<ClCompile Include="src\spine\SkeletonData.c" />
|
<ClCompile Include="src\spine\spSkeletonData.c" />
|
||||||
<ClCompile Include="src\spine\SkeletonJson.c" />
|
<ClCompile Include="src\spine\spSkeletonJson.c" />
|
||||||
<ClCompile Include="src\spine\Skin.c" />
|
<ClCompile Include="src\spine\spSkin.c" />
|
||||||
<ClCompile Include="src\spine\Slot.c" />
|
<ClCompile Include="src\spine\spSlot.c" />
|
||||||
<ClCompile Include="src\spine\SlotData.c" />
|
<ClCompile Include="src\spine\spSlotData.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
|||||||
@ -15,55 +15,55 @@
|
|||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="include\spine\Animation.h">
|
<ClInclude Include="include\spine\spAnimation.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\AnimationState.h">
|
<ClInclude Include="include\spine\spAnimationState.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\AnimationStateData.h">
|
<ClInclude Include="include\spine\spAnimationStateData.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\Atlas.h">
|
<ClInclude Include="include\spine\Atlas.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\AtlasAttachmentLoader.h">
|
<ClInclude Include="include\spine\spAtlasAttachmentLoader.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\Attachment.h">
|
<ClInclude Include="include\spine\Attachment.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\AttachmentLoader.h">
|
<ClInclude Include="include\spine\spAttachmentLoader.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\Bone.h">
|
<ClInclude Include="include\spine\spBone.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\BoneData.h">
|
<ClInclude Include="include\spine\spBoneData.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\extension.h">
|
<ClInclude Include="include\spine\extension.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\RegionAttachment.h">
|
<ClInclude Include="include\spine\spRegionAttachment.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\Skeleton.h">
|
<ClInclude Include="include\spine\Skeleton.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\SkeletonData.h">
|
<ClInclude Include="include\spine\spSkeletonData.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\SkeletonJson.h">
|
<ClInclude Include="include\spine\spSkeletonJson.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\Skin.h">
|
<ClInclude Include="include\spine\spSkin.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\Slot.h">
|
<ClInclude Include="include\spine\spSlot.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\SlotData.h">
|
<ClInclude Include="include\spine\spSlotData.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\spine.h">
|
<ClInclude Include="include\spine\spine.h">
|
||||||
@ -72,45 +72,45 @@
|
|||||||
<ClInclude Include="src\spine\Json.h">
|
<ClInclude Include="src\spine\Json.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\BoundingBoxAttachment.h">
|
<ClInclude Include="include\spine\spBoundingBoxAttachment.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\SkeletonBounds.h">
|
<ClInclude Include="include\spine\spSkeletonBounds.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\Event.h">
|
<ClInclude Include="include\spine\spEvent.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\spine\EventData.h">
|
<ClInclude Include="include\spine\spEventData.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\spine\Animation.c">
|
<ClCompile Include="src\spine\spAnimation.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\AnimationState.c">
|
<ClCompile Include="src\spine\spAnimationState.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\AnimationStateData.c">
|
<ClCompile Include="src\spine\spAnimationStateData.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\Atlas.c">
|
<ClCompile Include="src\spine\Atlas.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\AtlasAttachmentLoader.c">
|
<ClCompile Include="src\spine\spAtlasAttachmentLoader.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\Attachment.c">
|
<ClCompile Include="src\spine\Attachment.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\AttachmentLoader.c">
|
<ClCompile Include="src\spine\spAttachmentLoader.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\Bone.c">
|
<ClCompile Include="src\spine\spBone.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\BoneData.c">
|
<ClCompile Include="src\spine\spBoneData.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\extension.c">
|
<ClCompile Include="src\spine\extension.c">
|
||||||
@ -119,37 +119,37 @@
|
|||||||
<ClCompile Include="src\spine\Json.c">
|
<ClCompile Include="src\spine\Json.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\RegionAttachment.c">
|
<ClCompile Include="src\spine\spRegionAttachment.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\Skeleton.c">
|
<ClCompile Include="src\spine\Skeleton.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\SkeletonData.c">
|
<ClCompile Include="src\spine\spSkeletonData.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\SkeletonJson.c">
|
<ClCompile Include="src\spine\spSkeletonJson.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\Skin.c">
|
<ClCompile Include="src\spine\spSkin.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\Slot.c">
|
<ClCompile Include="src\spine\spSlot.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\SlotData.c">
|
<ClCompile Include="src\spine\spSlotData.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\BoundingBoxAttachment.c">
|
<ClCompile Include="src\spine\spBoundingBoxAttachment.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\SkeletonBounds.c">
|
<ClCompile Include="src\spine\spSkeletonBounds.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\EventData.c">
|
<ClCompile Include="src\spine\spEventData.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\spine\Event.c">
|
<ClCompile Include="src\spine\spEvent.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@ -35,24 +35,24 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <spine/extension.h>
|
#include <spine/extension.h>
|
||||||
|
|
||||||
Animation* Animation_create (const char* name, int timelineCount) {
|
spAnimation* spAnimation_create (const char* name, int timelineCount) {
|
||||||
Animation* self = NEW(Animation);
|
spAnimation* self = NEW(spAnimation);
|
||||||
MALLOC_STR(self->name, name);
|
MALLOC_STR(self->name, name);
|
||||||
self->timelineCount = timelineCount;
|
self->timelineCount = timelineCount;
|
||||||
self->timelines = MALLOC(Timeline*, timelineCount);
|
self->timelines = MALLOC(spTimeline*, timelineCount);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation_dispose (Animation* self) {
|
void spAnimation_dispose (spAnimation* self) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->timelineCount; ++i)
|
for (i = 0; i < self->timelineCount; ++i)
|
||||||
Timeline_dispose(self->timelines[i]);
|
spTimeline_dispose(self->timelines[i]);
|
||||||
FREE(self->timelines);
|
FREE(self->timelines);
|
||||||
FREE(self->name);
|
FREE(self->name);
|
||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation_apply (const Animation* self, Skeleton* skeleton, float lastTime, float time, int loop, Event** events,
|
void spAnimation_apply (const spAnimation* self, spSkeleton* skeleton, float lastTime, float time, int loop, spEvent** events,
|
||||||
int* eventCount) {
|
int* eventCount) {
|
||||||
int i, n = self->timelineCount;
|
int i, n = self->timelineCount;
|
||||||
|
|
||||||
@ -62,10 +62,10 @@ void Animation_apply (const Animation* self, Skeleton* skeleton, float lastTime,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; ++i)
|
for (i = 0; i < n; ++i)
|
||||||
Timeline_apply(self->timelines[i], skeleton, lastTime, time, events, eventCount, 1);
|
spTimeline_apply(self->timelines[i], skeleton, lastTime, time, events, eventCount, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation_mix (const Animation* self, Skeleton* skeleton, float lastTime, float time, int loop, Event** events,
|
void spAnimation_mix (const spAnimation* self, spSkeleton* skeleton, float lastTime, float time, int loop, spEvent** events,
|
||||||
int* eventCount, float alpha) {
|
int* eventCount, float alpha) {
|
||||||
int i, n = self->timelineCount;
|
int i, n = self->timelineCount;
|
||||||
|
|
||||||
@ -75,37 +75,37 @@ void Animation_mix (const Animation* self, Skeleton* skeleton, float lastTime, f
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; ++i)
|
for (i = 0; i < n; ++i)
|
||||||
Timeline_apply(self->timelines[i], skeleton, lastTime, time, events, eventCount, alpha);
|
spTimeline_apply(self->timelines[i], skeleton, lastTime, time, events, eventCount, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
typedef struct _TimelineVtable {
|
typedef struct _spTimelineVtable {
|
||||||
void (*apply) (const Timeline* self, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, int* eventCount,
|
void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount,
|
||||||
float alpha);
|
float alpha);
|
||||||
void (*dispose) (Timeline* self);
|
void (*dispose) (spTimeline* self);
|
||||||
} _TimelineVtable;
|
} _spTimelineVtable;
|
||||||
|
|
||||||
void _Timeline_init (Timeline* self, /**/
|
void _spTimeline_init (spTimeline* self, /**/
|
||||||
void (*dispose) (Timeline* self), /**/
|
void (*dispose) (spTimeline* self), /**/
|
||||||
void (*apply) (const Timeline* self, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, int* eventCount,
|
void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
float alpha)) {
|
int* eventCount, float alpha)) {
|
||||||
CONST_CAST(_TimelineVtable*, self->vtable) = NEW(_TimelineVtable);
|
CONST_CAST(_spTimelineVtable*, self->vtable) = NEW(_spTimelineVtable);
|
||||||
VTABLE(Timeline, self)->dispose = dispose;
|
VTABLE(spTimeline, self)->dispose = dispose;
|
||||||
VTABLE(Timeline, self)->apply = apply;
|
VTABLE(spTimeline, self)->apply = apply;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _Timeline_deinit (Timeline* self) {
|
void _spTimeline_deinit (spTimeline* self) {
|
||||||
FREE(self->vtable);
|
FREE(self->vtable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timeline_dispose (Timeline* self) {
|
void spTimeline_dispose (spTimeline* self) {
|
||||||
VTABLE(Timeline, self)->dispose(self);
|
VTABLE(spTimeline, self)->dispose(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timeline_apply (const Timeline* self, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, int* eventCount,
|
void spTimeline_apply (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
float alpha) {
|
int* eventCount, float alpha) {
|
||||||
VTABLE(Timeline, self)->apply(self, skeleton, lastTime, time, firedEvents, eventCount, alpha);
|
VTABLE(spTimeline, self)->apply(self, skeleton, lastTime, time, firedEvents, eventCount, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
@ -114,28 +114,28 @@ static const float CURVE_LINEAR = 0;
|
|||||||
static const float CURVE_STEPPED = -1;
|
static const float CURVE_STEPPED = -1;
|
||||||
static const int CURVE_SEGMENTS = 10;
|
static const int CURVE_SEGMENTS = 10;
|
||||||
|
|
||||||
void _CurveTimeline_init (CurveTimeline* self, int frameCount, /**/
|
void _spCurveTimeline_init (spCurveTimeline* self, int frameCount, /**/
|
||||||
void (*dispose) (Timeline* self), /**/
|
void (*dispose) (spTimeline* self), /**/
|
||||||
void (*apply) (const Timeline* self, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, int* eventCount,
|
void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
float alpha)) {
|
int* eventCount, float alpha)) {
|
||||||
_Timeline_init(SUPER(self), dispose, apply);
|
_spTimeline_init(SUPER(self), dispose, apply);
|
||||||
self->curves = CALLOC(float, (frameCount - 1) * 6);
|
self->curves = CALLOC(float, (frameCount - 1) * 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _CurveTimeline_deinit (CurveTimeline* self) {
|
void _spCurveTimeline_deinit (spCurveTimeline* self) {
|
||||||
_Timeline_deinit(SUPER(self));
|
_spTimeline_deinit(SUPER(self));
|
||||||
FREE(self->curves);
|
FREE(self->curves);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveTimeline_setLinear (CurveTimeline* self, int frameIndex) {
|
void spCurveTimeline_setLinear (spCurveTimeline* self, int frameIndex) {
|
||||||
self->curves[frameIndex * 6] = CURVE_LINEAR;
|
self->curves[frameIndex * 6] = CURVE_LINEAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveTimeline_setStepped (CurveTimeline* self, int frameIndex) {
|
void spCurveTimeline_setStepped (spCurveTimeline* self, int frameIndex) {
|
||||||
self->curves[frameIndex * 6] = CURVE_STEPPED;
|
self->curves[frameIndex * 6] = CURVE_STEPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveTimeline_setCurve (CurveTimeline* self, int frameIndex, float cx1, float cy1, float cx2, float cy2) {
|
void spCurveTimeline_setCurve (spCurveTimeline* self, int frameIndex, float cx1, float cy1, float cx2, float cy2) {
|
||||||
float subdiv_step = 1.0f / CURVE_SEGMENTS;
|
float subdiv_step = 1.0f / CURVE_SEGMENTS;
|
||||||
float subdiv_step2 = subdiv_step * subdiv_step;
|
float subdiv_step2 = subdiv_step * subdiv_step;
|
||||||
float subdiv_step3 = subdiv_step2 * subdiv_step;
|
float subdiv_step3 = subdiv_step2 * subdiv_step;
|
||||||
@ -156,7 +156,7 @@ void CurveTimeline_setCurve (CurveTimeline* self, int frameIndex, float cx1, flo
|
|||||||
self->curves[i + 5] = tmp2y * pre5;
|
self->curves[i + 5] = tmp2y * pre5;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CurveTimeline_getCurvePercent (const CurveTimeline* self, int frameIndex, float percent) {
|
float spCurveTimeline_getCurvePercent (const spCurveTimeline* self, int frameIndex, float percent) {
|
||||||
float dfy;
|
float dfy;
|
||||||
float ddfx;
|
float ddfx;
|
||||||
float ddfy;
|
float ddfy;
|
||||||
@ -221,19 +221,19 @@ static int binarySearch (float *values, int valuesLength, float target, int step
|
|||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
void _BaseTimeline_dispose (Timeline* timeline) {
|
void _spBaseTimeline_dispose (spTimeline* timeline) {
|
||||||
struct BaseTimeline* self = SUB_CAST(struct BaseTimeline, timeline);
|
struct spBaseTimeline* self = SUB_CAST(struct spBaseTimeline, timeline);
|
||||||
_CurveTimeline_deinit(SUPER(self));
|
_spCurveTimeline_deinit(SUPER(self));
|
||||||
FREE(self->frames);
|
FREE(self->frames);
|
||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Many timelines have structure identical to struct BaseTimeline and extend CurveTimeline. **/
|
/* Many timelines have structure identical to struct spBaseTimeline and extend spCurveTimeline. **/
|
||||||
struct BaseTimeline* _BaseTimeline_create (int frameCount, int frameSize, /**/
|
struct spBaseTimeline* _spBaseTimeline_create (int frameCount, int frameSize, /**/
|
||||||
void (*apply) (const Timeline* self, Skeleton* skeleton, float lastTime, float time, Event** firedEvents, int* eventCount,
|
void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
float alpha)) {
|
int* eventCount, float alpha)) {
|
||||||
struct BaseTimeline* self = NEW(struct BaseTimeline);
|
struct spBaseTimeline* self = NEW(struct spBaseTimeline);
|
||||||
_CurveTimeline_init(SUPER(self), frameCount, _BaseTimeline_dispose, apply);
|
_spCurveTimeline_init(SUPER(self), frameCount, _spBaseTimeline_dispose, apply);
|
||||||
|
|
||||||
CONST_CAST(int, self->framesLength) = frameCount * frameSize;
|
CONST_CAST(int, self->framesLength) = frameCount * frameSize;
|
||||||
CONST_CAST(float*, self->frames) = CALLOC(float, self->framesLength);
|
CONST_CAST(float*, self->frames) = CALLOC(float, self->framesLength);
|
||||||
@ -246,13 +246,13 @@ struct BaseTimeline* _BaseTimeline_create (int frameCount, int frameSize, /**/
|
|||||||
static const int ROTATE_LAST_FRAME_TIME = -2;
|
static const int ROTATE_LAST_FRAME_TIME = -2;
|
||||||
static const int ROTATE_FRAME_VALUE = 1;
|
static const int ROTATE_FRAME_VALUE = 1;
|
||||||
|
|
||||||
void _RotateTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float lastTime, float time, Event** firedEvents,
|
void _spRotateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int* eventCount, float alpha) {
|
int* eventCount, float alpha) {
|
||||||
Bone *bone;
|
spBone *bone;
|
||||||
int frameIndex;
|
int frameIndex;
|
||||||
float lastFrameValue, frameTime, percent, amount;
|
float lastFrameValue, frameTime, percent, amount;
|
||||||
|
|
||||||
RotateTimeline* self = SUB_CAST(RotateTimeline, timeline);
|
spRotateTimeline* self = SUB_CAST(spRotateTimeline, timeline);
|
||||||
|
|
||||||
if (time < self->frames[0]) return; /* Time is before first frame. */
|
if (time < self->frames[0]) return; /* Time is before first frame. */
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ void _RotateTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float
|
|||||||
lastFrameValue = self->frames[frameIndex - 1];
|
lastFrameValue = self->frames[frameIndex - 1];
|
||||||
frameTime = self->frames[frameIndex];
|
frameTime = self->frames[frameIndex];
|
||||||
percent = 1 - (time - frameTime) / (self->frames[frameIndex + ROTATE_LAST_FRAME_TIME] - frameTime);
|
percent = 1 - (time - frameTime) / (self->frames[frameIndex + ROTATE_LAST_FRAME_TIME] - frameTime);
|
||||||
percent = CurveTimeline_getCurvePercent(SUPER(self), frameIndex / 2 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent));
|
percent = spCurveTimeline_getCurvePercent(SUPER(self), frameIndex / 2 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent));
|
||||||
|
|
||||||
amount = self->frames[frameIndex + ROTATE_FRAME_VALUE] - lastFrameValue;
|
amount = self->frames[frameIndex + ROTATE_FRAME_VALUE] - lastFrameValue;
|
||||||
while (amount > 180)
|
while (amount > 180)
|
||||||
@ -288,11 +288,11 @@ void _RotateTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float
|
|||||||
bone->rotation += amount * alpha;
|
bone->rotation += amount * alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
RotateTimeline* RotateTimeline_create (int frameCount) {
|
spRotateTimeline* spRotateTimeline_create (int frameCount) {
|
||||||
return _BaseTimeline_create(frameCount, 2, _RotateTimeline_apply);
|
return _spBaseTimeline_create(frameCount, 2, _spRotateTimeline_apply);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotateTimeline_setFrame (RotateTimeline* self, int frameIndex, float time, float angle) {
|
void spRotateTimeline_setFrame (spRotateTimeline* self, int frameIndex, float time, float angle) {
|
||||||
frameIndex *= 2;
|
frameIndex *= 2;
|
||||||
self->frames[frameIndex] = time;
|
self->frames[frameIndex] = time;
|
||||||
self->frames[frameIndex + 1] = angle;
|
self->frames[frameIndex + 1] = angle;
|
||||||
@ -304,13 +304,13 @@ static const int TRANSLATE_LAST_FRAME_TIME = -3;
|
|||||||
static const int TRANSLATE_FRAME_X = 1;
|
static const int TRANSLATE_FRAME_X = 1;
|
||||||
static const int TRANSLATE_FRAME_Y = 2;
|
static const int TRANSLATE_FRAME_Y = 2;
|
||||||
|
|
||||||
void _TranslateTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float lastTime, float time, Event** firedEvents,
|
void _spTranslateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int* eventCount, float alpha) {
|
int* eventCount, float alpha) {
|
||||||
Bone *bone;
|
spBone *bone;
|
||||||
int frameIndex;
|
int frameIndex;
|
||||||
float lastFrameX, lastFrameY, frameTime, percent;
|
float lastFrameX, lastFrameY, frameTime, percent;
|
||||||
|
|
||||||
TranslateTimeline* self = SUB_CAST(TranslateTimeline, timeline);
|
spTranslateTimeline* self = SUB_CAST(spTranslateTimeline, timeline);
|
||||||
|
|
||||||
if (time < self->frames[0]) return; /* Time is before first frame. */
|
if (time < self->frames[0]) return; /* Time is before first frame. */
|
||||||
|
|
||||||
@ -328,7 +328,7 @@ void _TranslateTimeline_apply (const Timeline* timeline, Skeleton* skeleton, flo
|
|||||||
lastFrameY = self->frames[frameIndex - 1];
|
lastFrameY = self->frames[frameIndex - 1];
|
||||||
frameTime = self->frames[frameIndex];
|
frameTime = self->frames[frameIndex];
|
||||||
percent = 1 - (time - frameTime) / (self->frames[frameIndex + TRANSLATE_LAST_FRAME_TIME] - frameTime);
|
percent = 1 - (time - frameTime) / (self->frames[frameIndex + TRANSLATE_LAST_FRAME_TIME] - frameTime);
|
||||||
percent = CurveTimeline_getCurvePercent(SUPER(self), frameIndex / 3 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent));
|
percent = spCurveTimeline_getCurvePercent(SUPER(self), frameIndex / 3 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent));
|
||||||
|
|
||||||
bone->x += (bone->data->x + lastFrameX + (self->frames[frameIndex + TRANSLATE_FRAME_X] - lastFrameX) * percent - bone->x)
|
bone->x += (bone->data->x + lastFrameX + (self->frames[frameIndex + TRANSLATE_FRAME_X] - lastFrameX) * percent - bone->x)
|
||||||
* alpha;
|
* alpha;
|
||||||
@ -336,11 +336,11 @@ void _TranslateTimeline_apply (const Timeline* timeline, Skeleton* skeleton, flo
|
|||||||
* alpha;
|
* alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
TranslateTimeline* TranslateTimeline_create (int frameCount) {
|
spTranslateTimeline* spTranslateTimeline_create (int frameCount) {
|
||||||
return _BaseTimeline_create(frameCount, 3, _TranslateTimeline_apply);
|
return _spBaseTimeline_create(frameCount, 3, _spTranslateTimeline_apply);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TranslateTimeline_setFrame (TranslateTimeline* self, int frameIndex, float time, float x, float y) {
|
void spTranslateTimeline_setFrame (spTranslateTimeline* self, int frameIndex, float time, float x, float y) {
|
||||||
frameIndex *= 3;
|
frameIndex *= 3;
|
||||||
self->frames[frameIndex] = time;
|
self->frames[frameIndex] = time;
|
||||||
self->frames[frameIndex + 1] = x;
|
self->frames[frameIndex + 1] = x;
|
||||||
@ -349,13 +349,13 @@ void TranslateTimeline_setFrame (TranslateTimeline* self, int frameIndex, float
|
|||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
void _ScaleTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float lastTime, float time, Event** firedEvents,
|
void _spScaleTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int* eventCount, float alpha) {
|
int* eventCount, float alpha) {
|
||||||
Bone *bone;
|
spBone *bone;
|
||||||
int frameIndex;
|
int frameIndex;
|
||||||
float lastFrameX, lastFrameY, frameTime, percent;
|
float lastFrameX, lastFrameY, frameTime, percent;
|
||||||
|
|
||||||
ScaleTimeline* self = SUB_CAST(ScaleTimeline, timeline);
|
spScaleTimeline* self = SUB_CAST(spScaleTimeline, timeline);
|
||||||
|
|
||||||
if (time < self->frames[0]) return; /* Time is before first frame. */
|
if (time < self->frames[0]) return; /* Time is before first frame. */
|
||||||
|
|
||||||
@ -372,7 +372,7 @@ void _ScaleTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float l
|
|||||||
lastFrameY = self->frames[frameIndex - 1];
|
lastFrameY = self->frames[frameIndex - 1];
|
||||||
frameTime = self->frames[frameIndex];
|
frameTime = self->frames[frameIndex];
|
||||||
percent = 1 - (time - frameTime) / (self->frames[frameIndex + TRANSLATE_LAST_FRAME_TIME] - frameTime);
|
percent = 1 - (time - frameTime) / (self->frames[frameIndex + TRANSLATE_LAST_FRAME_TIME] - frameTime);
|
||||||
percent = CurveTimeline_getCurvePercent(SUPER(self), frameIndex / 3 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent));
|
percent = spCurveTimeline_getCurvePercent(SUPER(self), frameIndex / 3 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent));
|
||||||
|
|
||||||
bone->scaleX += (bone->data->scaleX - 1 + lastFrameX + (self->frames[frameIndex + TRANSLATE_FRAME_X] - lastFrameX) * percent
|
bone->scaleX += (bone->data->scaleX - 1 + lastFrameX + (self->frames[frameIndex + TRANSLATE_FRAME_X] - lastFrameX) * percent
|
||||||
- bone->scaleX) * alpha;
|
- bone->scaleX) * alpha;
|
||||||
@ -380,12 +380,12 @@ void _ScaleTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float l
|
|||||||
- bone->scaleY) * alpha;
|
- bone->scaleY) * alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScaleTimeline* ScaleTimeline_create (int frameCount) {
|
spScaleTimeline* spScaleTimeline_create (int frameCount) {
|
||||||
return _BaseTimeline_create(frameCount, 3, _ScaleTimeline_apply);
|
return _spBaseTimeline_create(frameCount, 3, _spScaleTimeline_apply);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScaleTimeline_setFrame (ScaleTimeline* self, int frameIndex, float time, float x, float y) {
|
void spScaleTimeline_setFrame (spScaleTimeline* self, int frameIndex, float time, float x, float y) {
|
||||||
TranslateTimeline_setFrame(self, frameIndex, time, x, y);
|
spTranslateTimeline_setFrame(self, frameIndex, time, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
@ -396,13 +396,13 @@ static const int COLOR_FRAME_G = 2;
|
|||||||
static const int COLOR_FRAME_B = 3;
|
static const int COLOR_FRAME_B = 3;
|
||||||
static const int COLOR_FRAME_A = 4;
|
static const int COLOR_FRAME_A = 4;
|
||||||
|
|
||||||
void _ColorTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float lastTime, float time, Event** firedEvents,
|
void _spColorTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int* eventCount, float alpha) {
|
int* eventCount, float alpha) {
|
||||||
Slot *slot;
|
spSlot *slot;
|
||||||
int frameIndex;
|
int frameIndex;
|
||||||
float lastFrameR, lastFrameG, lastFrameB, lastFrameA, percent, frameTime;
|
float lastFrameR, lastFrameG, lastFrameB, lastFrameA, percent, frameTime;
|
||||||
float r, g, b, a;
|
float r, g, b, a;
|
||||||
ColorTimeline* self = (ColorTimeline*)timeline;
|
spColorTimeline* self = (spColorTimeline*)timeline;
|
||||||
|
|
||||||
if (time < self->frames[0]) return; /* Time is before first frame. */
|
if (time < self->frames[0]) return; /* Time is before first frame. */
|
||||||
|
|
||||||
@ -425,7 +425,7 @@ void _ColorTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float l
|
|||||||
lastFrameA = self->frames[frameIndex - 1];
|
lastFrameA = self->frames[frameIndex - 1];
|
||||||
frameTime = self->frames[frameIndex];
|
frameTime = self->frames[frameIndex];
|
||||||
percent = 1 - (time - frameTime) / (self->frames[frameIndex + COLOR_LAST_FRAME_TIME] - frameTime);
|
percent = 1 - (time - frameTime) / (self->frames[frameIndex + COLOR_LAST_FRAME_TIME] - frameTime);
|
||||||
percent = CurveTimeline_getCurvePercent(SUPER(self), frameIndex / 5 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent));
|
percent = spCurveTimeline_getCurvePercent(SUPER(self), frameIndex / 5 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent));
|
||||||
|
|
||||||
r = lastFrameR + (self->frames[frameIndex + COLOR_FRAME_R] - lastFrameR) * percent;
|
r = lastFrameR + (self->frames[frameIndex + COLOR_FRAME_R] - lastFrameR) * percent;
|
||||||
g = lastFrameG + (self->frames[frameIndex + COLOR_FRAME_G] - lastFrameG) * percent;
|
g = lastFrameG + (self->frames[frameIndex + COLOR_FRAME_G] - lastFrameG) * percent;
|
||||||
@ -444,11 +444,11 @@ void _ColorTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float l
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorTimeline* ColorTimeline_create (int frameCount) {
|
spColorTimeline* spColorTimeline_create (int frameCount) {
|
||||||
return (ColorTimeline*)_BaseTimeline_create(frameCount, 5, _ColorTimeline_apply);
|
return (spColorTimeline*)_spBaseTimeline_create(frameCount, 5, _spColorTimeline_apply);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorTimeline_setFrame (ColorTimeline* self, int frameIndex, float time, float r, float g, float b, float a) {
|
void spColorTimeline_setFrame (spColorTimeline* self, int frameIndex, float time, float r, float g, float b, float a) {
|
||||||
frameIndex *= 5;
|
frameIndex *= 5;
|
||||||
self->frames[frameIndex] = time;
|
self->frames[frameIndex] = time;
|
||||||
self->frames[frameIndex + 1] = r;
|
self->frames[frameIndex + 1] = r;
|
||||||
@ -459,11 +459,11 @@ void ColorTimeline_setFrame (ColorTimeline* self, int frameIndex, float time, fl
|
|||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
void _AttachmentTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float lastTime, float time, Event** firedEvents,
|
void _spAttachmentTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int* eventCount, float alpha) {
|
int* eventCount, float alpha) {
|
||||||
int frameIndex;
|
int frameIndex;
|
||||||
const char* attachmentName;
|
const char* attachmentName;
|
||||||
AttachmentTimeline* self = (AttachmentTimeline*)timeline;
|
spAttachmentTimeline* self = (spAttachmentTimeline*)timeline;
|
||||||
|
|
||||||
if (time < self->frames[0]) return; /* Time is before first frame. */
|
if (time < self->frames[0]) return; /* Time is before first frame. */
|
||||||
|
|
||||||
@ -473,15 +473,15 @@ void _AttachmentTimeline_apply (const Timeline* timeline, Skeleton* skeleton, fl
|
|||||||
frameIndex = binarySearch(self->frames, self->framesLength, time, 1) - 1;
|
frameIndex = binarySearch(self->frames, self->framesLength, time, 1) - 1;
|
||||||
|
|
||||||
attachmentName = self->attachmentNames[frameIndex];
|
attachmentName = self->attachmentNames[frameIndex];
|
||||||
Slot_setAttachment(skeleton->slots[self->slotIndex],
|
spSlot_setAttachment(skeleton->slots[self->slotIndex],
|
||||||
attachmentName ? Skeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName) : 0);
|
attachmentName ? spSkeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _AttachmentTimeline_dispose (Timeline* timeline) {
|
void _spAttachmentTimeline_dispose (spTimeline* timeline) {
|
||||||
AttachmentTimeline* self = SUB_CAST(AttachmentTimeline, timeline);
|
spAttachmentTimeline* self = SUB_CAST(spAttachmentTimeline, timeline);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
_Timeline_deinit(timeline);
|
_spTimeline_deinit(timeline);
|
||||||
|
|
||||||
for (i = 0; i < self->framesLength; ++i)
|
for (i = 0; i < self->framesLength; ++i)
|
||||||
FREE(self->attachmentNames[i]);
|
FREE(self->attachmentNames[i]);
|
||||||
@ -490,9 +490,9 @@ void _AttachmentTimeline_dispose (Timeline* timeline) {
|
|||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
AttachmentTimeline* AttachmentTimeline_create (int frameCount) {
|
spAttachmentTimeline* spAttachmentTimeline_create (int frameCount) {
|
||||||
AttachmentTimeline* self = NEW(AttachmentTimeline);
|
spAttachmentTimeline* self = NEW(spAttachmentTimeline);
|
||||||
_Timeline_init(SUPER(self), _AttachmentTimeline_dispose, _AttachmentTimeline_apply);
|
_spTimeline_init(SUPER(self), _spAttachmentTimeline_dispose, _spAttachmentTimeline_apply);
|
||||||
|
|
||||||
CONST_CAST(int, self->framesLength) = frameCount;
|
CONST_CAST(int, self->framesLength) = frameCount;
|
||||||
CONST_CAST(float*, self->frames) = CALLOC(float, frameCount);
|
CONST_CAST(float*, self->frames) = CALLOC(float, frameCount);
|
||||||
@ -501,7 +501,7 @@ AttachmentTimeline* AttachmentTimeline_create (int frameCount) {
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttachmentTimeline_setFrame (AttachmentTimeline* self, int frameIndex, float time, const char* attachmentName) {
|
void spAttachmentTimeline_setFrame (spAttachmentTimeline* self, int frameIndex, float time, const char* attachmentName) {
|
||||||
self->frames[frameIndex] = time;
|
self->frames[frameIndex] = time;
|
||||||
|
|
||||||
FREE(self->attachmentNames[frameIndex]);
|
FREE(self->attachmentNames[frameIndex]);
|
||||||
@ -513,17 +513,17 @@ void AttachmentTimeline_setFrame (AttachmentTimeline* self, int frameIndex, floa
|
|||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
void _EventTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float lastTime, float time, Event** firedEvents,
|
void _spEventTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int* eventCount, float alpha) {
|
int* eventCount, float alpha) {
|
||||||
if (!firedEvents) return;
|
if (!firedEvents) return;
|
||||||
EventTimeline* self = (EventTimeline*)timeline;
|
spEventTimeline* self = (spEventTimeline*)timeline;
|
||||||
int frameIndex;
|
int frameIndex;
|
||||||
|
|
||||||
if (lastTime >= self->frames[self->framesLength - 1]) return; /* Last time is after last frame. */
|
if (lastTime >= self->frames[self->framesLength - 1]) return; /* Last time is after last frame. */
|
||||||
|
|
||||||
if (lastTime > time) {
|
if (lastTime > time) {
|
||||||
/* Fire events after last time for looped animations. */
|
/* Fire events after last time for looped animations. */
|
||||||
_EventTimeline_apply(timeline, skeleton, lastTime, (float)INT_MAX, firedEvents, eventCount, alpha);
|
_spEventTimeline_apply(timeline, skeleton, lastTime, (float)INT_MAX, firedEvents, eventCount, alpha);
|
||||||
lastTime = 0;
|
lastTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -544,11 +544,11 @@ void _EventTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float l
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _EventTimeline_dispose (Timeline* timeline) {
|
void _spEventTimeline_dispose (spTimeline* timeline) {
|
||||||
EventTimeline* self = SUB_CAST(EventTimeline, timeline);
|
spEventTimeline* self = SUB_CAST(spEventTimeline, timeline);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
_Timeline_deinit(timeline);
|
_spTimeline_deinit(timeline);
|
||||||
|
|
||||||
for (i = 0; i < self->framesLength; ++i)
|
for (i = 0; i < self->framesLength; ++i)
|
||||||
FREE(self->events[i]);
|
FREE(self->events[i]);
|
||||||
@ -557,18 +557,18 @@ void _EventTimeline_dispose (Timeline* timeline) {
|
|||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventTimeline* EventTimeline_create (int frameCount) {
|
spEventTimeline* spEventTimeline_create (int frameCount) {
|
||||||
EventTimeline* self = NEW(EventTimeline);
|
spEventTimeline* self = NEW(spEventTimeline);
|
||||||
_Timeline_init(SUPER(self), _EventTimeline_dispose, _EventTimeline_apply);
|
_spTimeline_init(SUPER(self), _spEventTimeline_dispose, _spEventTimeline_apply);
|
||||||
|
|
||||||
CONST_CAST(int, self->framesLength) = frameCount;
|
CONST_CAST(int, self->framesLength) = frameCount;
|
||||||
CONST_CAST(float*, self->frames) = CALLOC(float, frameCount);
|
CONST_CAST(float*, self->frames) = CALLOC(float, frameCount);
|
||||||
CONST_CAST(Event**, self->events) = CALLOC(Event*, frameCount);
|
CONST_CAST(spEvent**, self->events) = CALLOC(spEvent*, frameCount);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventTimeline_setFrame (EventTimeline* self, int frameIndex, float time, Event* event) {
|
void spEventTimeline_setFrame (spEventTimeline* self, int frameIndex, float time, spEvent* event) {
|
||||||
self->frames[frameIndex] = time;
|
self->frames[frameIndex] = time;
|
||||||
|
|
||||||
FREE(self->events[frameIndex]);
|
FREE(self->events[frameIndex]);
|
||||||
@ -577,12 +577,12 @@ void EventTimeline_setFrame (EventTimeline* self, int frameIndex, float time, Ev
|
|||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
void _DrawOrderTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float lastTime, float time, Event** firedEvents,
|
void _spDrawOrderTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int* eventCount, float alpha) {
|
int* eventCount, float alpha) {
|
||||||
int i;
|
int i;
|
||||||
int frameIndex;
|
int frameIndex;
|
||||||
const int* drawOrderToSetupIndex;
|
const int* drawOrderToSetupIndex;
|
||||||
DrawOrderTimeline* self = (DrawOrderTimeline*)timeline;
|
spDrawOrderTimeline* self = (spDrawOrderTimeline*)timeline;
|
||||||
|
|
||||||
if (time < self->frames[0]) return; /* Time is before first frame. */
|
if (time < self->frames[0]) return; /* Time is before first frame. */
|
||||||
|
|
||||||
@ -600,11 +600,11 @@ void _DrawOrderTimeline_apply (const Timeline* timeline, Skeleton* skeleton, flo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _DrawOrderTimeline_dispose (Timeline* timeline) {
|
void _spDrawOrderTimeline_dispose (spTimeline* timeline) {
|
||||||
DrawOrderTimeline* self = SUB_CAST(DrawOrderTimeline, timeline);
|
spDrawOrderTimeline* self = SUB_CAST(spDrawOrderTimeline, timeline);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
_Timeline_deinit(timeline);
|
_spTimeline_deinit(timeline);
|
||||||
|
|
||||||
for (i = 0; i < self->framesLength; ++i)
|
for (i = 0; i < self->framesLength; ++i)
|
||||||
FREE(self->drawOrders[i]);
|
FREE(self->drawOrders[i]);
|
||||||
@ -613,9 +613,9 @@ void _DrawOrderTimeline_dispose (Timeline* timeline) {
|
|||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawOrderTimeline* DrawOrderTimeline_create (int frameCount, int slotCount) {
|
spDrawOrderTimeline* spDrawOrderTimeline_create (int frameCount, int slotCount) {
|
||||||
DrawOrderTimeline* self = NEW(DrawOrderTimeline);
|
spDrawOrderTimeline* self = NEW(spDrawOrderTimeline);
|
||||||
_Timeline_init(SUPER(self), _DrawOrderTimeline_dispose, _DrawOrderTimeline_apply);
|
_spTimeline_init(SUPER(self), _spDrawOrderTimeline_dispose, _spDrawOrderTimeline_apply);
|
||||||
|
|
||||||
CONST_CAST(int, self->framesLength) = frameCount;
|
CONST_CAST(int, self->framesLength) = frameCount;
|
||||||
CONST_CAST(float*, self->frames) = CALLOC(float, frameCount);
|
CONST_CAST(float*, self->frames) = CALLOC(float, frameCount);
|
||||||
@ -625,7 +625,7 @@ DrawOrderTimeline* DrawOrderTimeline_create (int frameCount, int slotCount) {
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawOrderTimeline_setFrame (DrawOrderTimeline* self, int frameIndex, float time, const int* drawOrder) {
|
void spDrawOrderTimeline_setFrame (spDrawOrderTimeline* self, int frameIndex, float time, const int* drawOrder) {
|
||||||
self->frames[frameIndex] = time;
|
self->frames[frameIndex] = time;
|
||||||
|
|
||||||
FREE(self->drawOrders[frameIndex]);
|
FREE(self->drawOrders[frameIndex]);
|
||||||
|
|||||||
@ -40,20 +40,20 @@
|
|||||||
#include <spine/SkeletonData.h>
|
#include <spine/SkeletonData.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
TrackEntry* _TrackEntry_create () {
|
spTrackEntry* _spTrackEntry_create () {
|
||||||
TrackEntry* entry = NEW(TrackEntry);
|
spTrackEntry* entry = NEW(spTrackEntry);
|
||||||
entry->timeScale = 1;
|
entry->timeScale = 1;
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _TrackEntry_dispose (TrackEntry* entry) {
|
void _spTrackEntry_dispose (spTrackEntry* entry) {
|
||||||
FREE(entry);
|
FREE(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _TrackEntry_disposeAll (TrackEntry* entry) {
|
void _spTrackEntry_disposeAll (spTrackEntry* entry) {
|
||||||
while (entry) {
|
while (entry) {
|
||||||
TrackEntry* next = entry->next;
|
spTrackEntry* next = entry->next;
|
||||||
_TrackEntry_dispose(entry);
|
_spTrackEntry_dispose(entry);
|
||||||
entry = next;
|
entry = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,34 +61,34 @@ void _TrackEntry_disposeAll (TrackEntry* entry) {
|
|||||||
/**/
|
/**/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
AnimationState super;
|
spAnimationState super;
|
||||||
Event** events;
|
spEvent** events;
|
||||||
} _AnimationState;
|
} _spAnimationState;
|
||||||
|
|
||||||
void _AnimationState_setCurrent (AnimationState* self, int index, TrackEntry* entry);
|
void _spAnimationState_setCurrent (spAnimationState* self, int index, spTrackEntry* entry);
|
||||||
|
|
||||||
AnimationState* AnimationState_create (AnimationStateData* data) {
|
spAnimationState* spAnimationState_create (spAnimationStateData* data) {
|
||||||
_AnimationState* internal = NEW(_AnimationState);
|
_spAnimationState* internal = NEW(_spAnimationState);
|
||||||
AnimationState* self = SUPER(internal);
|
spAnimationState* self = SUPER(internal);
|
||||||
internal->events = MALLOC(Event*, 64);
|
internal->events = MALLOC(spEvent*, 64);
|
||||||
self->timeScale = 1;
|
self->timeScale = 1;
|
||||||
CONST_CAST(AnimationStateData*, self->data) = data;
|
CONST_CAST(spAnimationStateData*, self->data) = data;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationState_dispose (AnimationState* self) {
|
void spAnimationState_dispose (spAnimationState* self) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->trackCount; i++)
|
for (i = 0; i < self->trackCount; i++)
|
||||||
_TrackEntry_disposeAll(self->tracks[i]);
|
_spTrackEntry_disposeAll(self->tracks[i]);
|
||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationState_update (AnimationState* self, float delta) {
|
void spAnimationState_update (spAnimationState* self, float delta) {
|
||||||
int i;
|
int i;
|
||||||
float time, endTime, trackDelta;
|
float time, endTime, trackDelta;
|
||||||
delta *= self->timeScale;
|
delta *= self->timeScale;
|
||||||
for (i = 0; i < self->trackCount; i++) {
|
for (i = 0; i < self->trackCount; i++) {
|
||||||
TrackEntry* current = self->tracks[i];
|
spTrackEntry* current = self->tracks[i];
|
||||||
if (!current) continue;
|
if (!current) continue;
|
||||||
|
|
||||||
trackDelta = delta * current->timeScale;
|
trackDelta = delta * current->timeScale;
|
||||||
@ -110,23 +110,23 @@ void AnimationState_update (AnimationState* self, float delta) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (current->next) {
|
if (current->next) {
|
||||||
if (time - trackDelta >= current->next->delay) _AnimationState_setCurrent(self, i, current->next);
|
if (time - trackDelta >= current->next->delay) _spAnimationState_setCurrent(self, i, current->next);
|
||||||
} else {
|
} else {
|
||||||
/* End non-looping animation when it reaches its end time and there is no next entry. */
|
/* End non-looping animation when it reaches its end time and there is no next entry. */
|
||||||
if (!current->loop && current->lastTime >= current->endTime) AnimationState_clearTrack(self, i);
|
if (!current->loop && current->lastTime >= current->endTime) spAnimationState_clearTrack(self, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationState_apply (AnimationState* self, Skeleton* skeleton) {
|
void spAnimationState_apply (spAnimationState* self, spSkeleton* skeleton) {
|
||||||
_AnimationState* internal = SUB_CAST(_AnimationState, self);
|
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
|
||||||
|
|
||||||
int i, ii;
|
int i, ii;
|
||||||
int eventCount;
|
int eventCount;
|
||||||
float time;
|
float time;
|
||||||
TrackEntry* previous;
|
spTrackEntry* previous;
|
||||||
for (i = 0; i < self->trackCount; i++) {
|
for (i = 0; i < self->trackCount; i++) {
|
||||||
TrackEntry* current = self->tracks[i];
|
spTrackEntry* current = self->tracks[i];
|
||||||
if (!current) continue;
|
if (!current) continue;
|
||||||
|
|
||||||
eventCount = 0;
|
eventCount = 0;
|
||||||
@ -136,26 +136,26 @@ void AnimationState_apply (AnimationState* self, Skeleton* skeleton) {
|
|||||||
|
|
||||||
previous = current->previous;
|
previous = current->previous;
|
||||||
if (!previous) {
|
if (!previous) {
|
||||||
Animation_apply(current->animation, skeleton, current->lastTime, time, current->loop, internal->events,
|
spAnimation_apply(current->animation, skeleton, current->lastTime, time, current->loop, internal->events,
|
||||||
&eventCount);
|
&eventCount);
|
||||||
} else {
|
} else {
|
||||||
float alpha = current->mixTime / current->mixDuration;
|
float alpha = current->mixTime / current->mixDuration;
|
||||||
|
|
||||||
float previousTime = previous->time;
|
float previousTime = previous->time;
|
||||||
if (!previous->loop && previousTime > previous->endTime) previousTime = previous->endTime;
|
if (!previous->loop && previousTime > previous->endTime) previousTime = previous->endTime;
|
||||||
Animation_apply(previous->animation, skeleton, previousTime, previousTime, previous->loop, 0, 0);
|
spAnimation_apply(previous->animation, skeleton, previousTime, previousTime, previous->loop, 0, 0);
|
||||||
|
|
||||||
if (alpha >= 1) {
|
if (alpha >= 1) {
|
||||||
alpha = 1;
|
alpha = 1;
|
||||||
_TrackEntry_dispose(current->previous);
|
_spTrackEntry_dispose(current->previous);
|
||||||
current->previous = 0;
|
current->previous = 0;
|
||||||
}
|
}
|
||||||
Animation_mix(current->animation, skeleton, current->lastTime, time, current->loop, internal->events,
|
spAnimation_mix(current->animation, skeleton, current->lastTime, time, current->loop, internal->events,
|
||||||
&eventCount, alpha);
|
&eventCount, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ii = 0; ii < eventCount; ii++) {
|
for (ii = 0; ii < eventCount; ii++) {
|
||||||
Event* event = internal->events[ii];
|
spEvent* event = internal->events[ii];
|
||||||
if (current->listener) current->listener(self, i, ANIMATION_EVENT, event, 0);
|
if (current->listener) current->listener(self, i, ANIMATION_EVENT, event, 0);
|
||||||
if (self->listener) self->listener(self, i, ANIMATION_EVENT, event, 0);
|
if (self->listener) self->listener(self, i, ANIMATION_EVENT, event, 0);
|
||||||
}
|
}
|
||||||
@ -164,15 +164,15 @@ void AnimationState_apply (AnimationState* self, Skeleton* skeleton) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationState_clearTracks (AnimationState* self) {
|
void spAnimationState_clearTracks (spAnimationState* self) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->trackCount; i++)
|
for (i = 0; i < self->trackCount; i++)
|
||||||
AnimationState_clearTrack(self, i);
|
spAnimationState_clearTrack(self, i);
|
||||||
self->trackCount = 0;
|
self->trackCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationState_clearTrack (AnimationState* self, int trackIndex) {
|
void spAnimationState_clearTrack (spAnimationState* self, int trackIndex) {
|
||||||
TrackEntry* current;
|
spTrackEntry* current;
|
||||||
if (trackIndex >= self->trackCount) return;
|
if (trackIndex >= self->trackCount) return;
|
||||||
current = self->tracks[trackIndex];
|
current = self->tracks[trackIndex];
|
||||||
if (!current) return;
|
if (!current) return;
|
||||||
@ -181,37 +181,37 @@ void AnimationState_clearTrack (AnimationState* self, int trackIndex) {
|
|||||||
if (self->listener) self->listener(self, trackIndex, ANIMATION_END, 0, 0);
|
if (self->listener) self->listener(self, trackIndex, ANIMATION_END, 0, 0);
|
||||||
|
|
||||||
self->tracks[trackIndex] = 0;
|
self->tracks[trackIndex] = 0;
|
||||||
if (current->previous) _TrackEntry_dispose(current->previous);
|
if (current->previous) _spTrackEntry_dispose(current->previous);
|
||||||
_TrackEntry_disposeAll(current);
|
_spTrackEntry_disposeAll(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry* _AnimationState_expandToIndex (AnimationState* self, int index) {
|
spTrackEntry* _spAnimationState_expandToIndex (spAnimationState* self, int index) {
|
||||||
TrackEntry** newTracks;
|
spTrackEntry** newTracks;
|
||||||
if (index < self->trackCount) return self->tracks[index];
|
if (index < self->trackCount) return self->tracks[index];
|
||||||
newTracks = CALLOC(TrackEntry*, index + 1);
|
newTracks = CALLOC(spTrackEntry*, index + 1);
|
||||||
memcpy(newTracks, self->tracks, self->trackCount * sizeof(TrackEntry*));
|
memcpy(newTracks, self->tracks, self->trackCount * sizeof(spTrackEntry*));
|
||||||
self->tracks = newTracks;
|
self->tracks = newTracks;
|
||||||
self->trackCount = index + 1;
|
self->trackCount = index + 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _AnimationState_setCurrent (AnimationState* self, int index, TrackEntry* entry) {
|
void _spAnimationState_setCurrent (spAnimationState* self, int index, spTrackEntry* entry) {
|
||||||
TrackEntry* current = _AnimationState_expandToIndex(self, index);
|
spTrackEntry* current = _spAnimationState_expandToIndex(self, index);
|
||||||
if (current) {
|
if (current) {
|
||||||
if (current->previous) {
|
if (current->previous) {
|
||||||
_TrackEntry_dispose(current->previous);
|
_spTrackEntry_dispose(current->previous);
|
||||||
current->previous = 0;
|
current->previous = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current->listener) current->listener(self, index, ANIMATION_END, 0, 0);
|
if (current->listener) current->listener(self, index, ANIMATION_END, 0, 0);
|
||||||
if (self->listener) self->listener(self, index, ANIMATION_END, 0, 0);
|
if (self->listener) self->listener(self, index, ANIMATION_END, 0, 0);
|
||||||
|
|
||||||
entry->mixDuration = AnimationStateData_getMix(self->data, current->animation, entry->animation);
|
entry->mixDuration = spAnimationStateData_getMix(self->data, current->animation, entry->animation);
|
||||||
if (entry->mixDuration > 0) {
|
if (entry->mixDuration > 0) {
|
||||||
entry->mixTime = 0;
|
entry->mixTime = 0;
|
||||||
entry->previous = current;
|
entry->previous = current;
|
||||||
} else
|
} else
|
||||||
_TrackEntry_dispose(current);
|
_spTrackEntry_dispose(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
self->tracks[index] = entry;
|
self->tracks[index] = entry;
|
||||||
@ -220,41 +220,41 @@ void _AnimationState_setCurrent (AnimationState* self, int index, TrackEntry* en
|
|||||||
if (self->listener) self->listener(self, index, ANIMATION_START, 0, 0);
|
if (self->listener) self->listener(self, index, ANIMATION_START, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry* AnimationState_setAnimationByName (AnimationState* self, int trackIndex, const char* animationName, int/*bool*/loop) {
|
spTrackEntry* spAnimationState_setAnimationByName (spAnimationState* self, int trackIndex, const char* animationName, int/*bool*/loop) {
|
||||||
Animation* animation = SkeletonData_findAnimation(self->data->skeletonData, animationName);
|
spAnimation* animation = spSkeletonData_findAnimation(self->data->skeletonData, animationName);
|
||||||
return AnimationState_setAnimation(self, trackIndex, animation, loop);
|
return spAnimationState_setAnimation(self, trackIndex, animation, loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry* AnimationState_setAnimation (AnimationState* self, int trackIndex, Animation* animation, int/*bool*/loop) {
|
spTrackEntry* spAnimationState_setAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop) {
|
||||||
TrackEntry* entry;
|
spTrackEntry* entry;
|
||||||
TrackEntry* current = _AnimationState_expandToIndex(self, trackIndex);
|
spTrackEntry* current = _spAnimationState_expandToIndex(self, trackIndex);
|
||||||
if (current) _TrackEntry_disposeAll(current->next);
|
if (current) _spTrackEntry_disposeAll(current->next);
|
||||||
|
|
||||||
entry = _TrackEntry_create();
|
entry = _spTrackEntry_create();
|
||||||
entry->animation = animation;
|
entry->animation = animation;
|
||||||
entry->loop = loop;
|
entry->loop = loop;
|
||||||
entry->time = 0;
|
entry->time = 0;
|
||||||
entry->endTime = animation->duration;
|
entry->endTime = animation->duration;
|
||||||
_AnimationState_setCurrent(self, trackIndex, entry);
|
_spAnimationState_setCurrent(self, trackIndex, entry);
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry* AnimationState_addAnimationByName (AnimationState* self, int trackIndex, const char* animationName, int/*bool*/loop,
|
spTrackEntry* spAnimationState_addAnimationByName (spAnimationState* self, int trackIndex, const char* animationName, int/*bool*/loop,
|
||||||
float delay) {
|
float delay) {
|
||||||
Animation* animation = SkeletonData_findAnimation(self->data->skeletonData, animationName);
|
spAnimation* animation = spSkeletonData_findAnimation(self->data->skeletonData, animationName);
|
||||||
return AnimationState_addAnimation(self, trackIndex, animation, loop, delay);
|
return spAnimationState_addAnimation(self, trackIndex, animation, loop, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry* AnimationState_addAnimation (AnimationState* self, int trackIndex, Animation* animation, int/*bool*/loop, float delay) {
|
spTrackEntry* spAnimationState_addAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop, float delay) {
|
||||||
TrackEntry* last;
|
spTrackEntry* last;
|
||||||
|
|
||||||
TrackEntry* entry = _TrackEntry_create();
|
spTrackEntry* entry = _spTrackEntry_create();
|
||||||
entry->animation = animation;
|
entry->animation = animation;
|
||||||
entry->loop = loop;
|
entry->loop = loop;
|
||||||
entry->time = 0;
|
entry->time = 0;
|
||||||
entry->endTime = animation->duration;
|
entry->endTime = animation->duration;
|
||||||
|
|
||||||
last = _AnimationState_expandToIndex(self, trackIndex);
|
last = _spAnimationState_expandToIndex(self, trackIndex);
|
||||||
if (last) {
|
if (last) {
|
||||||
while (last->next)
|
while (last->next)
|
||||||
last = last->next;
|
last = last->next;
|
||||||
@ -265,7 +265,7 @@ TrackEntry* AnimationState_addAnimation (AnimationState* self, int trackIndex, A
|
|||||||
if (delay <= 0) {
|
if (delay <= 0) {
|
||||||
if (last) {
|
if (last) {
|
||||||
delay += last->endTime;
|
delay += last->endTime;
|
||||||
if (animation) delay -= AnimationStateData_getMix(self->data, last->animation, animation);
|
if (animation) delay -= spAnimationStateData_getMix(self->data, last->animation, animation);
|
||||||
} else
|
} else
|
||||||
delay = 0;
|
delay = 0;
|
||||||
}
|
}
|
||||||
@ -274,7 +274,7 @@ TrackEntry* AnimationState_addAnimation (AnimationState* self, int trackIndex, A
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry* AnimationState_getCurrent (AnimationState* self, int trackIndex) {
|
spTrackEntry* spAnimationState_getCurrent (spAnimationState* self, int trackIndex) {
|
||||||
if (trackIndex >= self->trackCount) return 0;
|
if (trackIndex >= self->trackCount) return 0;
|
||||||
return self->tracks[trackIndex];
|
return self->tracks[trackIndex];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,12 +36,12 @@
|
|||||||
|
|
||||||
typedef struct _ToEntry _ToEntry;
|
typedef struct _ToEntry _ToEntry;
|
||||||
struct _ToEntry {
|
struct _ToEntry {
|
||||||
Animation* animation;
|
spAnimation* animation;
|
||||||
float duration;
|
float duration;
|
||||||
_ToEntry* next;
|
_ToEntry* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
_ToEntry* _ToEntry_create (Animation* to, float duration) {
|
_ToEntry* _ToEntry_create (spAnimation* to, float duration) {
|
||||||
_ToEntry* self = NEW(_ToEntry);
|
_ToEntry* self = NEW(_ToEntry);
|
||||||
self->animation = to;
|
self->animation = to;
|
||||||
self->duration = duration;
|
self->duration = duration;
|
||||||
@ -56,12 +56,12 @@ void _ToEntry_dispose (_ToEntry* self) {
|
|||||||
|
|
||||||
typedef struct _FromEntry _FromEntry;
|
typedef struct _FromEntry _FromEntry;
|
||||||
struct _FromEntry {
|
struct _FromEntry {
|
||||||
Animation* animation;
|
spAnimation* animation;
|
||||||
_ToEntry* toEntries;
|
_ToEntry* toEntries;
|
||||||
_FromEntry* next;
|
_FromEntry* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
_FromEntry* _FromEntry_create (Animation* from) {
|
_FromEntry* _FromEntry_create (spAnimation* from) {
|
||||||
_FromEntry* self = NEW(_FromEntry);
|
_FromEntry* self = NEW(_FromEntry);
|
||||||
self->animation = from;
|
self->animation = from;
|
||||||
return self;
|
return self;
|
||||||
@ -73,13 +73,13 @@ void _FromEntry_dispose (_FromEntry* self) {
|
|||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
AnimationStateData* AnimationStateData_create (SkeletonData* skeletonData) {
|
spAnimationStateData* spAnimationStateData_create (spSkeletonData* skeletonData) {
|
||||||
AnimationStateData* self = NEW(AnimationStateData);
|
spAnimationStateData* self = NEW(spAnimationStateData);
|
||||||
CONST_CAST(SkeletonData*, self->skeletonData) = skeletonData;
|
CONST_CAST(spSkeletonData*, self->skeletonData) = skeletonData;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationStateData_dispose (AnimationStateData* self) {
|
void spAnimationStateData_dispose (spAnimationStateData* self) {
|
||||||
_ToEntry* toEntry;
|
_ToEntry* toEntry;
|
||||||
_ToEntry* nextToEntry;
|
_ToEntry* nextToEntry;
|
||||||
_FromEntry* nextFromEntry;
|
_FromEntry* nextFromEntry;
|
||||||
@ -100,16 +100,16 @@ void AnimationStateData_dispose (AnimationStateData* self) {
|
|||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationStateData_setMixByName (AnimationStateData* self, const char* fromName, const char* toName, float duration) {
|
void spAnimationStateData_setMixByName (spAnimationStateData* self, const char* fromName, const char* toName, float duration) {
|
||||||
Animation* to;
|
spAnimation* to;
|
||||||
Animation* from = SkeletonData_findAnimation(self->skeletonData, fromName);
|
spAnimation* from = spSkeletonData_findAnimation(self->skeletonData, fromName);
|
||||||
if (!from) return;
|
if (!from) return;
|
||||||
to = SkeletonData_findAnimation(self->skeletonData, toName);
|
to = spSkeletonData_findAnimation(self->skeletonData, toName);
|
||||||
if (!to) return;
|
if (!to) return;
|
||||||
AnimationStateData_setMix(self, from, to, duration);
|
spAnimationStateData_setMix(self, from, to, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationStateData_setMix (AnimationStateData* self, Animation* from, Animation* to, float duration) {
|
void spAnimationStateData_setMix (spAnimationStateData* self, spAnimation* from, spAnimation* to, float duration) {
|
||||||
/* Find existing FromEntry. */
|
/* Find existing FromEntry. */
|
||||||
_ToEntry* toEntry;
|
_ToEntry* toEntry;
|
||||||
_FromEntry* fromEntry = (_FromEntry*)self->entries;
|
_FromEntry* fromEntry = (_FromEntry*)self->entries;
|
||||||
@ -138,7 +138,7 @@ void AnimationStateData_setMix (AnimationStateData* self, Animation* from, Anima
|
|||||||
fromEntry->toEntries = toEntry;
|
fromEntry->toEntries = toEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AnimationStateData_getMix (AnimationStateData* self, Animation* from, Animation* to) {
|
float spAnimationStateData_getMix (spAnimationStateData* self, spAnimation* from, spAnimation* to) {
|
||||||
_FromEntry* fromEntry = (_FromEntry*)self->entries;
|
_FromEntry* fromEntry = (_FromEntry*)self->entries;
|
||||||
while (fromEntry) {
|
while (fromEntry) {
|
||||||
if (fromEntry->animation == from) {
|
if (fromEntry->animation == from) {
|
||||||
|
|||||||
@ -35,25 +35,25 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <spine/extension.h>
|
#include <spine/extension.h>
|
||||||
|
|
||||||
AtlasPage* AtlasPage_create (const char* name) {
|
spAtlasPage* spAtlasPage_create (const char* name) {
|
||||||
AtlasPage* self = NEW(AtlasPage);
|
spAtlasPage* self = NEW(spAtlasPage);
|
||||||
MALLOC_STR(self->name, name);
|
MALLOC_STR(self->name, name);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtlasPage_dispose (AtlasPage* self) {
|
void spAtlasPage_dispose (spAtlasPage* self) {
|
||||||
_AtlasPage_disposeTexture(self);
|
_spAtlasPage_disposeTexture(self);
|
||||||
FREE(self->name);
|
FREE(self->name);
|
||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
AtlasRegion* AtlasRegion_create () {
|
spAtlasRegion* spAtlasRegion_create () {
|
||||||
return NEW(AtlasRegion) ;
|
return NEW(spAtlasRegion) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtlasRegion_dispose (AtlasRegion* self) {
|
void spAtlasRegion_dispose (spAtlasRegion* self) {
|
||||||
FREE(self->name);
|
FREE(self->name);
|
||||||
FREE(self->splits);
|
FREE(self->splits);
|
||||||
FREE(self->pads);
|
FREE(self->pads);
|
||||||
@ -165,8 +165,8 @@ static int toInt (Str* str) {
|
|||||||
return strtol(str->begin, (char**)&str->end, 10);
|
return strtol(str->begin, (char**)&str->end, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Atlas* abortAtlas (Atlas* self) {
|
static spAtlas* abortAtlas (spAtlas* self) {
|
||||||
Atlas_dispose(self);
|
spAtlas_dispose(self);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,17 +174,17 @@ static const char* formatNames[] = {"Alpha", "Intensity", "LuminanceAlpha", "RGB
|
|||||||
static const char* textureFilterNames[] = {"Nearest", "Linear", "MipMap", "MipMapNearestNearest", "MipMapLinearNearest",
|
static const char* textureFilterNames[] = {"Nearest", "Linear", "MipMap", "MipMapNearestNearest", "MipMapLinearNearest",
|
||||||
"MipMapNearestLinear", "MipMapLinearLinear"};
|
"MipMapNearestLinear", "MipMapLinearLinear"};
|
||||||
|
|
||||||
Atlas* Atlas_readAtlas (const char* begin, int length, const char* dir) {
|
spAtlas* spAtlas_readAtlas (const char* begin, int length, const char* dir) {
|
||||||
int count;
|
int count;
|
||||||
const char* end = begin + length;
|
const char* end = begin + length;
|
||||||
int dirLength = strlen(dir);
|
int dirLength = strlen(dir);
|
||||||
int needsSlash = dirLength > 0 && dir[dirLength - 1] != '/' && dir[dirLength - 1] != '\\';
|
int needsSlash = dirLength > 0 && dir[dirLength - 1] != '/' && dir[dirLength - 1] != '\\';
|
||||||
|
|
||||||
Atlas* self = NEW(Atlas);
|
spAtlas* self = NEW(spAtlas);
|
||||||
|
|
||||||
AtlasPage *page = 0;
|
spAtlasPage *page = 0;
|
||||||
AtlasPage *lastPage = 0;
|
spAtlasPage *lastPage = 0;
|
||||||
AtlasRegion *lastRegion = 0;
|
spAtlasRegion *lastRegion = 0;
|
||||||
Str str;
|
Str str;
|
||||||
Str tuple[4];
|
Str tuple[4];
|
||||||
readLine(begin, 0, 0);
|
readLine(begin, 0, 0);
|
||||||
@ -198,7 +198,7 @@ Atlas* Atlas_readAtlas (const char* begin, int length, const char* dir) {
|
|||||||
if (needsSlash) path[dirLength] = '/';
|
if (needsSlash) path[dirLength] = '/';
|
||||||
strcpy(path + dirLength + needsSlash, name);
|
strcpy(path + dirLength + needsSlash, name);
|
||||||
|
|
||||||
page = AtlasPage_create(name);
|
page = spAtlasPage_create(name);
|
||||||
FREE(name);
|
FREE(name);
|
||||||
if (lastPage)
|
if (lastPage)
|
||||||
lastPage->next = page;
|
lastPage->next = page;
|
||||||
@ -207,11 +207,11 @@ Atlas* Atlas_readAtlas (const char* begin, int length, const char* dir) {
|
|||||||
lastPage = page;
|
lastPage = page;
|
||||||
|
|
||||||
if (!readValue(end, &str)) return abortAtlas(self);
|
if (!readValue(end, &str)) return abortAtlas(self);
|
||||||
page->format = (AtlasFormat)indexOf(formatNames, 7, &str);
|
page->format = (spAtlasFormat)indexOf(formatNames, 7, &str);
|
||||||
|
|
||||||
if (!readTuple(end, tuple)) return abortAtlas(self);
|
if (!readTuple(end, tuple)) return abortAtlas(self);
|
||||||
page->minFilter = (AtlasFilter)indexOf(textureFilterNames, 7, tuple);
|
page->minFilter = (spAtlasFilter)indexOf(textureFilterNames, 7, tuple);
|
||||||
page->magFilter = (AtlasFilter)indexOf(textureFilterNames, 7, tuple + 1);
|
page->magFilter = (spAtlasFilter)indexOf(textureFilterNames, 7, tuple + 1);
|
||||||
|
|
||||||
if (!readValue(end, &str)) return abortAtlas(self);
|
if (!readValue(end, &str)) return abortAtlas(self);
|
||||||
if (!equals(&str, "none")) {
|
if (!equals(&str, "none")) {
|
||||||
@ -219,10 +219,10 @@ Atlas* Atlas_readAtlas (const char* begin, int length, const char* dir) {
|
|||||||
page->vWrap = *str.begin == 'x' ? ATLAS_CLAMPTOEDGE : (*str.begin == 'y' ? ATLAS_REPEAT : ATLAS_REPEAT);
|
page->vWrap = *str.begin == 'x' ? ATLAS_CLAMPTOEDGE : (*str.begin == 'y' ? ATLAS_REPEAT : ATLAS_REPEAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
_AtlasPage_createTexture(page, path);
|
_spAtlasPage_createTexture(page, path);
|
||||||
FREE(path);
|
FREE(path);
|
||||||
} else {
|
} else {
|
||||||
AtlasRegion *region = AtlasRegion_create();
|
spAtlasRegion *region = spAtlasRegion_create();
|
||||||
if (lastRegion)
|
if (lastRegion)
|
||||||
lastRegion->next = region;
|
lastRegion->next = region;
|
||||||
else
|
else
|
||||||
@ -288,13 +288,13 @@ Atlas* Atlas_readAtlas (const char* begin, int length, const char* dir) {
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
Atlas* Atlas_readAtlasFile (const char* path) {
|
spAtlas* spAtlas_readAtlasFile (const char* path) {
|
||||||
int dirLength;
|
int dirLength;
|
||||||
char *dir;
|
char *dir;
|
||||||
int length;
|
int length;
|
||||||
const char* data;
|
const char* data;
|
||||||
|
|
||||||
Atlas* atlas = 0;
|
spAtlas* atlas = 0;
|
||||||
|
|
||||||
/* Get directory from atlas path. */
|
/* Get directory from atlas path. */
|
||||||
const char* lastForwardSlash = strrchr(path, '/');
|
const char* lastForwardSlash = strrchr(path, '/');
|
||||||
@ -306,35 +306,35 @@ Atlas* Atlas_readAtlasFile (const char* path) {
|
|||||||
memcpy(dir, path, dirLength);
|
memcpy(dir, path, dirLength);
|
||||||
dir[dirLength] = '\0';
|
dir[dirLength] = '\0';
|
||||||
|
|
||||||
data = _Util_readFile(path, &length);
|
data = _spUtil_readFile(path, &length);
|
||||||
if (data) atlas = Atlas_readAtlas(data, length, dir);
|
if (data) atlas = spAtlas_readAtlas(data, length, dir);
|
||||||
|
|
||||||
FREE(data);
|
FREE(data);
|
||||||
FREE(dir);
|
FREE(dir);
|
||||||
return atlas;
|
return atlas;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Atlas_dispose (Atlas* self) {
|
void spAtlas_dispose (spAtlas* self) {
|
||||||
AtlasRegion* region, *nextRegion;
|
spAtlasRegion* region, *nextRegion;
|
||||||
AtlasPage* page = self->pages;
|
spAtlasPage* page = self->pages;
|
||||||
while (page) {
|
while (page) {
|
||||||
AtlasPage* nextPage = page->next;
|
spAtlasPage* nextPage = page->next;
|
||||||
AtlasPage_dispose(page);
|
spAtlasPage_dispose(page);
|
||||||
page = nextPage;
|
page = nextPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
region = self->regions;
|
region = self->regions;
|
||||||
while (region) {
|
while (region) {
|
||||||
nextRegion = region->next;
|
nextRegion = region->next;
|
||||||
AtlasRegion_dispose(region);
|
spAtlasRegion_dispose(region);
|
||||||
region = nextRegion;
|
region = nextRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
AtlasRegion* Atlas_findRegion (const Atlas* self, const char* name) {
|
spAtlasRegion* spAtlas_findRegion (const spAtlas* self, const char* name) {
|
||||||
AtlasRegion* region = self->regions;
|
spAtlasRegion* region = self->regions;
|
||||||
while (region) {
|
while (region) {
|
||||||
if (strcmp(region->name, name) == 0) return region;
|
if (strcmp(region->name, name) == 0) return region;
|
||||||
region = region->next;
|
region = region->next;
|
||||||
|
|||||||
@ -34,19 +34,20 @@
|
|||||||
#include <spine/AtlasAttachmentLoader.h>
|
#include <spine/AtlasAttachmentLoader.h>
|
||||||
#include <spine/extension.h>
|
#include <spine/extension.h>
|
||||||
|
|
||||||
Attachment* _AtlasAttachmentLoader_newAttachment (AttachmentLoader* loader, Skin* skin, AttachmentType type, const char* name) {
|
spAttachment* _spAtlasAttachmentLoader_newAttachment (spAttachmentLoader* loader, spSkin* skin, spAttachmentType type,
|
||||||
AtlasAttachmentLoader* self = SUB_CAST(AtlasAttachmentLoader, loader);
|
const char* name) {
|
||||||
|
spAtlasAttachmentLoader* self = SUB_CAST(spAtlasAttachmentLoader, loader);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ATTACHMENT_REGION: {
|
case ATTACHMENT_REGION: {
|
||||||
RegionAttachment* attachment;
|
spRegionAttachment* attachment;
|
||||||
AtlasRegion* region = Atlas_findRegion(self->atlas, name);
|
spAtlasRegion* region = spAtlas_findRegion(self->atlas, name);
|
||||||
if (!region) {
|
if (!region) {
|
||||||
_AttachmentLoader_setError(loader, "Region not found: ", name);
|
_spAttachmentLoader_setError(loader, "Region not found: ", name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
attachment = RegionAttachment_create(name);
|
attachment = spRegionAttachment_create(name);
|
||||||
attachment->rendererObject = region;
|
attachment->rendererObject = region;
|
||||||
RegionAttachment_setUVs(attachment, region->u, region->v, region->u2, region->v2, region->rotate);
|
spRegionAttachment_setUVs(attachment, region->u, region->v, region->u2, region->v2, region->rotate);
|
||||||
attachment->regionOffsetX = region->offsetX;
|
attachment->regionOffsetX = region->offsetX;
|
||||||
attachment->regionOffsetY = region->offsetY;
|
attachment->regionOffsetY = region->offsetY;
|
||||||
attachment->regionWidth = region->width;
|
attachment->regionWidth = region->width;
|
||||||
@ -56,16 +57,16 @@ Attachment* _AtlasAttachmentLoader_newAttachment (AttachmentLoader* loader, Skin
|
|||||||
return SUPER(attachment);
|
return SUPER(attachment);
|
||||||
}
|
}
|
||||||
case ATTACHMENT_BOUNDING_BOX:
|
case ATTACHMENT_BOUNDING_BOX:
|
||||||
return SUPER(BoundingBoxAttachment_create(name));
|
return SUPER(spBoundingBoxAttachment_create(name));
|
||||||
default:
|
default:
|
||||||
_AttachmentLoader_setUnknownTypeError(loader, type);
|
_spAttachmentLoader_setUnknownTypeError(loader, type);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AtlasAttachmentLoader* AtlasAttachmentLoader_create (Atlas* atlas) {
|
spAtlasAttachmentLoader* spAtlasAttachmentLoader_create (spAtlas* atlas) {
|
||||||
AtlasAttachmentLoader* self = NEW(AtlasAttachmentLoader);
|
spAtlasAttachmentLoader* self = NEW(spAtlasAttachmentLoader);
|
||||||
_AttachmentLoader_init(SUPER(self), _AttachmentLoader_deinit, _AtlasAttachmentLoader_newAttachment);
|
_spAttachmentLoader_init(SUPER(self), _spAttachmentLoader_deinit, _spAtlasAttachmentLoader_newAttachment);
|
||||||
self->atlas = atlas;
|
self->atlas = atlas;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,26 +35,26 @@
|
|||||||
#include <spine/extension.h>
|
#include <spine/extension.h>
|
||||||
#include <spine/Slot.h>
|
#include <spine/Slot.h>
|
||||||
|
|
||||||
typedef struct _AttachmentVtable {
|
typedef struct _spAttachmentVtable {
|
||||||
void (*dispose) (Attachment* self);
|
void (*dispose) (spAttachment* self);
|
||||||
} _AttachmentVtable;
|
} _spAttachmentVtable;
|
||||||
|
|
||||||
void _Attachment_init (Attachment* self, const char* name, AttachmentType type, /**/
|
void _spAttachment_init (spAttachment* self, const char* name, spAttachmentType type, /**/
|
||||||
void (*dispose) (Attachment* self)) {
|
void (*dispose) (spAttachment* self)) {
|
||||||
|
|
||||||
CONST_CAST(_AttachmentVtable*, self->vtable) = NEW(_AttachmentVtable);
|
CONST_CAST(_spAttachmentVtable*, self->vtable) = NEW(_spAttachmentVtable);
|
||||||
VTABLE(Attachment, self) ->dispose = dispose;
|
VTABLE(spAttachment, self) ->dispose = dispose;
|
||||||
|
|
||||||
MALLOC_STR(self->name, name);
|
MALLOC_STR(self->name, name);
|
||||||
self->type = type;
|
self->type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _Attachment_deinit (Attachment* self) {
|
void _spAttachment_deinit (spAttachment* self) {
|
||||||
FREE(self->vtable);
|
FREE(self->vtable);
|
||||||
FREE(self->name);
|
FREE(self->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Attachment_dispose (Attachment* self) {
|
void spAttachment_dispose (spAttachment* self) {
|
||||||
VTABLE(Attachment, self) ->dispose(self);
|
VTABLE(spAttachment, self) ->dispose(self);
|
||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,47 +35,47 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <spine/extension.h>
|
#include <spine/extension.h>
|
||||||
|
|
||||||
typedef struct _AttachmentLoaderVtable {
|
typedef struct _spAttachmentLoaderVtable {
|
||||||
Attachment* (*newAttachment) (AttachmentLoader* self, Skin* skin, AttachmentType type, const char* name);
|
spAttachment* (*newAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name);
|
||||||
void (*dispose) (AttachmentLoader* self);
|
void (*dispose) (spAttachmentLoader* self);
|
||||||
} _AttachmentLoaderVtable;
|
} _spAttachmentLoaderVtable;
|
||||||
|
|
||||||
void _AttachmentLoader_init (AttachmentLoader* self, /**/
|
void _spAttachmentLoader_init (spAttachmentLoader* self, /**/
|
||||||
void (*dispose) (AttachmentLoader* self), /**/
|
void (*dispose) (spAttachmentLoader* self), /**/
|
||||||
Attachment* (*newAttachment) (AttachmentLoader* self, Skin* skin, AttachmentType type, const char* name)) {
|
spAttachment* (*newAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name)) {
|
||||||
CONST_CAST(_AttachmentLoaderVtable*, self->vtable) = NEW(_AttachmentLoaderVtable);
|
CONST_CAST(_spAttachmentLoaderVtable*, self->vtable) = NEW(_spAttachmentLoaderVtable);
|
||||||
VTABLE(AttachmentLoader, self) ->dispose = dispose;
|
VTABLE(spAttachmentLoader, self)->dispose = dispose;
|
||||||
VTABLE(AttachmentLoader, self) ->newAttachment = newAttachment;
|
VTABLE(spAttachmentLoader, self)->newAttachment = newAttachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _AttachmentLoader_deinit (AttachmentLoader* self) {
|
void _spAttachmentLoader_deinit (spAttachmentLoader* self) {
|
||||||
FREE(self->vtable);
|
FREE(self->vtable);
|
||||||
FREE(self->error1);
|
FREE(self->error1);
|
||||||
FREE(self->error2);
|
FREE(self->error2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttachmentLoader_dispose (AttachmentLoader* self) {
|
void spAttachmentLoader_dispose (spAttachmentLoader* self) {
|
||||||
VTABLE(AttachmentLoader, self) ->dispose(self);
|
VTABLE(spAttachmentLoader, self)->dispose(self);
|
||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
Attachment* AttachmentLoader_newAttachment (AttachmentLoader* self, Skin* skin, AttachmentType type, const char* name) {
|
spAttachment* spAttachmentLoader_newAttachment (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name) {
|
||||||
FREE(self->error1);
|
FREE(self->error1);
|
||||||
FREE(self->error2);
|
FREE(self->error2);
|
||||||
self->error1 = 0;
|
self->error1 = 0;
|
||||||
self->error2 = 0;
|
self->error2 = 0;
|
||||||
return VTABLE(AttachmentLoader, self) ->newAttachment(self, skin, type, name);
|
return VTABLE(spAttachmentLoader, self)->newAttachment(self, skin, type, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _AttachmentLoader_setError (AttachmentLoader* self, const char* error1, const char* error2) {
|
void _spAttachmentLoader_setError (spAttachmentLoader* self, const char* error1, const char* error2) {
|
||||||
FREE(self->error1);
|
FREE(self->error1);
|
||||||
FREE(self->error2);
|
FREE(self->error2);
|
||||||
MALLOC_STR(self->error1, error1);
|
MALLOC_STR(self->error1, error1);
|
||||||
MALLOC_STR(self->error2, error2);
|
MALLOC_STR(self->error2, error2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _AttachmentLoader_setUnknownTypeError (AttachmentLoader* self, AttachmentType type) {
|
void _spAttachmentLoader_setUnknownTypeError (spAttachmentLoader* self, spAttachmentType type) {
|
||||||
char buffer[16];
|
char buffer[16];
|
||||||
sprintf(buffer, "%d", type);
|
sprintf(buffer, "%d", type);
|
||||||
_AttachmentLoader_setError(self, "Unknown attachment type: ", buffer);
|
_spAttachmentLoader_setError(self, "Unknown attachment type: ", buffer);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,23 +36,23 @@
|
|||||||
|
|
||||||
static int yDown;
|
static int yDown;
|
||||||
|
|
||||||
void Bone_setYDown (int value) {
|
void spBone_setYDown (int value) {
|
||||||
yDown = value;
|
yDown = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bone* Bone_create (BoneData* data, Bone* parent) {
|
spBone* spBone_create (spBoneData* data, spBone* parent) {
|
||||||
Bone* self = NEW(Bone);
|
spBone* self = NEW(spBone);
|
||||||
CONST_CAST(BoneData*, self->data) = data;
|
CONST_CAST(spBoneData*, self->data) = data;
|
||||||
CONST_CAST(Bone*, self->parent) = parent;
|
CONST_CAST(spBone*, self->parent) = parent;
|
||||||
Bone_setToSetupPose(self);
|
spBone_setToSetupPose(self);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bone_dispose (Bone* self) {
|
void spBone_dispose (spBone* self) {
|
||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bone_setToSetupPose (Bone* self) {
|
void spBone_setToSetupPose (spBone* self) {
|
||||||
self->x = self->data->x;
|
self->x = self->data->x;
|
||||||
self->y = self->data->y;
|
self->y = self->data->y;
|
||||||
self->rotation = self->data->rotation;
|
self->rotation = self->data->rotation;
|
||||||
@ -60,7 +60,7 @@ void Bone_setToSetupPose (Bone* self) {
|
|||||||
self->scaleY = self->data->scaleY;
|
self->scaleY = self->data->scaleY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bone_updateWorldTransform (Bone* self, int flipX, int flipY) {
|
void spBone_updateWorldTransform (spBone* self, int flipX, int flipY) {
|
||||||
float radians, cosine, sine;
|
float radians, cosine, sine;
|
||||||
if (self->parent) {
|
if (self->parent) {
|
||||||
CONST_CAST(float, self->worldX) = self->x * self->parent->m00 + self->y * self->parent->m01 + self->parent->worldX;
|
CONST_CAST(float, self->worldX) = self->x * self->parent->m00 + self->y * self->parent->m01 + self->parent->worldX;
|
||||||
|
|||||||
@ -34,10 +34,10 @@
|
|||||||
#include <spine/BoneData.h>
|
#include <spine/BoneData.h>
|
||||||
#include <spine/extension.h>
|
#include <spine/extension.h>
|
||||||
|
|
||||||
BoneData* BoneData_create (const char* name, BoneData* parent) {
|
spBoneData* spBoneData_create (const char* name, spBoneData* parent) {
|
||||||
BoneData* self = NEW(BoneData);
|
spBoneData* self = NEW(spBoneData);
|
||||||
MALLOC_STR(self->name, name);
|
MALLOC_STR(self->name, name);
|
||||||
CONST_CAST(BoneData*, self->parent) = parent;
|
CONST_CAST(spBoneData*, self->parent) = parent;
|
||||||
self->scaleX = 1;
|
self->scaleX = 1;
|
||||||
self->scaleY = 1;
|
self->scaleY = 1;
|
||||||
self->inheritScale = 1;
|
self->inheritScale = 1;
|
||||||
@ -45,7 +45,7 @@ BoneData* BoneData_create (const char* name, BoneData* parent) {
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoneData_dispose (BoneData* self) {
|
void spBoneData_dispose (spBoneData* self) {
|
||||||
FREE(self->name);
|
FREE(self->name);
|
||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,13 +34,13 @@
|
|||||||
#include <spine/BoundingBoxAttachment.h>
|
#include <spine/BoundingBoxAttachment.h>
|
||||||
#include <spine/extension.h>
|
#include <spine/extension.h>
|
||||||
|
|
||||||
BoundingBoxAttachment* BoundingBoxAttachment_create (const char* name) {
|
spBoundingBoxAttachment* spBoundingBoxAttachment_create (const char* name) {
|
||||||
BoundingBoxAttachment* self = NEW(BoundingBoxAttachment);
|
spBoundingBoxAttachment* self = NEW(spBoundingBoxAttachment);
|
||||||
_Attachment_init(SUPER(self), name, ATTACHMENT_BOUNDING_BOX, _Attachment_deinit);
|
_spAttachment_init(SUPER(self), name, ATTACHMENT_BOUNDING_BOX, _spAttachment_deinit);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundingBoxAttachment_computeWorldVertices (BoundingBoxAttachment* self, float x, float y, Bone* bone, float* worldVertices) {
|
void spBoundingBoxAttachment_computeWorldVertices (spBoundingBoxAttachment* self, float x, float y, spBone* bone, float* worldVertices) {
|
||||||
int i;
|
int i;
|
||||||
float px, py;
|
float px, py;
|
||||||
float* vertices = self->vertices;
|
float* vertices = self->vertices;
|
||||||
|
|||||||
@ -34,13 +34,13 @@
|
|||||||
#include <spine/Event.h>
|
#include <spine/Event.h>
|
||||||
#include <spine/extension.h>
|
#include <spine/extension.h>
|
||||||
|
|
||||||
Event* Event_create (EventData* data) {
|
spEvent* spEvent_create (spEventData* data) {
|
||||||
Event* self = NEW(Event);
|
spEvent* self = NEW(spEvent);
|
||||||
CONST_CAST(EventData*, self->data) = data;
|
CONST_CAST(spEventData*, self->data) = data;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Event_dispose (Event* self) {
|
void spEvent_dispose (spEvent* self) {
|
||||||
FREE(self->stringValue);
|
FREE(self->stringValue);
|
||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,13 +34,13 @@
|
|||||||
#include <spine/EventData.h>
|
#include <spine/EventData.h>
|
||||||
#include <spine/extension.h>
|
#include <spine/extension.h>
|
||||||
|
|
||||||
EventData* EventData_create (const char* name) {
|
spEventData* spEventData_create (const char* name) {
|
||||||
EventData* self = NEW(EventData);
|
spEventData* self = NEW(spEventData);
|
||||||
MALLOC_STR(self->name, name);
|
MALLOC_STR(self->name, name);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventData_dispose (EventData* self) {
|
void spEventData_dispose (spEventData* self) {
|
||||||
FREE(self->stringValue);
|
FREE(self->stringValue);
|
||||||
FREE(self->name);
|
FREE(self->name);
|
||||||
FREE(self);
|
FREE(self);
|
||||||
|
|||||||
@ -34,15 +34,15 @@
|
|||||||
#include <spine/RegionAttachment.h>
|
#include <spine/RegionAttachment.h>
|
||||||
#include <spine/extension.h>
|
#include <spine/extension.h>
|
||||||
|
|
||||||
RegionAttachment* RegionAttachment_create (const char* name) {
|
spRegionAttachment* spRegionAttachment_create (const char* name) {
|
||||||
RegionAttachment* self = NEW(RegionAttachment);
|
spRegionAttachment* self = NEW(spRegionAttachment);
|
||||||
self->scaleX = 1;
|
self->scaleX = 1;
|
||||||
self->scaleY = 1;
|
self->scaleY = 1;
|
||||||
_Attachment_init(SUPER(self), name, ATTACHMENT_REGION, _Attachment_deinit);
|
_spAttachment_init(SUPER(self), name, ATTACHMENT_REGION, _spAttachment_deinit);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionAttachment_setUVs (RegionAttachment* self, float u, float v, float u2, float v2, int/*bool*/rotate) {
|
void spRegionAttachment_setUVs (spRegionAttachment* self, float u, float v, float u2, float v2, int/*bool*/rotate) {
|
||||||
if (rotate) {
|
if (rotate) {
|
||||||
self->uvs[VERTEX_X2] = u;
|
self->uvs[VERTEX_X2] = u;
|
||||||
self->uvs[VERTEX_Y2] = v2;
|
self->uvs[VERTEX_Y2] = v2;
|
||||||
@ -64,7 +64,7 @@ void RegionAttachment_setUVs (RegionAttachment* self, float u, float v, float u2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionAttachment_updateOffset (RegionAttachment* self) {
|
void spRegionAttachment_updateOffset (spRegionAttachment* self) {
|
||||||
float regionScaleX = self->width / self->regionOriginalWidth * self->scaleX;
|
float regionScaleX = self->width / self->regionOriginalWidth * self->scaleX;
|
||||||
float regionScaleY = self->height / self->regionOriginalHeight * self->scaleY;
|
float regionScaleY = self->height / self->regionOriginalHeight * self->scaleY;
|
||||||
float localX = -self->width / 2 * self->scaleX + self->regionOffsetX * regionScaleX;
|
float localX = -self->width / 2 * self->scaleX + self->regionOffsetX * regionScaleX;
|
||||||
@ -97,7 +97,7 @@ void RegionAttachment_updateOffset (RegionAttachment* self) {
|
|||||||
self->offset[VERTEX_Y4] = localYCos + localX2Sin;
|
self->offset[VERTEX_Y4] = localYCos + localX2Sin;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionAttachment_computeWorldVertices (RegionAttachment* self, float x, float y, Bone* bone, float* vertices) {
|
void spRegionAttachment_computeWorldVertices (spRegionAttachment* self, float x, float y, spBone* bone, float* vertices) {
|
||||||
float* offset = self->offset;
|
float* offset = self->offset;
|
||||||
x += bone->worldX;
|
x += bone->worldX;
|
||||||
y += bone->worldY;
|
y += bone->worldY;
|
||||||
|
|||||||
@ -35,18 +35,18 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <spine/extension.h>
|
#include <spine/extension.h>
|
||||||
|
|
||||||
Skeleton* Skeleton_create (SkeletonData* data) {
|
spSkeleton* spSkeleton_create (spSkeletonData* data) {
|
||||||
int i, ii;
|
int i, ii;
|
||||||
|
|
||||||
Skeleton* self = NEW(Skeleton);
|
spSkeleton* self = NEW(spSkeleton);
|
||||||
CONST_CAST(SkeletonData*, self->data) = data;
|
CONST_CAST(spSkeletonData*, self->data) = data;
|
||||||
|
|
||||||
self->boneCount = self->data->boneCount;
|
self->boneCount = self->data->boneCount;
|
||||||
self->bones = MALLOC(Bone*, self->boneCount);
|
self->bones = MALLOC(spBone*, self->boneCount);
|
||||||
|
|
||||||
for (i = 0; i < self->boneCount; ++i) {
|
for (i = 0; i < self->boneCount; ++i) {
|
||||||
BoneData* boneData = self->data->bones[i];
|
spBoneData* boneData = self->data->bones[i];
|
||||||
Bone* parent = 0;
|
spBone* parent = 0;
|
||||||
if (boneData->parent) {
|
if (boneData->parent) {
|
||||||
/* Find parent bone. */
|
/* Find parent bone. */
|
||||||
for (ii = 0; ii < self->boneCount; ++ii) {
|
for (ii = 0; ii < self->boneCount; ++ii) {
|
||||||
@ -56,28 +56,28 @@ Skeleton* Skeleton_create (SkeletonData* data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self->bones[i] = Bone_create(boneData, parent);
|
self->bones[i] = spBone_create(boneData, parent);
|
||||||
}
|
}
|
||||||
CONST_CAST(Bone*, self->root) = self->bones[0];
|
CONST_CAST(spBone*, self->root) = self->bones[0];
|
||||||
|
|
||||||
self->slotCount = data->slotCount;
|
self->slotCount = data->slotCount;
|
||||||
self->slots = MALLOC(Slot*, self->slotCount);
|
self->slots = MALLOC(spSlot*, self->slotCount);
|
||||||
for (i = 0; i < self->slotCount; ++i) {
|
for (i = 0; i < self->slotCount; ++i) {
|
||||||
SlotData *slotData = data->slots[i];
|
spSlotData *slotData = data->slots[i];
|
||||||
|
|
||||||
/* Find bone for the slotData's boneData. */
|
/* Find bone for the slotData's boneData. */
|
||||||
Bone* bone = 0;
|
spBone* bone = 0;
|
||||||
for (ii = 0; ii < self->boneCount; ++ii) {
|
for (ii = 0; ii < self->boneCount; ++ii) {
|
||||||
if (data->bones[ii] == slotData->boneData) {
|
if (data->bones[ii] == slotData->boneData) {
|
||||||
bone = self->bones[ii];
|
bone = self->bones[ii];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self->slots[i] = Slot_create(slotData, self, bone);
|
self->slots[i] = spSlot_create(slotData, self, bone);
|
||||||
}
|
}
|
||||||
|
|
||||||
self->drawOrder = MALLOC(Slot*, self->slotCount);
|
self->drawOrder = MALLOC(spSlot*, self->slotCount);
|
||||||
memcpy(self->drawOrder, self->slots, sizeof(Slot*) * self->slotCount);
|
memcpy(self->drawOrder, self->slots, sizeof(spSlot*) * self->slotCount);
|
||||||
|
|
||||||
self->r = 1;
|
self->r = 1;
|
||||||
self->g = 1;
|
self->g = 1;
|
||||||
@ -87,118 +87,118 @@ Skeleton* Skeleton_create (SkeletonData* data) {
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton_dispose (Skeleton* self) {
|
void spSkeleton_dispose (spSkeleton* self) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->boneCount; ++i)
|
for (i = 0; i < self->boneCount; ++i)
|
||||||
Bone_dispose(self->bones[i]);
|
spBone_dispose(self->bones[i]);
|
||||||
FREE(self->bones);
|
FREE(self->bones);
|
||||||
|
|
||||||
for (i = 0; i < self->slotCount; ++i)
|
for (i = 0; i < self->slotCount; ++i)
|
||||||
Slot_dispose(self->slots[i]);
|
spSlot_dispose(self->slots[i]);
|
||||||
FREE(self->slots);
|
FREE(self->slots);
|
||||||
|
|
||||||
FREE(self->drawOrder);
|
FREE(self->drawOrder);
|
||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton_updateWorldTransform (const Skeleton* self) {
|
void spSkeleton_updateWorldTransform (const spSkeleton* self) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->boneCount; ++i)
|
for (i = 0; i < self->boneCount; ++i)
|
||||||
Bone_updateWorldTransform(self->bones[i], self->flipX, self->flipY);
|
spBone_updateWorldTransform(self->bones[i], self->flipX, self->flipY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton_setToSetupPose (const Skeleton* self) {
|
void spSkeleton_setToSetupPose (const spSkeleton* self) {
|
||||||
Skeleton_setBonesToSetupPose(self);
|
spSkeleton_setBonesToSetupPose(self);
|
||||||
Skeleton_setSlotsToSetupPose(self);
|
spSkeleton_setSlotsToSetupPose(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton_setBonesToSetupPose (const Skeleton* self) {
|
void spSkeleton_setBonesToSetupPose (const spSkeleton* self) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->boneCount; ++i)
|
for (i = 0; i < self->boneCount; ++i)
|
||||||
Bone_setToSetupPose(self->bones[i]);
|
spBone_setToSetupPose(self->bones[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton_setSlotsToSetupPose (const Skeleton* self) {
|
void spSkeleton_setSlotsToSetupPose (const spSkeleton* self) {
|
||||||
int i;
|
int i;
|
||||||
memcpy(self->drawOrder, self->slots, self->slotCount * sizeof(int));
|
memcpy(self->drawOrder, self->slots, self->slotCount * sizeof(int));
|
||||||
for (i = 0; i < self->slotCount; ++i)
|
for (i = 0; i < self->slotCount; ++i)
|
||||||
Slot_setToSetupPose(self->slots[i]);
|
spSlot_setToSetupPose(self->slots[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bone* Skeleton_findBone (const Skeleton* self, const char* boneName) {
|
spBone* spSkeleton_findBone (const spSkeleton* self, const char* boneName) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->boneCount; ++i)
|
for (i = 0; i < self->boneCount; ++i)
|
||||||
if (strcmp(self->data->bones[i]->name, boneName) == 0) return self->bones[i];
|
if (strcmp(self->data->bones[i]->name, boneName) == 0) return self->bones[i];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Skeleton_findBoneIndex (const Skeleton* self, const char* boneName) {
|
int spSkeleton_findBoneIndex (const spSkeleton* self, const char* boneName) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->boneCount; ++i)
|
for (i = 0; i < self->boneCount; ++i)
|
||||||
if (strcmp(self->data->bones[i]->name, boneName) == 0) return i;
|
if (strcmp(self->data->bones[i]->name, boneName) == 0) return i;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Slot* Skeleton_findSlot (const Skeleton* self, const char* slotName) {
|
spSlot* spSkeleton_findSlot (const spSkeleton* self, const char* slotName) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->slotCount; ++i)
|
for (i = 0; i < self->slotCount; ++i)
|
||||||
if (strcmp(self->data->slots[i]->name, slotName) == 0) return self->slots[i];
|
if (strcmp(self->data->slots[i]->name, slotName) == 0) return self->slots[i];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Skeleton_findSlotIndex (const Skeleton* self, const char* slotName) {
|
int spSkeleton_findSlotIndex (const spSkeleton* self, const char* slotName) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->slotCount; ++i)
|
for (i = 0; i < self->slotCount; ++i)
|
||||||
if (strcmp(self->data->slots[i]->name, slotName) == 0) return i;
|
if (strcmp(self->data->slots[i]->name, slotName) == 0) return i;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Skeleton_setSkinByName (Skeleton* self, const char* skinName) {
|
int spSkeleton_setSkinByName (spSkeleton* self, const char* skinName) {
|
||||||
Skin *skin;
|
spSkin *skin;
|
||||||
if (!skinName) {
|
if (!skinName) {
|
||||||
Skeleton_setSkin(self, 0);
|
spSkeleton_setSkin(self, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
skin = SkeletonData_findSkin(self->data, skinName);
|
skin = spSkeletonData_findSkin(self->data, skinName);
|
||||||
if (!skin) return 0;
|
if (!skin) return 0;
|
||||||
Skeleton_setSkin(self, skin);
|
spSkeleton_setSkin(self, skin);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton_setSkin (Skeleton* self, Skin* newSkin) {
|
void spSkeleton_setSkin (spSkeleton* self, spSkin* newSkin) {
|
||||||
if (self->skin && newSkin) Skin_attachAll(newSkin, self, self->skin);
|
if (self->skin && newSkin) spSkin_attachAll(newSkin, self, self->skin);
|
||||||
CONST_CAST(Skin*, self->skin) = newSkin;
|
CONST_CAST(spSkin*, self->skin) = newSkin;
|
||||||
}
|
}
|
||||||
|
|
||||||
Attachment* Skeleton_getAttachmentForSlotName (const Skeleton* self, const char* slotName, const char* attachmentName) {
|
spAttachment* spSkeleton_getAttachmentForSlotName (const spSkeleton* self, const char* slotName, const char* attachmentName) {
|
||||||
int slotIndex = SkeletonData_findSlotIndex(self->data, slotName);
|
int slotIndex = spSkeletonData_findSlotIndex(self->data, slotName);
|
||||||
return Skeleton_getAttachmentForSlotIndex(self, slotIndex, attachmentName);
|
return spSkeleton_getAttachmentForSlotIndex(self, slotIndex, attachmentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Attachment* Skeleton_getAttachmentForSlotIndex (const Skeleton* self, int slotIndex, const char* attachmentName) {
|
spAttachment* spSkeleton_getAttachmentForSlotIndex (const spSkeleton* self, int slotIndex, const char* attachmentName) {
|
||||||
if (slotIndex == -1) return 0;
|
if (slotIndex == -1) return 0;
|
||||||
if (self->skin) {
|
if (self->skin) {
|
||||||
Attachment *attachment = Skin_getAttachment(self->skin, slotIndex, attachmentName);
|
spAttachment *attachment = spSkin_getAttachment(self->skin, slotIndex, attachmentName);
|
||||||
if (attachment) return attachment;
|
if (attachment) return attachment;
|
||||||
}
|
}
|
||||||
if (self->data->defaultSkin) {
|
if (self->data->defaultSkin) {
|
||||||
Attachment *attachment = Skin_getAttachment(self->data->defaultSkin, slotIndex, attachmentName);
|
spAttachment *attachment = spSkin_getAttachment(self->data->defaultSkin, slotIndex, attachmentName);
|
||||||
if (attachment) return attachment;
|
if (attachment) return attachment;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Skeleton_setAttachment (Skeleton* self, const char* slotName, const char* attachmentName) {
|
int spSkeleton_setAttachment (spSkeleton* self, const char* slotName, const char* attachmentName) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->slotCount; ++i) {
|
for (i = 0; i < self->slotCount; ++i) {
|
||||||
Slot *slot = self->slots[i];
|
spSlot *slot = self->slots[i];
|
||||||
if (strcmp(slot->data->name, slotName) == 0) {
|
if (strcmp(slot->data->name, slotName) == 0) {
|
||||||
if (!attachmentName)
|
if (!attachmentName)
|
||||||
Slot_setAttachment(slot, 0);
|
spSlot_setAttachment(slot, 0);
|
||||||
else {
|
else {
|
||||||
Attachment* attachment = Skeleton_getAttachmentForSlotIndex(self, i, attachmentName);
|
spAttachment* attachment = spSkeleton_getAttachmentForSlotIndex(self, i, attachmentName);
|
||||||
if (!attachment) return 0;
|
if (!attachment) return 0;
|
||||||
Slot_setAttachment(slot, attachment);
|
spSlot_setAttachment(slot, attachment);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -206,6 +206,6 @@ int Skeleton_setAttachment (Skeleton* self, const char* slotName, const char* at
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton_update (Skeleton* self, float deltaTime) {
|
void spSkeleton_update (spSkeleton* self, float deltaTime) {
|
||||||
self->time += deltaTime;
|
self->time += deltaTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,19 +35,19 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <spine/extension.h>
|
#include <spine/extension.h>
|
||||||
|
|
||||||
BoundingPolygon* BoundingPolygon_create (int capacity) {
|
spBoundingPolygon* spBoundingPolygon_create (int capacity) {
|
||||||
BoundingPolygon* self = NEW(BoundingPolygon);
|
spBoundingPolygon* self = NEW(spBoundingPolygon);
|
||||||
self->capacity = capacity;
|
self->capacity = capacity;
|
||||||
CONST_CAST(float*, self->vertices) = MALLOC(float, capacity);
|
CONST_CAST(float*, self->vertices) = MALLOC(float, capacity);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundingPolygon_dispose (BoundingPolygon* self) {
|
void spBoundingPolygon_dispose (spBoundingPolygon* self) {
|
||||||
FREE(self->vertices);
|
FREE(self->vertices);
|
||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
int/*bool*/BoundingPolygon_containsPoint (BoundingPolygon* self, float x, float y) {
|
int/*bool*/spBoundingPolygon_containsPoint (spBoundingPolygon* self, float x, float y) {
|
||||||
int prevIndex = self->count - 2;
|
int prevIndex = self->count - 2;
|
||||||
int inside = 0;
|
int inside = 0;
|
||||||
int i;
|
int i;
|
||||||
@ -63,7 +63,7 @@ int/*bool*/BoundingPolygon_containsPoint (BoundingPolygon* self, float x, float
|
|||||||
return inside;
|
return inside;
|
||||||
}
|
}
|
||||||
|
|
||||||
int/*bool*/BoundingPolygon_intersectsSegment (BoundingPolygon* self, float x1, float y1, float x2, float y2) {
|
int/*bool*/spBoundingPolygon_intersectsSegment (spBoundingPolygon* self, float x1, float y1, float x2, float y2) {
|
||||||
float width12 = x1 - x2, height12 = y1 - y2;
|
float width12 = x1 - x2, height12 = y1 - y2;
|
||||||
float det1 = x1 * y2 - y1 * x2;
|
float det1 = x1 * y2 - y1 * x2;
|
||||||
float x3 = self->vertices[self->count - 2], y3 = self->vertices[self->count - 1];
|
float x3 = self->vertices[self->count - 2], y3 = self->vertices[self->count - 1];
|
||||||
@ -87,34 +87,34 @@ int/*bool*/BoundingPolygon_intersectsSegment (BoundingPolygon* self, float x1, f
|
|||||||
/**/
|
/**/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SkeletonBounds super;
|
spSkeletonBounds super;
|
||||||
int capacity;
|
int capacity;
|
||||||
} _SkeletonBounds;
|
} _spSkeletonBounds;
|
||||||
|
|
||||||
SkeletonBounds* SkeletonBounds_create () {
|
spSkeletonBounds* spSkeletonBounds_create () {
|
||||||
return SUPER(NEW(_SkeletonBounds));
|
return SUPER(NEW(_spSkeletonBounds));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonBounds_dispose (SkeletonBounds* self) {
|
void spSkeletonBounds_dispose (spSkeletonBounds* self) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < SUB_CAST(_SkeletonBounds, self)->capacity; ++i)
|
for (i = 0; i < SUB_CAST(_spSkeletonBounds, self)->capacity; ++i)
|
||||||
if (self->polygons[i]) BoundingPolygon_dispose(self->polygons[i]);
|
if (self->polygons[i]) spBoundingPolygon_dispose(self->polygons[i]);
|
||||||
FREE(self->polygons);
|
FREE(self->polygons);
|
||||||
FREE(self->boundingBoxes);
|
FREE(self->boundingBoxes);
|
||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonBounds_update (SkeletonBounds* self, Skeleton* skeleton, int/*bool*/updateAabb) {
|
void spSkeletonBounds_update (spSkeletonBounds* self, spSkeleton* skeleton, int/*bool*/updateAabb) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
_SkeletonBounds* internal = SUB_CAST(_SkeletonBounds, self);
|
_spSkeletonBounds* internal = SUB_CAST(_spSkeletonBounds, self);
|
||||||
if (internal->capacity < skeleton->slotCount) {
|
if (internal->capacity < skeleton->slotCount) {
|
||||||
BoundingPolygon** newPolygons;
|
spBoundingPolygon** newPolygons;
|
||||||
|
|
||||||
FREE(self->boundingBoxes);
|
FREE(self->boundingBoxes);
|
||||||
self->boundingBoxes = MALLOC(BoundingBoxAttachment*, skeleton->slotCount);
|
self->boundingBoxes = MALLOC(spBoundingBoxAttachment*, skeleton->slotCount);
|
||||||
|
|
||||||
newPolygons = CALLOC(BoundingPolygon*, skeleton->slotCount);
|
newPolygons = CALLOC(spBoundingPolygon*, skeleton->slotCount);
|
||||||
memcpy(newPolygons, self->polygons, internal->capacity);
|
memcpy(newPolygons, self->polygons, internal->capacity);
|
||||||
FREE(self->polygons);
|
FREE(self->polygons);
|
||||||
self->polygons = newPolygons;
|
self->polygons = newPolygons;
|
||||||
@ -129,22 +129,22 @@ void SkeletonBounds_update (SkeletonBounds* self, Skeleton* skeleton, int/*bool*
|
|||||||
|
|
||||||
self->count = 0;
|
self->count = 0;
|
||||||
for (i = 0; i < skeleton->slotCount; ++i) {
|
for (i = 0; i < skeleton->slotCount; ++i) {
|
||||||
BoundingPolygon* polygon;
|
spBoundingPolygon* polygon;
|
||||||
BoundingBoxAttachment* boundingBox;
|
spBoundingBoxAttachment* boundingBox;
|
||||||
|
|
||||||
Slot* slot = skeleton->slots[i];
|
spSlot* slot = skeleton->slots[i];
|
||||||
Attachment* attachment = slot->attachment;
|
spAttachment* attachment = slot->attachment;
|
||||||
if (!attachment || attachment->type != ATTACHMENT_BOUNDING_BOX) continue;
|
if (!attachment || attachment->type != ATTACHMENT_BOUNDING_BOX) continue;
|
||||||
boundingBox = (BoundingBoxAttachment*)attachment;
|
boundingBox = (spBoundingBoxAttachment*)attachment;
|
||||||
self->boundingBoxes[self->count] = boundingBox;
|
self->boundingBoxes[self->count] = boundingBox;
|
||||||
|
|
||||||
polygon = self->polygons[self->count];
|
polygon = self->polygons[self->count];
|
||||||
if (!polygon || polygon->capacity < boundingBox->verticesCount) {
|
if (!polygon || polygon->capacity < boundingBox->verticesCount) {
|
||||||
if (polygon) BoundingPolygon_dispose(polygon);
|
if (polygon) spBoundingPolygon_dispose(polygon);
|
||||||
self->polygons[self->count] = polygon = BoundingPolygon_create(boundingBox->verticesCount);
|
self->polygons[self->count] = polygon = spBoundingPolygon_create(boundingBox->verticesCount);
|
||||||
}
|
}
|
||||||
polygon->count = boundingBox->verticesCount;
|
polygon->count = boundingBox->verticesCount;
|
||||||
BoundingBoxAttachment_computeWorldVertices(boundingBox, skeleton->x, skeleton->y, slot->bone, polygon->vertices);
|
spBoundingBoxAttachment_computeWorldVertices(boundingBox, skeleton->x, skeleton->y, slot->bone, polygon->vertices);
|
||||||
|
|
||||||
if (updateAabb) {
|
if (updateAabb) {
|
||||||
int ii = 0;
|
int ii = 0;
|
||||||
@ -162,11 +162,11 @@ void SkeletonBounds_update (SkeletonBounds* self, Skeleton* skeleton, int/*bool*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int/*bool*/SkeletonBounds_aabbContainsPoint (SkeletonBounds* self, float x, float y) {
|
int/*bool*/spSkeletonBounds_aabbContainsPoint (spSkeletonBounds* self, float x, float y) {
|
||||||
return x >= self->minX && x <= self->maxX && y >= self->minY && y <= self->maxY;
|
return x >= self->minX && x <= self->maxX && y >= self->minY && y <= self->maxY;
|
||||||
}
|
}
|
||||||
|
|
||||||
int/*bool*/SkeletonBounds_aabbIntersectsSegment (SkeletonBounds* self, float x1, float y1, float x2, float y2) {
|
int/*bool*/spSkeletonBounds_aabbIntersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2) {
|
||||||
float m, x, y;
|
float m, x, y;
|
||||||
if ((x1 <= self->minX && x2 <= self->minX) || (y1 <= self->minY && y2 <= self->minY) || (x1 >= self->maxX && x2 >= self->maxX)
|
if ((x1 <= self->minX && x2 <= self->minX) || (y1 <= self->minY && y2 <= self->minY) || (x1 >= self->maxX && x2 >= self->maxX)
|
||||||
|| (y1 >= self->maxY && y2 >= self->maxY)) return 0;
|
|| (y1 >= self->maxY && y2 >= self->maxY)) return 0;
|
||||||
@ -182,25 +182,25 @@ int/*bool*/SkeletonBounds_aabbIntersectsSegment (SkeletonBounds* self, float x1,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int/*bool*/SkeletonBounds_aabbIntersectsSkeleton (SkeletonBounds* self, SkeletonBounds* bounds) {
|
int/*bool*/spSkeletonBounds_aabbIntersectsSkeleton (spSkeletonBounds* self, spSkeletonBounds* bounds) {
|
||||||
return self->minX < bounds->maxX && self->maxX > bounds->minX && self->minY < bounds->maxY && self->maxY > bounds->minY;
|
return self->minX < bounds->maxX && self->maxX > bounds->minX && self->minY < bounds->maxY && self->maxY > bounds->minY;
|
||||||
}
|
}
|
||||||
|
|
||||||
BoundingBoxAttachment* SkeletonBounds_containsPoint (SkeletonBounds* self, float x, float y) {
|
spBoundingBoxAttachment* spSkeletonBounds_containsPoint (spSkeletonBounds* self, float x, float y) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->count; ++i)
|
for (i = 0; i < self->count; ++i)
|
||||||
if (BoundingPolygon_containsPoint(self->polygons[i], x, y)) return self->boundingBoxes[i];
|
if (spBoundingPolygon_containsPoint(self->polygons[i], x, y)) return self->boundingBoxes[i];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BoundingBoxAttachment* SkeletonBounds_intersectsSegment (SkeletonBounds* self, float x1, float y1, float x2, float y2) {
|
spBoundingBoxAttachment* spSkeletonBounds_intersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->count; ++i)
|
for (i = 0; i < self->count; ++i)
|
||||||
if (BoundingPolygon_intersectsSegment(self->polygons[i], x1, y1, x2, y2)) return self->boundingBoxes[i];
|
if (spBoundingPolygon_intersectsSegment(self->polygons[i], x1, y1, x2, y2)) return self->boundingBoxes[i];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BoundingPolygon* SkeletonBounds_getPolygon (SkeletonBounds* self, BoundingBoxAttachment* boundingBox) {
|
spBoundingPolygon* spSkeletonBounds_getPolygon (spSkeletonBounds* self, spBoundingBoxAttachment* boundingBox) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->count; ++i)
|
for (i = 0; i < self->count; ++i)
|
||||||
if (self->boundingBoxes[i] == boundingBox) return self->polygons[i];
|
if (self->boundingBoxes[i] == boundingBox) return self->polygons[i];
|
||||||
|
|||||||
@ -35,74 +35,74 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <spine/extension.h>
|
#include <spine/extension.h>
|
||||||
|
|
||||||
SkeletonData* SkeletonData_create () {
|
spSkeletonData* spSkeletonData_create () {
|
||||||
return NEW(SkeletonData);
|
return NEW(spSkeletonData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonData_dispose (SkeletonData* self) {
|
void spSkeletonData_dispose (spSkeletonData* self) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->boneCount; ++i)
|
for (i = 0; i < self->boneCount; ++i)
|
||||||
BoneData_dispose(self->bones[i]);
|
spBoneData_dispose(self->bones[i]);
|
||||||
FREE(self->bones);
|
FREE(self->bones);
|
||||||
|
|
||||||
for (i = 0; i < self->slotCount; ++i)
|
for (i = 0; i < self->slotCount; ++i)
|
||||||
SlotData_dispose(self->slots[i]);
|
spSlotData_dispose(self->slots[i]);
|
||||||
FREE(self->slots);
|
FREE(self->slots);
|
||||||
|
|
||||||
for (i = 0; i < self->skinCount; ++i)
|
for (i = 0; i < self->skinCount; ++i)
|
||||||
Skin_dispose(self->skins[i]);
|
spSkin_dispose(self->skins[i]);
|
||||||
FREE(self->skins);
|
FREE(self->skins);
|
||||||
|
|
||||||
for (i = 0; i < self->animationCount; ++i)
|
for (i = 0; i < self->animationCount; ++i)
|
||||||
Animation_dispose(self->animations[i]);
|
spAnimation_dispose(self->animations[i]);
|
||||||
FREE(self->animations);
|
FREE(self->animations);
|
||||||
|
|
||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
BoneData* SkeletonData_findBone (const SkeletonData* self, const char* boneName) {
|
spBoneData* spSkeletonData_findBone (const spSkeletonData* self, const char* boneName) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->boneCount; ++i)
|
for (i = 0; i < self->boneCount; ++i)
|
||||||
if (strcmp(self->bones[i]->name, boneName) == 0) return self->bones[i];
|
if (strcmp(self->bones[i]->name, boneName) == 0) return self->bones[i];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SkeletonData_findBoneIndex (const SkeletonData* self, const char* boneName) {
|
int spSkeletonData_findBoneIndex (const spSkeletonData* self, const char* boneName) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->boneCount; ++i)
|
for (i = 0; i < self->boneCount; ++i)
|
||||||
if (strcmp(self->bones[i]->name, boneName) == 0) return i;
|
if (strcmp(self->bones[i]->name, boneName) == 0) return i;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SlotData* SkeletonData_findSlot (const SkeletonData* self, const char* slotName) {
|
spSlotData* spSkeletonData_findSlot (const spSkeletonData* self, const char* slotName) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->slotCount; ++i)
|
for (i = 0; i < self->slotCount; ++i)
|
||||||
if (strcmp(self->slots[i]->name, slotName) == 0) return self->slots[i];
|
if (strcmp(self->slots[i]->name, slotName) == 0) return self->slots[i];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SkeletonData_findSlotIndex (const SkeletonData* self, const char* slotName) {
|
int spSkeletonData_findSlotIndex (const spSkeletonData* self, const char* slotName) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->slotCount; ++i)
|
for (i = 0; i < self->slotCount; ++i)
|
||||||
if (strcmp(self->slots[i]->name, slotName) == 0) return i;
|
if (strcmp(self->slots[i]->name, slotName) == 0) return i;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skin* SkeletonData_findSkin (const SkeletonData* self, const char* skinName) {
|
spSkin* spSkeletonData_findSkin (const spSkeletonData* self, const char* skinName) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->skinCount; ++i)
|
for (i = 0; i < self->skinCount; ++i)
|
||||||
if (strcmp(self->skins[i]->name, skinName) == 0) return self->skins[i];
|
if (strcmp(self->skins[i]->name, skinName) == 0) return self->skins[i];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData* SkeletonData_findEvent (const SkeletonData* self, const char* eventName) {
|
spEventData* spSkeletonData_findEvent (const spSkeletonData* self, const char* eventName) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->eventCount; ++i)
|
for (i = 0; i < self->eventCount; ++i)
|
||||||
if (strcmp(self->events[i]->name, eventName) == 0) return self->events[i];
|
if (strcmp(self->events[i]->name, eventName) == 0) return self->events[i];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Animation* SkeletonData_findAnimation (const SkeletonData* self, const char* animationName) {
|
spAnimation* spSkeletonData_findAnimation (const spSkeletonData* self, const char* animationName) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->animationCount; ++i)
|
for (i = 0; i < self->animationCount; ++i)
|
||||||
if (strcmp(self->animations[i]->name, animationName) == 0) return self->animations[i];
|
if (strcmp(self->animations[i]->name, animationName) == 0) return self->animations[i];
|
||||||
|
|||||||
@ -39,31 +39,31 @@
|
|||||||
#include <spine/AtlasAttachmentLoader.h>
|
#include <spine/AtlasAttachmentLoader.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SkeletonJson super;
|
spSkeletonJson super;
|
||||||
int ownsLoader;
|
int ownsLoader;
|
||||||
} _SkeletonJson;
|
} _spSkeletonJson;
|
||||||
|
|
||||||
SkeletonJson* SkeletonJson_createWithLoader (AttachmentLoader* attachmentLoader) {
|
spSkeletonJson* spSkeletonJson_createWithLoader (spAttachmentLoader* attachmentLoader) {
|
||||||
SkeletonJson* self = SUPER(NEW(_SkeletonJson));
|
spSkeletonJson* self = SUPER(NEW(_spSkeletonJson));
|
||||||
self->scale = 1;
|
self->scale = 1;
|
||||||
self->attachmentLoader = attachmentLoader;
|
self->attachmentLoader = attachmentLoader;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkeletonJson* SkeletonJson_create (Atlas* atlas) {
|
spSkeletonJson* spSkeletonJson_create (spAtlas* atlas) {
|
||||||
AtlasAttachmentLoader* attachmentLoader = AtlasAttachmentLoader_create(atlas);
|
spAtlasAttachmentLoader* attachmentLoader = spAtlasAttachmentLoader_create(atlas);
|
||||||
SkeletonJson* self = SkeletonJson_createWithLoader(SUPER(attachmentLoader));
|
spSkeletonJson* self = spSkeletonJson_createWithLoader(SUPER(attachmentLoader));
|
||||||
SUB_CAST(_SkeletonJson, self)->ownsLoader = 1;
|
SUB_CAST(_spSkeletonJson, self)->ownsLoader = 1;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonJson_dispose (SkeletonJson* self) {
|
void spSkeletonJson_dispose (spSkeletonJson* self) {
|
||||||
if (SUB_CAST(_SkeletonJson, self)->ownsLoader) AttachmentLoader_dispose(self->attachmentLoader);
|
if (SUB_CAST(_spSkeletonJson, self)->ownsLoader) spAttachmentLoader_dispose(self->attachmentLoader);
|
||||||
FREE(self->error);
|
FREE(self->error);
|
||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _SkeletonJson_setError (SkeletonJson* self, Json* root, const char* value1, const char* value2) {
|
void _spSkeletonJson_setError (spSkeletonJson* self, Json* root, const char* value1, const char* value2) {
|
||||||
char message[256];
|
char message[256];
|
||||||
int length;
|
int length;
|
||||||
FREE(self->error);
|
FREE(self->error);
|
||||||
@ -90,24 +90,24 @@ static float toColor (const char* value, int index) {
|
|||||||
return color / (float)255;
|
return color / (float)255;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void readCurve (CurveTimeline* timeline, int frameIndex, Json* frame) {
|
static void readCurve (spCurveTimeline* timeline, int frameIndex, Json* frame) {
|
||||||
Json* curve = Json_getItem(frame, "curve");
|
Json* curve = Json_getItem(frame, "curve");
|
||||||
if (!curve) return;
|
if (!curve) return;
|
||||||
if (curve->type == Json_String && strcmp(curve->valueString, "stepped") == 0)
|
if (curve->type == Json_String && strcmp(curve->valueString, "stepped") == 0)
|
||||||
CurveTimeline_setStepped(timeline, frameIndex);
|
spCurveTimeline_setStepped(timeline, frameIndex);
|
||||||
else if (curve->type == Json_Array) {
|
else if (curve->type == Json_Array) {
|
||||||
Json* child0 = curve->child;
|
Json* child0 = curve->child;
|
||||||
Json* child1 = child0->next;
|
Json* child1 = child0->next;
|
||||||
Json* child2 = child1->next;
|
Json* child2 = child1->next;
|
||||||
Json* child3 = child2->next;
|
Json* child3 = child2->next;
|
||||||
CurveTimeline_setCurve(timeline, frameIndex, child0->valueFloat, child1->valueFloat, child2->valueFloat,
|
spCurveTimeline_setCurve(timeline, frameIndex, child0->valueFloat, child1->valueFloat, child2->valueFloat,
|
||||||
child3->valueFloat);
|
child3->valueFloat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, SkeletonData *skeletonData) {
|
static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* root, spSkeletonData *skeletonData) {
|
||||||
int i;
|
int i;
|
||||||
Animation* animation;
|
spAnimation* animation;
|
||||||
|
|
||||||
Json* bones = Json_getItem(root, "bones");
|
Json* bones = Json_getItem(root, "bones");
|
||||||
Json* slots = Json_getItem(root, "slots");
|
Json* slots = Json_getItem(root, "slots");
|
||||||
@ -123,7 +123,7 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S
|
|||||||
if (events) ++timelineCount;
|
if (events) ++timelineCount;
|
||||||
if (drawOrder) ++timelineCount;
|
if (drawOrder) ++timelineCount;
|
||||||
|
|
||||||
animation = Animation_create(root->name, timelineCount);
|
animation = spAnimation_create(root->name, timelineCount);
|
||||||
animation->timelineCount = 0;
|
animation->timelineCount = 0;
|
||||||
skeletonData->animations[skeletonData->animationCount] = animation;
|
skeletonData->animations[skeletonData->animationCount] = animation;
|
||||||
++skeletonData->animationCount;
|
++skeletonData->animationCount;
|
||||||
@ -131,10 +131,10 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S
|
|||||||
for (boneMap = bones ? bones->child : 0; boneMap; boneMap = boneMap->next) {
|
for (boneMap = bones ? bones->child : 0; boneMap; boneMap = boneMap->next) {
|
||||||
Json *timelineArray;
|
Json *timelineArray;
|
||||||
|
|
||||||
int boneIndex = SkeletonData_findBoneIndex(skeletonData, boneMap->name);
|
int boneIndex = spSkeletonData_findBoneIndex(skeletonData, boneMap->name);
|
||||||
if (boneIndex == -1) {
|
if (boneIndex == -1) {
|
||||||
Animation_dispose(animation);
|
spAnimation_dispose(animation);
|
||||||
_SkeletonJson_setError(self, root, "Bone not found: ", boneMap->name);
|
_spSkeletonJson_setError(self, root, "spBone not found: ", boneMap->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,13 +143,13 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S
|
|||||||
float duration;
|
float duration;
|
||||||
|
|
||||||
if (strcmp(timelineArray->name, "rotate") == 0) {
|
if (strcmp(timelineArray->name, "rotate") == 0) {
|
||||||
RotateTimeline *timeline = RotateTimeline_create(timelineArray->size);
|
spRotateTimeline *timeline = spRotateTimeline_create(timelineArray->size);
|
||||||
timeline->boneIndex = boneIndex;
|
timeline->boneIndex = boneIndex;
|
||||||
for (frame = timelineArray->child, i = 0; frame; frame = frame->next, ++i) {
|
for (frame = timelineArray->child, i = 0; frame; frame = frame->next, ++i) {
|
||||||
RotateTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), Json_getFloat(frame, "angle", 0));
|
spRotateTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), Json_getFloat(frame, "angle", 0));
|
||||||
readCurve(SUPER(timeline), i, frame);
|
readCurve(SUPER(timeline), i, frame);
|
||||||
}
|
}
|
||||||
animation->timelines[animation->timelineCount++] = (Timeline*)timeline;
|
animation->timelines[animation->timelineCount++] = (spTimeline*)timeline;
|
||||||
duration = timeline->frames[timelineArray->size * 2 - 2];
|
duration = timeline->frames[timelineArray->size * 2 - 2];
|
||||||
if (duration > animation->duration) animation->duration = duration;
|
if (duration > animation->duration) animation->duration = duration;
|
||||||
|
|
||||||
@ -157,20 +157,20 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S
|
|||||||
int isScale = strcmp(timelineArray->name, "scale") == 0;
|
int isScale = strcmp(timelineArray->name, "scale") == 0;
|
||||||
if (isScale || strcmp(timelineArray->name, "translate") == 0) {
|
if (isScale || strcmp(timelineArray->name, "translate") == 0) {
|
||||||
float scale = isScale ? 1 : self->scale;
|
float scale = isScale ? 1 : self->scale;
|
||||||
TranslateTimeline *timeline =
|
spTranslateTimeline *timeline =
|
||||||
isScale ? ScaleTimeline_create(timelineArray->size) : TranslateTimeline_create(timelineArray->size);
|
isScale ? spScaleTimeline_create(timelineArray->size) : spTranslateTimeline_create(timelineArray->size);
|
||||||
timeline->boneIndex = boneIndex;
|
timeline->boneIndex = boneIndex;
|
||||||
for (frame = timelineArray->child, i = 0; frame; frame = frame->next, ++i) {
|
for (frame = timelineArray->child, i = 0; frame; frame = frame->next, ++i) {
|
||||||
TranslateTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), Json_getFloat(frame, "x", 0) * scale,
|
spTranslateTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), Json_getFloat(frame, "x", 0) * scale,
|
||||||
Json_getFloat(frame, "y", 0) * scale);
|
Json_getFloat(frame, "y", 0) * scale);
|
||||||
readCurve(SUPER(timeline), i, frame);
|
readCurve(SUPER(timeline), i, frame);
|
||||||
}
|
}
|
||||||
animation->timelines[animation->timelineCount++] = (Timeline*)timeline;
|
animation->timelines[animation->timelineCount++] = (spTimeline*)timeline;
|
||||||
duration = timeline->frames[timelineArray->size * 3 - 3];
|
duration = timeline->frames[timelineArray->size * 3 - 3];
|
||||||
if (duration > animation->duration) animation->duration = duration;
|
if (duration > animation->duration) animation->duration = duration;
|
||||||
} else {
|
} else {
|
||||||
Animation_dispose(animation);
|
spAnimation_dispose(animation);
|
||||||
_SkeletonJson_setError(self, 0, "Invalid timeline type for a bone: ", timelineArray->name);
|
_spSkeletonJson_setError(self, 0, "Invalid timeline type for a bone: ", timelineArray->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,10 +180,10 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S
|
|||||||
for (slotMap = slots ? slots->child : 0; slotMap; slotMap = slotMap->next) {
|
for (slotMap = slots ? slots->child : 0; slotMap; slotMap = slotMap->next) {
|
||||||
Json *timelineArray;
|
Json *timelineArray;
|
||||||
|
|
||||||
int slotIndex = SkeletonData_findSlotIndex(skeletonData, slotMap->name);
|
int slotIndex = spSkeletonData_findSlotIndex(skeletonData, slotMap->name);
|
||||||
if (slotIndex == -1) {
|
if (slotIndex == -1) {
|
||||||
Animation_dispose(animation);
|
spAnimation_dispose(animation);
|
||||||
_SkeletonJson_setError(self, root, "Slot not found: ", slotMap->name);
|
_spSkeletonJson_setError(self, root, "Slot not found: ", slotMap->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,33 +192,33 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S
|
|||||||
float duration;
|
float duration;
|
||||||
|
|
||||||
if (strcmp(timelineArray->name, "color") == 0) {
|
if (strcmp(timelineArray->name, "color") == 0) {
|
||||||
ColorTimeline *timeline = ColorTimeline_create(timelineArray->size);
|
spColorTimeline *timeline = spColorTimeline_create(timelineArray->size);
|
||||||
timeline->slotIndex = slotIndex;
|
timeline->slotIndex = slotIndex;
|
||||||
for (frame = timelineArray->child, i = 0; frame; frame = frame->next, ++i) {
|
for (frame = timelineArray->child, i = 0; frame; frame = frame->next, ++i) {
|
||||||
const char* s = Json_getString(frame, "color", 0);
|
const char* s = Json_getString(frame, "color", 0);
|
||||||
ColorTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), toColor(s, 0), toColor(s, 1), toColor(s, 2),
|
spColorTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), toColor(s, 0), toColor(s, 1), toColor(s, 2),
|
||||||
toColor(s, 3));
|
toColor(s, 3));
|
||||||
readCurve(SUPER(timeline), i, frame);
|
readCurve(SUPER(timeline), i, frame);
|
||||||
}
|
}
|
||||||
animation->timelines[animation->timelineCount++] = (Timeline*)timeline;
|
animation->timelines[animation->timelineCount++] = (spTimeline*)timeline;
|
||||||
duration = timeline->frames[timelineArray->size * 5 - 5];
|
duration = timeline->frames[timelineArray->size * 5 - 5];
|
||||||
if (duration > animation->duration) animation->duration = duration;
|
if (duration > animation->duration) animation->duration = duration;
|
||||||
|
|
||||||
} else if (strcmp(timelineArray->name, "attachment") == 0) {
|
} else if (strcmp(timelineArray->name, "attachment") == 0) {
|
||||||
AttachmentTimeline *timeline = AttachmentTimeline_create(timelineArray->size);
|
spAttachmentTimeline *timeline = spAttachmentTimeline_create(timelineArray->size);
|
||||||
timeline->slotIndex = slotIndex;
|
timeline->slotIndex = slotIndex;
|
||||||
for (frame = timelineArray->child, i = 0; frame; frame = frame->next, ++i) {
|
for (frame = timelineArray->child, i = 0; frame; frame = frame->next, ++i) {
|
||||||
Json* name = Json_getItem(frame, "name");
|
Json* name = Json_getItem(frame, "name");
|
||||||
AttachmentTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0),
|
spAttachmentTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0),
|
||||||
name->type == Json_NULL ? 0 : name->valueString);
|
name->type == Json_NULL ? 0 : name->valueString);
|
||||||
}
|
}
|
||||||
animation->timelines[animation->timelineCount++] = (Timeline*)timeline;
|
animation->timelines[animation->timelineCount++] = (spTimeline*)timeline;
|
||||||
duration = timeline->frames[timelineArray->size - 1];
|
duration = timeline->frames[timelineArray->size - 1];
|
||||||
if (duration > animation->duration) animation->duration = duration;
|
if (duration > animation->duration) animation->duration = duration;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Animation_dispose(animation);
|
spAnimation_dispose(animation);
|
||||||
_SkeletonJson_setError(self, 0, "Invalid timeline type for a slot: ", timelineArray->name);
|
_spSkeletonJson_setError(self, 0, "Invalid timeline type for a slot: ", timelineArray->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -228,24 +228,24 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S
|
|||||||
Json* frame;
|
Json* frame;
|
||||||
float duration;
|
float duration;
|
||||||
|
|
||||||
EventTimeline* timeline = EventTimeline_create(events->size);
|
spEventTimeline* timeline = spEventTimeline_create(events->size);
|
||||||
for (frame = events->child, i = 0; frame; frame = frame->next, ++i) {
|
for (frame = events->child, i = 0; frame; frame = frame->next, ++i) {
|
||||||
Event* event;
|
spEvent* event;
|
||||||
const char* stringValue;
|
const char* stringValue;
|
||||||
EventData* eventData = SkeletonData_findEvent(skeletonData, Json_getString(frame, "name", 0));
|
spEventData* eventData = spSkeletonData_findEvent(skeletonData, Json_getString(frame, "name", 0));
|
||||||
if (!eventData) {
|
if (!eventData) {
|
||||||
Animation_dispose(animation);
|
spAnimation_dispose(animation);
|
||||||
_SkeletonJson_setError(self, 0, "Event not found: ", Json_getString(frame, "name", 0));
|
_spSkeletonJson_setError(self, 0, "Event not found: ", Json_getString(frame, "name", 0));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
event = Event_create(eventData);
|
event = spEvent_create(eventData);
|
||||||
event->intValue = Json_getInt(frame, "int", eventData->intValue);
|
event->intValue = Json_getInt(frame, "int", eventData->intValue);
|
||||||
event->floatValue = Json_getFloat(frame, "float", eventData->floatValue);
|
event->floatValue = Json_getFloat(frame, "float", eventData->floatValue);
|
||||||
stringValue = Json_getString(frame, "string", eventData->stringValue);
|
stringValue = Json_getString(frame, "string", eventData->stringValue);
|
||||||
if (stringValue) MALLOC_STR(event->stringValue, stringValue);
|
if (stringValue) MALLOC_STR(event->stringValue, stringValue);
|
||||||
EventTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), event);
|
spEventTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), event);
|
||||||
}
|
}
|
||||||
animation->timelines[animation->timelineCount++] = (Timeline*)timeline;
|
animation->timelines[animation->timelineCount++] = (spTimeline*)timeline;
|
||||||
duration = timeline->frames[events->size - 1];
|
duration = timeline->frames[events->size - 1];
|
||||||
if (duration > animation->duration) animation->duration = duration;
|
if (duration > animation->duration) animation->duration = duration;
|
||||||
}
|
}
|
||||||
@ -254,7 +254,7 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S
|
|||||||
Json* frame;
|
Json* frame;
|
||||||
float duration;
|
float duration;
|
||||||
|
|
||||||
DrawOrderTimeline* timeline = DrawOrderTimeline_create(drawOrder->size, skeletonData->slotCount);
|
spDrawOrderTimeline* timeline = spDrawOrderTimeline_create(drawOrder->size, skeletonData->slotCount);
|
||||||
for (frame = drawOrder->child, i = 0; frame; frame = frame->next, ++i) {
|
for (frame = drawOrder->child, i = 0; frame; frame = frame->next, ++i) {
|
||||||
int ii;
|
int ii;
|
||||||
int* drawOrder = 0;
|
int* drawOrder = 0;
|
||||||
@ -269,10 +269,10 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S
|
|||||||
drawOrder[ii] = -1;
|
drawOrder[ii] = -1;
|
||||||
|
|
||||||
for (offsetMap = offsets->child; offsetMap; offsetMap = offsetMap->next) {
|
for (offsetMap = offsets->child; offsetMap; offsetMap = offsetMap->next) {
|
||||||
int slotIndex = SkeletonData_findSlotIndex(skeletonData, Json_getString(offsetMap, "slot", 0));
|
int slotIndex = spSkeletonData_findSlotIndex(skeletonData, Json_getString(offsetMap, "slot", 0));
|
||||||
if (slotIndex == -1) {
|
if (slotIndex == -1) {
|
||||||
Animation_dispose(animation);
|
spAnimation_dispose(animation);
|
||||||
_SkeletonJson_setError(self, 0, "Slot not found: ", Json_getString(offsetMap, "slot", 0));
|
_spSkeletonJson_setError(self, 0, "Slot not found: ", Json_getString(offsetMap, "slot", 0));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* Collect unchanged items. */
|
/* Collect unchanged items. */
|
||||||
@ -290,10 +290,10 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S
|
|||||||
if (drawOrder[ii] == -1) drawOrder[ii] = unchanged[--unchangedIndex];
|
if (drawOrder[ii] == -1) drawOrder[ii] = unchanged[--unchangedIndex];
|
||||||
FREE(unchanged);
|
FREE(unchanged);
|
||||||
}
|
}
|
||||||
DrawOrderTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), drawOrder);
|
spDrawOrderTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), drawOrder);
|
||||||
FREE(drawOrder);
|
FREE(drawOrder);
|
||||||
}
|
}
|
||||||
animation->timelines[animation->timelineCount++] = (Timeline*)timeline;
|
animation->timelines[animation->timelineCount++] = (spTimeline*)timeline;
|
||||||
duration = timeline->frames[drawOrder->size - 1];
|
duration = timeline->frames[drawOrder->size - 1];
|
||||||
if (duration > animation->duration) animation->duration = duration;
|
if (duration > animation->duration) animation->duration = duration;
|
||||||
}
|
}
|
||||||
@ -301,22 +301,22 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S
|
|||||||
return animation;
|
return animation;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkeletonData* SkeletonJson_readSkeletonDataFile (SkeletonJson* self, const char* path) {
|
spSkeletonData* spSkeletonJson_readSkeletonDataFile (spSkeletonJson* self, const char* path) {
|
||||||
int length;
|
int length;
|
||||||
SkeletonData* skeletonData;
|
spSkeletonData* skeletonData;
|
||||||
const char* json = _Util_readFile(path, &length);
|
const char* json = _spUtil_readFile(path, &length);
|
||||||
if (!json) {
|
if (!json) {
|
||||||
_SkeletonJson_setError(self, 0, "Unable to read skeleton file: ", path);
|
_spSkeletonJson_setError(self, 0, "Unable to read skeleton file: ", path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
skeletonData = SkeletonJson_readSkeletonData(self, json);
|
skeletonData = spSkeletonJson_readSkeletonData(self, json);
|
||||||
FREE(json);
|
FREE(json);
|
||||||
return skeletonData;
|
return skeletonData;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* json) {
|
spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const char* json) {
|
||||||
int i;
|
int i;
|
||||||
SkeletonData* skeletonData;
|
spSkeletonData* skeletonData;
|
||||||
Json *root, *bones, *boneMap, *slots, *skins, *animations, *events;
|
Json *root, *bones, *boneMap, *slots, *skins, *animations, *events;
|
||||||
|
|
||||||
FREE(self->error);
|
FREE(self->error);
|
||||||
@ -324,29 +324,29 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso
|
|||||||
|
|
||||||
root = Json_create(json);
|
root = Json_create(json);
|
||||||
if (!root) {
|
if (!root) {
|
||||||
_SkeletonJson_setError(self, 0, "Invalid skeleton JSON: ", Json_getError());
|
_spSkeletonJson_setError(self, 0, "Invalid skeleton JSON: ", Json_getError());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
skeletonData = SkeletonData_create();
|
skeletonData = spSkeletonData_create();
|
||||||
|
|
||||||
bones = Json_getItem(root, "bones");
|
bones = Json_getItem(root, "bones");
|
||||||
skeletonData->bones = MALLOC(BoneData*, bones->size);
|
skeletonData->bones = MALLOC(spBoneData*, bones->size);
|
||||||
for (boneMap = bones->child, i = 0; boneMap; boneMap = boneMap->next, ++i) {
|
for (boneMap = bones->child, i = 0; boneMap; boneMap = boneMap->next, ++i) {
|
||||||
BoneData* boneData;
|
spBoneData* boneData;
|
||||||
|
|
||||||
BoneData* parent = 0;
|
spBoneData* parent = 0;
|
||||||
const char* parentName = Json_getString(boneMap, "parent", 0);
|
const char* parentName = Json_getString(boneMap, "parent", 0);
|
||||||
if (parentName) {
|
if (parentName) {
|
||||||
parent = SkeletonData_findBone(skeletonData, parentName);
|
parent = spSkeletonData_findBone(skeletonData, parentName);
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
SkeletonData_dispose(skeletonData);
|
spSkeletonData_dispose(skeletonData);
|
||||||
_SkeletonJson_setError(self, root, "Parent bone not found: ", parentName);
|
_spSkeletonJson_setError(self, root, "Parent bone not found: ", parentName);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boneData = BoneData_create(Json_getString(boneMap, "name", 0), parent);
|
boneData = spBoneData_create(Json_getString(boneMap, "name", 0), parent);
|
||||||
boneData->length = Json_getFloat(boneMap, "length", 0) * self->scale;
|
boneData->length = Json_getFloat(boneMap, "length", 0) * self->scale;
|
||||||
boneData->x = Json_getFloat(boneMap, "x", 0) * self->scale;
|
boneData->x = Json_getFloat(boneMap, "x", 0) * self->scale;
|
||||||
boneData->y = Json_getFloat(boneMap, "y", 0) * self->scale;
|
boneData->y = Json_getFloat(boneMap, "y", 0) * self->scale;
|
||||||
@ -363,21 +363,21 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso
|
|||||||
slots = Json_getItem(root, "slots");
|
slots = Json_getItem(root, "slots");
|
||||||
if (slots) {
|
if (slots) {
|
||||||
Json *slotMap;
|
Json *slotMap;
|
||||||
skeletonData->slots = MALLOC(SlotData*, slots->size);
|
skeletonData->slots = MALLOC(spSlotData*, slots->size);
|
||||||
for (slotMap = slots->child, i = 0; slotMap; slotMap = slotMap->next, ++i) {
|
for (slotMap = slots->child, i = 0; slotMap; slotMap = slotMap->next, ++i) {
|
||||||
SlotData* slotData;
|
spSlotData* slotData;
|
||||||
const char* color;
|
const char* color;
|
||||||
Json *attachmentItem;
|
Json *attachmentItem;
|
||||||
|
|
||||||
const char* boneName = Json_getString(slotMap, "bone", 0);
|
const char* boneName = Json_getString(slotMap, "bone", 0);
|
||||||
BoneData* boneData = SkeletonData_findBone(skeletonData, boneName);
|
spBoneData* boneData = spSkeletonData_findBone(skeletonData, boneName);
|
||||||
if (!boneData) {
|
if (!boneData) {
|
||||||
SkeletonData_dispose(skeletonData);
|
spSkeletonData_dispose(skeletonData);
|
||||||
_SkeletonJson_setError(self, root, "Slot bone not found: ", boneName);
|
_spSkeletonJson_setError(self, root, "spSlot bone not found: ", boneName);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
slotData = SlotData_create(Json_getString(slotMap, "name", 0), boneData);
|
slotData = spSlotData_create(Json_getString(slotMap, "name", 0), boneData);
|
||||||
|
|
||||||
color = Json_getString(slotMap, "color", 0);
|
color = Json_getString(slotMap, "color", 0);
|
||||||
if (color) {
|
if (color) {
|
||||||
@ -388,7 +388,7 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso
|
|||||||
}
|
}
|
||||||
|
|
||||||
attachmentItem = Json_getItem(slotMap, "attachment");
|
attachmentItem = Json_getItem(slotMap, "attachment");
|
||||||
if (attachmentItem) SlotData_setAttachmentName(slotData, attachmentItem->valueString);
|
if (attachmentItem) spSlotData_setAttachmentName(slotData, attachmentItem->valueString);
|
||||||
|
|
||||||
slotData->additiveBlending = Json_getInt(slotMap, "additive", 0);
|
slotData->additiveBlending = Json_getInt(slotMap, "additive", 0);
|
||||||
|
|
||||||
@ -400,26 +400,26 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso
|
|||||||
skins = Json_getItem(root, "skins");
|
skins = Json_getItem(root, "skins");
|
||||||
if (skins) {
|
if (skins) {
|
||||||
Json *slotMap;
|
Json *slotMap;
|
||||||
skeletonData->skins = MALLOC(Skin*, skins->size);
|
skeletonData->skins = MALLOC(spSkin*, skins->size);
|
||||||
for (slotMap = skins->child, i = 0; slotMap; slotMap = slotMap->next, ++i) {
|
for (slotMap = skins->child, i = 0; slotMap; slotMap = slotMap->next, ++i) {
|
||||||
Json *attachmentsMap;
|
Json *attachmentsMap;
|
||||||
Skin *skin = Skin_create(slotMap->name);
|
spSkin *skin = spSkin_create(slotMap->name);
|
||||||
|
|
||||||
skeletonData->skins[i] = skin;
|
skeletonData->skins[i] = skin;
|
||||||
++skeletonData->skinCount;
|
++skeletonData->skinCount;
|
||||||
if (strcmp(slotMap->name, "default") == 0) skeletonData->defaultSkin = skin;
|
if (strcmp(slotMap->name, "default") == 0) skeletonData->defaultSkin = skin;
|
||||||
|
|
||||||
for (attachmentsMap = slotMap->child; attachmentsMap; attachmentsMap = attachmentsMap->next) {
|
for (attachmentsMap = slotMap->child; attachmentsMap; attachmentsMap = attachmentsMap->next) {
|
||||||
int slotIndex = SkeletonData_findSlotIndex(skeletonData, attachmentsMap->name);
|
int slotIndex = spSkeletonData_findSlotIndex(skeletonData, attachmentsMap->name);
|
||||||
Json *attachmentMap;
|
Json *attachmentMap;
|
||||||
|
|
||||||
for (attachmentMap = attachmentsMap->child; attachmentMap; attachmentMap = attachmentMap->next) {
|
for (attachmentMap = attachmentsMap->child; attachmentMap; attachmentMap = attachmentMap->next) {
|
||||||
Attachment* attachment;
|
spAttachment* attachment;
|
||||||
const char* skinAttachmentName = attachmentMap->name;
|
const char* skinAttachmentName = attachmentMap->name;
|
||||||
const char* attachmentName = Json_getString(attachmentMap, "name", skinAttachmentName);
|
const char* attachmentName = Json_getString(attachmentMap, "name", skinAttachmentName);
|
||||||
|
|
||||||
const char* typeString = Json_getString(attachmentMap, "type", "region");
|
const char* typeString = Json_getString(attachmentMap, "type", "region");
|
||||||
AttachmentType type;
|
spAttachmentType type;
|
||||||
if (strcmp(typeString, "region") == 0)
|
if (strcmp(typeString, "region") == 0)
|
||||||
type = ATTACHMENT_REGION;
|
type = ATTACHMENT_REGION;
|
||||||
else if (strcmp(typeString, "boundingbox") == 0)
|
else if (strcmp(typeString, "boundingbox") == 0)
|
||||||
@ -427,16 +427,16 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso
|
|||||||
else if (strcmp(typeString, "regionsequence") == 0)
|
else if (strcmp(typeString, "regionsequence") == 0)
|
||||||
type = ATTACHMENT_REGION_SEQUENCE;
|
type = ATTACHMENT_REGION_SEQUENCE;
|
||||||
else {
|
else {
|
||||||
SkeletonData_dispose(skeletonData);
|
spSkeletonData_dispose(skeletonData);
|
||||||
_SkeletonJson_setError(self, root, "Unknown attachment type: ", typeString);
|
_spSkeletonJson_setError(self, root, "Unknown attachment type: ", typeString);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
attachment = AttachmentLoader_newAttachment(self->attachmentLoader, skin, type, attachmentName);
|
attachment = spAttachmentLoader_newAttachment(self->attachmentLoader, skin, type, attachmentName);
|
||||||
if (!attachment) {
|
if (!attachment) {
|
||||||
if (self->attachmentLoader->error1) {
|
if (self->attachmentLoader->error1) {
|
||||||
SkeletonData_dispose(skeletonData);
|
spSkeletonData_dispose(skeletonData);
|
||||||
_SkeletonJson_setError(self, root, self->attachmentLoader->error1, self->attachmentLoader->error2);
|
_spSkeletonJson_setError(self, root, self->attachmentLoader->error1, self->attachmentLoader->error2);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -445,7 +445,7 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso
|
|||||||
switch (attachment->type) {
|
switch (attachment->type) {
|
||||||
case ATTACHMENT_REGION:
|
case ATTACHMENT_REGION:
|
||||||
case ATTACHMENT_REGION_SEQUENCE: {
|
case ATTACHMENT_REGION_SEQUENCE: {
|
||||||
RegionAttachment* regionAttachment = (RegionAttachment*)attachment;
|
spRegionAttachment* regionAttachment = (spRegionAttachment*)attachment;
|
||||||
regionAttachment->x = Json_getFloat(attachmentMap, "x", 0) * self->scale;
|
regionAttachment->x = Json_getFloat(attachmentMap, "x", 0) * self->scale;
|
||||||
regionAttachment->y = Json_getFloat(attachmentMap, "y", 0) * self->scale;
|
regionAttachment->y = Json_getFloat(attachmentMap, "y", 0) * self->scale;
|
||||||
regionAttachment->scaleX = Json_getFloat(attachmentMap, "scaleX", 1);
|
regionAttachment->scaleX = Json_getFloat(attachmentMap, "scaleX", 1);
|
||||||
@ -453,11 +453,11 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso
|
|||||||
regionAttachment->rotation = Json_getFloat(attachmentMap, "rotation", 0);
|
regionAttachment->rotation = Json_getFloat(attachmentMap, "rotation", 0);
|
||||||
regionAttachment->width = Json_getFloat(attachmentMap, "width", 32) * self->scale;
|
regionAttachment->width = Json_getFloat(attachmentMap, "width", 32) * self->scale;
|
||||||
regionAttachment->height = Json_getFloat(attachmentMap, "height", 32) * self->scale;
|
regionAttachment->height = Json_getFloat(attachmentMap, "height", 32) * self->scale;
|
||||||
RegionAttachment_updateOffset(regionAttachment);
|
spRegionAttachment_updateOffset(regionAttachment);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ATTACHMENT_BOUNDING_BOX: {
|
case ATTACHMENT_BOUNDING_BOX: {
|
||||||
BoundingBoxAttachment* box = (BoundingBoxAttachment*)attachment;
|
spBoundingBoxAttachment* box = (spBoundingBoxAttachment*)attachment;
|
||||||
Json* verticesArray = Json_getItem(attachmentMap, "vertices");
|
Json* verticesArray = Json_getItem(attachmentMap, "vertices");
|
||||||
Json* vertex;
|
Json* vertex;
|
||||||
int i;
|
int i;
|
||||||
@ -469,7 +469,7 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Skin_addAttachment(skin, slotIndex, skinAttachmentName, attachment);
|
spSkin_addAttachment(skin, slotIndex, skinAttachmentName, attachment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -480,9 +480,9 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso
|
|||||||
if (events) {
|
if (events) {
|
||||||
Json *eventMap;
|
Json *eventMap;
|
||||||
const char* stringValue;
|
const char* stringValue;
|
||||||
skeletonData->events = MALLOC(EventData*, events->size);
|
skeletonData->events = MALLOC(spEventData*, events->size);
|
||||||
for (eventMap = events->child; eventMap; eventMap = eventMap->next) {
|
for (eventMap = events->child; eventMap; eventMap = eventMap->next) {
|
||||||
EventData* eventData = EventData_create(eventMap->name);
|
spEventData* eventData = spEventData_create(eventMap->name);
|
||||||
eventData->intValue = Json_getInt(eventMap, "int", 0);
|
eventData->intValue = Json_getInt(eventMap, "int", 0);
|
||||||
eventData->floatValue = Json_getFloat(eventMap, "float", 0);
|
eventData->floatValue = Json_getFloat(eventMap, "float", 0);
|
||||||
stringValue = Json_getString(eventMap, "string", 0);
|
stringValue = Json_getString(eventMap, "string", 0);
|
||||||
@ -495,9 +495,9 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso
|
|||||||
animations = Json_getItem(root, "animations");
|
animations = Json_getItem(root, "animations");
|
||||||
if (animations) {
|
if (animations) {
|
||||||
Json *animationMap;
|
Json *animationMap;
|
||||||
skeletonData->animations = MALLOC(Animation*, animations->size);
|
skeletonData->animations = MALLOC(spAnimation*, animations->size);
|
||||||
for (animationMap = animations->child; animationMap; animationMap = animationMap->next)
|
for (animationMap = animations->child; animationMap; animationMap = animationMap->next)
|
||||||
_SkeletonJson_readAnimation(self, animationMap, skeletonData);
|
_spSkeletonJson_readAnimation(self, animationMap, skeletonData);
|
||||||
}
|
}
|
||||||
|
|
||||||
Json_dispose(root);
|
Json_dispose(root);
|
||||||
|
|||||||
@ -38,11 +38,11 @@ typedef struct _Entry _Entry;
|
|||||||
struct _Entry {
|
struct _Entry {
|
||||||
int slotIndex;
|
int slotIndex;
|
||||||
const char* name;
|
const char* name;
|
||||||
Attachment* attachment;
|
spAttachment* attachment;
|
||||||
_Entry* next;
|
_Entry* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
_Entry* _Entry_create (int slotIndex, const char* name, Attachment* attachment) {
|
_Entry* _Entry_create (int slotIndex, const char* name, spAttachment* attachment) {
|
||||||
_Entry* self = NEW(_Entry);
|
_Entry* self = NEW(_Entry);
|
||||||
self->slotIndex = slotIndex;
|
self->slotIndex = slotIndex;
|
||||||
MALLOC_STR(self->name, name);
|
MALLOC_STR(self->name, name);
|
||||||
@ -51,7 +51,7 @@ _Entry* _Entry_create (int slotIndex, const char* name, Attachment* attachment)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _Entry_dispose (_Entry* self) {
|
void _Entry_dispose (_Entry* self) {
|
||||||
Attachment_dispose(self->attachment);
|
spAttachment_dispose(self->attachment);
|
||||||
FREE(self->name);
|
FREE(self->name);
|
||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
@ -59,18 +59,18 @@ void _Entry_dispose (_Entry* self) {
|
|||||||
/**/
|
/**/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Skin super;
|
spSkin super;
|
||||||
_Entry* entries;
|
_Entry* entries;
|
||||||
} _Skin;
|
} _spSkin;
|
||||||
|
|
||||||
Skin* Skin_create (const char* name) {
|
spSkin* spSkin_create (const char* name) {
|
||||||
Skin* self = SUPER(NEW(_Skin));
|
spSkin* self = SUPER(NEW(_spSkin));
|
||||||
MALLOC_STR(self->name, name);
|
MALLOC_STR(self->name, name);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skin_dispose (Skin* self) {
|
void spSkin_dispose (spSkin* self) {
|
||||||
_Entry* entry = SUB_CAST(_Skin, self)->entries;
|
_Entry* entry = SUB_CAST(_spSkin, self)->entries;
|
||||||
while (entry) {
|
while (entry) {
|
||||||
_Entry* nextEntry = entry->next;
|
_Entry* nextEntry = entry->next;
|
||||||
_Entry_dispose(entry);
|
_Entry_dispose(entry);
|
||||||
@ -81,14 +81,14 @@ void Skin_dispose (Skin* self) {
|
|||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skin_addAttachment (Skin* self, int slotIndex, const char* name, Attachment* attachment) {
|
void spSkin_addAttachment (spSkin* self, int slotIndex, const char* name, spAttachment* attachment) {
|
||||||
_Entry* newEntry = _Entry_create(slotIndex, name, attachment);
|
_Entry* newEntry = _Entry_create(slotIndex, name, attachment);
|
||||||
newEntry->next = SUB_CAST(_Skin, self)->entries;
|
newEntry->next = SUB_CAST(_spSkin, self)->entries;
|
||||||
SUB_CAST(_Skin, self)->entries = newEntry;
|
SUB_CAST(_spSkin, self)->entries = newEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
Attachment* Skin_getAttachment (const Skin* self, int slotIndex, const char* name) {
|
spAttachment* spSkin_getAttachment (const spSkin* self, int slotIndex, const char* name) {
|
||||||
const _Entry* entry = SUB_CAST(_Skin, self)->entries;
|
const _Entry* entry = SUB_CAST(_spSkin, self)->entries;
|
||||||
while (entry) {
|
while (entry) {
|
||||||
if (entry->slotIndex == slotIndex && strcmp(entry->name, name) == 0) return entry->attachment;
|
if (entry->slotIndex == slotIndex && strcmp(entry->name, name) == 0) return entry->attachment;
|
||||||
entry = entry->next;
|
entry = entry->next;
|
||||||
@ -96,8 +96,8 @@ Attachment* Skin_getAttachment (const Skin* self, int slotIndex, const char* nam
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Skin_getAttachmentName (const Skin* self, int slotIndex, int attachmentIndex) {
|
const char* spSkin_getAttachmentName (const spSkin* self, int slotIndex, int attachmentIndex) {
|
||||||
const _Entry* entry = SUB_CAST(_Skin, self)->entries;
|
const _Entry* entry = SUB_CAST(_spSkin, self)->entries;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (entry) {
|
while (entry) {
|
||||||
if (entry->slotIndex == slotIndex) {
|
if (entry->slotIndex == slotIndex) {
|
||||||
@ -109,13 +109,13 @@ const char* Skin_getAttachmentName (const Skin* self, int slotIndex, int attachm
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skin_attachAll (const Skin* self, Skeleton* skeleton, const Skin* oldSkin) {
|
void spSkin_attachAll (const spSkin* self, spSkeleton* skeleton, const spSkin* oldSkin) {
|
||||||
const _Entry *entry = SUB_CAST(_Skin, oldSkin)->entries;
|
const _Entry *entry = SUB_CAST(_spSkin, oldSkin)->entries;
|
||||||
while (entry) {
|
while (entry) {
|
||||||
Slot *slot = skeleton->slots[entry->slotIndex];
|
spSlot *slot = skeleton->slots[entry->slotIndex];
|
||||||
if (slot->attachment == entry->attachment) {
|
if (slot->attachment == entry->attachment) {
|
||||||
Attachment *attachment = Skin_getAttachment(self, entry->slotIndex, entry->name);
|
spAttachment *attachment = spSkin_getAttachment(self, entry->slotIndex, entry->name);
|
||||||
if (attachment) Slot_setAttachment(slot, attachment);
|
if (attachment) spSlot_setAttachment(slot, attachment);
|
||||||
}
|
}
|
||||||
entry = entry->next;
|
entry = entry->next;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,38 +36,38 @@
|
|||||||
#include <spine/Skeleton.h>
|
#include <spine/Skeleton.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Slot super;
|
spSlot super;
|
||||||
float attachmentTime;
|
float attachmentTime;
|
||||||
} _Slot;
|
} _spSlot;
|
||||||
|
|
||||||
Slot* Slot_create (SlotData* data, Skeleton* skeleton, Bone* bone) {
|
spSlot* spSlot_create (spSlotData* data, spSkeleton* skeleton, spBone* bone) {
|
||||||
Slot* self = SUPER(NEW(_Slot));
|
spSlot* self = SUPER(NEW(_spSlot));
|
||||||
CONST_CAST(SlotData*, self->data) = data;
|
CONST_CAST(spSlotData*, self->data) = data;
|
||||||
CONST_CAST(Skeleton*, self->skeleton) = skeleton;
|
CONST_CAST(spSkeleton*, self->skeleton) = skeleton;
|
||||||
CONST_CAST(Bone*, self->bone) = bone;
|
CONST_CAST(spBone*, self->bone) = bone;
|
||||||
Slot_setToSetupPose(self);
|
spSlot_setToSetupPose(self);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Slot_dispose (Slot* self) {
|
void spSlot_dispose (spSlot* self) {
|
||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Slot_setAttachment (Slot* self, Attachment* attachment) {
|
void spSlot_setAttachment (spSlot* self, spAttachment* attachment) {
|
||||||
CONST_CAST(Attachment*, self->attachment) = attachment;
|
CONST_CAST(spAttachment*, self->attachment) = attachment;
|
||||||
SUB_CAST(_Slot, self) ->attachmentTime = self->skeleton->time;
|
SUB_CAST(_spSlot, self) ->attachmentTime = self->skeleton->time;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Slot_setAttachmentTime (Slot* self, float time) {
|
void spSlot_setAttachmentTime (spSlot* self, float time) {
|
||||||
SUB_CAST(_Slot, self) ->attachmentTime = self->skeleton->time - time;
|
SUB_CAST(_spSlot, self) ->attachmentTime = self->skeleton->time - time;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Slot_getAttachmentTime (const Slot* self) {
|
float spSlot_getAttachmentTime (const spSlot* self) {
|
||||||
return self->skeleton->time - SUB_CAST(_Slot, self) ->attachmentTime;
|
return self->skeleton->time - SUB_CAST(_spSlot, self) ->attachmentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Slot_setToSetupPose (Slot* self) {
|
void spSlot_setToSetupPose (spSlot* self) {
|
||||||
Attachment* attachment = 0;
|
spAttachment* attachment = 0;
|
||||||
self->r = self->data->r;
|
self->r = self->data->r;
|
||||||
self->g = self->data->g;
|
self->g = self->data->g;
|
||||||
self->b = self->data->b;
|
self->b = self->data->b;
|
||||||
@ -78,10 +78,10 @@ void Slot_setToSetupPose (Slot* self) {
|
|||||||
int i;
|
int i;
|
||||||
for (i = 0; i < self->skeleton->data->slotCount; ++i) {
|
for (i = 0; i < self->skeleton->data->slotCount; ++i) {
|
||||||
if (self->data == self->skeleton->data->slots[i]) {
|
if (self->data == self->skeleton->data->slots[i]) {
|
||||||
attachment = Skeleton_getAttachmentForSlotIndex(self->skeleton, i, self->data->attachmentName);
|
attachment = spSkeleton_getAttachmentForSlotIndex(self->skeleton, i, self->data->attachmentName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Slot_setAttachment(self, attachment);
|
spSlot_setAttachment(self, attachment);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,10 +34,10 @@
|
|||||||
#include <spine/SlotData.h>
|
#include <spine/SlotData.h>
|
||||||
#include <spine/extension.h>
|
#include <spine/extension.h>
|
||||||
|
|
||||||
SlotData* SlotData_create (const char* name, BoneData* boneData) {
|
spSlotData* spSlotData_create (const char* name, spBoneData* boneData) {
|
||||||
SlotData* self = NEW(SlotData);
|
spSlotData* self = NEW(spSlotData);
|
||||||
MALLOC_STR(self->name, name);
|
MALLOC_STR(self->name, name);
|
||||||
CONST_CAST(BoneData*, self->boneData) = boneData;
|
CONST_CAST(spBoneData*, self->boneData) = boneData;
|
||||||
self->r = 1;
|
self->r = 1;
|
||||||
self->g = 1;
|
self->g = 1;
|
||||||
self->b = 1;
|
self->b = 1;
|
||||||
@ -45,13 +45,13 @@ SlotData* SlotData_create (const char* name, BoneData* boneData) {
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlotData_dispose (SlotData* self) {
|
void spSlotData_dispose (spSlotData* self) {
|
||||||
FREE(self->name);
|
FREE(self->name);
|
||||||
FREE(self->attachmentName);
|
FREE(self->attachmentName);
|
||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlotData_setAttachmentName (SlotData* self, const char* attachmentName) {
|
void spSlotData_setAttachmentName (spSlotData* self, const char* attachmentName) {
|
||||||
FREE(self->attachmentName);
|
FREE(self->attachmentName);
|
||||||
if (attachmentName)
|
if (attachmentName)
|
||||||
MALLOC_STR(self->attachmentName, attachmentName);
|
MALLOC_STR(self->attachmentName, attachmentName);
|
||||||
|
|||||||
@ -31,6 +31,7 @@
|
|||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#define SPINE_SHORT_NAMES
|
||||||
#import <spine/spine.h>
|
#import <spine/spine.h>
|
||||||
#import "cocos2d.h"
|
#import "cocos2d.h"
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,7 @@
|
|||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#define SPINE_SHORT_NAMES
|
||||||
#import <spine/spine.h>
|
#import <spine/spine.h>
|
||||||
#import <spine/CCSkeleton.h>
|
#import <spine/CCSkeleton.h>
|
||||||
#import "cocos2d.h"
|
#import "cocos2d.h"
|
||||||
|
|||||||
@ -31,6 +31,7 @@
|
|||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#define SPINE_SHORT_NAMES
|
||||||
#import <spine/spine.h>
|
#import <spine/spine.h>
|
||||||
#import "cocos2d.h"
|
#import "cocos2d.h"
|
||||||
#import "CCSkeleton.h"
|
#import "CCSkeleton.h"
|
||||||
|
|||||||
@ -51,8 +51,8 @@ void ExampleLayer::update (float deltaTime) {
|
|||||||
// if (entry->time > 0.1) CCDirector::sharedDirector()->replaceScene(ExampleLayer::scene());
|
// if (entry->time > 0.1) CCDirector::sharedDirector()->replaceScene(ExampleLayer::scene());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExampleLayer::animationStateEvent (CCSkeletonAnimation* node, int trackIndex, EventType type, Event* event, int loopCount) {
|
void ExampleLayer::animationStateEvent (CCSkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount) {
|
||||||
TrackEntry* entry = AnimationState_getCurrent(node->state, trackIndex);
|
spTrackEntry* entry = spAnimationState_getCurrent(node->state, trackIndex);
|
||||||
const char* animationName = (entry && entry->animation) ? entry->animation->name : 0;
|
const char* animationName = (entry && entry->animation) ? entry->animation->name : 0;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|||||||
@ -17,7 +17,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
spine::CCSkeletonAnimation* skeletonNode;
|
spine::CCSkeletonAnimation* skeletonNode;
|
||||||
|
|
||||||
void animationStateEvent (spine::CCSkeletonAnimation* node, int trackIndex, EventType type, Event* event, int loopCount);
|
void animationStateEvent (spine::CCSkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _EXAMPLELAYER_H_
|
#endif // _EXAMPLELAYER_H_
|
||||||
@ -40,13 +40,13 @@ using std::max;
|
|||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
CCSkeleton* CCSkeleton::createWithData (SkeletonData* skeletonData, bool ownsSkeletonData) {
|
CCSkeleton* CCSkeleton::createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData) {
|
||||||
CCSkeleton* node = new CCSkeleton(skeletonData, ownsSkeletonData);
|
CCSkeleton* node = new CCSkeleton(skeletonData, ownsSkeletonData);
|
||||||
node->autorelease();
|
node->autorelease();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton* CCSkeleton::createWithFile (const char* skeletonDataFile, Atlas* atlas, float scale) {
|
CCSkeleton* CCSkeleton::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) {
|
||||||
CCSkeleton* node = new CCSkeleton(skeletonDataFile, atlas, scale);
|
CCSkeleton* node = new CCSkeleton(skeletonDataFile, atlas, scale);
|
||||||
node->autorelease();
|
node->autorelease();
|
||||||
return node;
|
return node;
|
||||||
@ -72,8 +72,8 @@ void CCSkeleton::initialize () {
|
|||||||
scheduleUpdate();
|
scheduleUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::setSkeletonData (SkeletonData *skeletonData, bool ownsSkeletonData) {
|
void CCSkeleton::setSkeletonData (spSkeletonData *skeletonData, bool ownsSkeletonData) {
|
||||||
skeleton = Skeleton_create(skeletonData);
|
skeleton = spSkeleton_create(skeletonData);
|
||||||
rootBone = skeleton->bones[0];
|
rootBone = skeleton->bones[0];
|
||||||
this->ownsSkeletonData = ownsSkeletonData;
|
this->ownsSkeletonData = ownsSkeletonData;
|
||||||
}
|
}
|
||||||
@ -82,20 +82,20 @@ CCSkeleton::CCSkeleton () {
|
|||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton::CCSkeleton (SkeletonData *skeletonData, bool ownsSkeletonData) {
|
CCSkeleton::CCSkeleton (spSkeletonData *skeletonData, bool ownsSkeletonData) {
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
setSkeletonData(skeletonData, ownsSkeletonData);
|
setSkeletonData(skeletonData, ownsSkeletonData);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton::CCSkeleton (const char* skeletonDataFile, Atlas* atlas, float scale) {
|
CCSkeleton::CCSkeleton (const char* skeletonDataFile, spAtlas* atlas, float scale) {
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
SkeletonJson* json = SkeletonJson_create(atlas);
|
spSkeletonJson* json = spSkeletonJson_create(atlas);
|
||||||
json->scale = scale;
|
json->scale = scale;
|
||||||
SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, skeletonDataFile);
|
spSkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(json, skeletonDataFile);
|
||||||
CCAssert(skeletonData, json->error ? json->error : "Error reading skeleton data.");
|
CCAssert(skeletonData, json->error ? json->error : "Error reading skeleton data.");
|
||||||
SkeletonJson_dispose(json);
|
spSkeletonJson_dispose(json);
|
||||||
|
|
||||||
setSkeletonData(skeletonData, true);
|
setSkeletonData(skeletonData, true);
|
||||||
}
|
}
|
||||||
@ -103,26 +103,26 @@ CCSkeleton::CCSkeleton (const char* skeletonDataFile, Atlas* atlas, float scale)
|
|||||||
CCSkeleton::CCSkeleton (const char* skeletonDataFile, const char* atlasFile, float scale) {
|
CCSkeleton::CCSkeleton (const char* skeletonDataFile, const char* atlasFile, float scale) {
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
atlas = Atlas_readAtlasFile(atlasFile);
|
atlas = spAtlas_readAtlasFile(atlasFile);
|
||||||
CCAssert(atlas, "Error reading atlas file.");
|
CCAssert(atlas, "Error reading atlas file.");
|
||||||
|
|
||||||
SkeletonJson* json = SkeletonJson_create(atlas);
|
spSkeletonJson* json = spSkeletonJson_create(atlas);
|
||||||
json->scale = scale;
|
json->scale = scale;
|
||||||
SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, skeletonDataFile);
|
spSkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(json, skeletonDataFile);
|
||||||
CCAssert(skeletonData, json->error ? json->error : "Error reading skeleton data file.");
|
CCAssert(skeletonData, json->error ? json->error : "Error reading skeleton data file.");
|
||||||
SkeletonJson_dispose(json);
|
spSkeletonJson_dispose(json);
|
||||||
|
|
||||||
setSkeletonData(skeletonData, true);
|
setSkeletonData(skeletonData, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton::~CCSkeleton () {
|
CCSkeleton::~CCSkeleton () {
|
||||||
if (ownsSkeletonData) SkeletonData_dispose(skeleton->data);
|
if (ownsSkeletonData) spSkeletonData_dispose(skeleton->data);
|
||||||
if (atlas) Atlas_dispose(atlas);
|
if (atlas) spAtlas_dispose(atlas);
|
||||||
Skeleton_dispose(skeleton);
|
spSkeleton_dispose(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::update (float deltaTime) {
|
void CCSkeleton::update (float deltaTime) {
|
||||||
Skeleton_update(skeleton, deltaTime * timeScale);
|
spSkeleton_update(skeleton, deltaTime * timeScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::draw () {
|
void CCSkeleton::draw () {
|
||||||
@ -148,9 +148,9 @@ void CCSkeleton::draw () {
|
|||||||
quad.bl.vertices.z = 0;
|
quad.bl.vertices.z = 0;
|
||||||
quad.br.vertices.z = 0;
|
quad.br.vertices.z = 0;
|
||||||
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
|
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
|
||||||
Slot* slot = skeleton->drawOrder[i];
|
spSlot* slot = skeleton->drawOrder[i];
|
||||||
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
|
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
|
||||||
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
|
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
|
||||||
CCTextureAtlas* regionTextureAtlas = getTextureAtlas(attachment);
|
CCTextureAtlas* regionTextureAtlas = getTextureAtlas(attachment);
|
||||||
|
|
||||||
if (slot->data->additiveBlending != additive) {
|
if (slot->data->additiveBlending != additive) {
|
||||||
@ -173,7 +173,7 @@ void CCSkeleton::draw () {
|
|||||||
if (!textureAtlas->resizeCapacity(textureAtlas->getCapacity() * 2)) return;
|
if (!textureAtlas->resizeCapacity(textureAtlas->getCapacity() * 2)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionAttachment_updateQuad(attachment, slot, &quad, premultipliedAlpha);
|
spRegionAttachment_updateQuad(attachment, slot, &quad, premultipliedAlpha);
|
||||||
textureAtlas->updateQuad(&quad, quadCount);
|
textureAtlas->updateQuad(&quad, quadCount);
|
||||||
}
|
}
|
||||||
if (textureAtlas) {
|
if (textureAtlas) {
|
||||||
@ -188,10 +188,10 @@ void CCSkeleton::draw () {
|
|||||||
CCPoint points[4];
|
CCPoint points[4];
|
||||||
ccV3F_C4B_T2F_Quad quad;
|
ccV3F_C4B_T2F_Quad quad;
|
||||||
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
|
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
|
||||||
Slot* slot = skeleton->drawOrder[i];
|
spSlot* slot = skeleton->drawOrder[i];
|
||||||
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
|
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
|
||||||
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
|
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
|
||||||
RegionAttachment_updateQuad(attachment, slot, &quad);
|
spRegionAttachment_updateQuad(attachment, slot, &quad);
|
||||||
points[0] = ccp(quad.bl.vertices.x, quad.bl.vertices.y);
|
points[0] = ccp(quad.bl.vertices.x, quad.bl.vertices.y);
|
||||||
points[1] = ccp(quad.br.vertices.x, quad.br.vertices.y);
|
points[1] = ccp(quad.br.vertices.x, quad.br.vertices.y);
|
||||||
points[2] = ccp(quad.tr.vertices.x, quad.tr.vertices.y);
|
points[2] = ccp(quad.tr.vertices.x, quad.tr.vertices.y);
|
||||||
@ -204,7 +204,7 @@ void CCSkeleton::draw () {
|
|||||||
glLineWidth(2);
|
glLineWidth(2);
|
||||||
ccDrawColor4B(255, 0, 0, 255);
|
ccDrawColor4B(255, 0, 0, 255);
|
||||||
for (int i = 0, n = skeleton->boneCount; i < n; i++) {
|
for (int i = 0, n = skeleton->boneCount; i < n; i++) {
|
||||||
Bone *bone = skeleton->bones[i];
|
spBone *bone = skeleton->bones[i];
|
||||||
float x = bone->data->length * bone->m00 + bone->worldX;
|
float x = bone->data->length * bone->m00 + bone->worldX;
|
||||||
float y = bone->data->length * bone->m10 + bone->worldY;
|
float y = bone->data->length * bone->m10 + bone->worldY;
|
||||||
ccDrawLine(ccp(bone->worldX, bone->worldY), ccp(x, y));
|
ccDrawLine(ccp(bone->worldX, bone->worldY), ccp(x, y));
|
||||||
@ -213,15 +213,15 @@ void CCSkeleton::draw () {
|
|||||||
ccPointSize(4);
|
ccPointSize(4);
|
||||||
ccDrawColor4B(0, 0, 255, 255); // Root bone is blue.
|
ccDrawColor4B(0, 0, 255, 255); // Root bone is blue.
|
||||||
for (int i = 0, n = skeleton->boneCount; i < n; i++) {
|
for (int i = 0, n = skeleton->boneCount; i < n; i++) {
|
||||||
Bone *bone = skeleton->bones[i];
|
spBone *bone = skeleton->bones[i];
|
||||||
ccDrawPoint(ccp(bone->worldX, bone->worldY));
|
ccDrawPoint(ccp(bone->worldX, bone->worldY));
|
||||||
if (i == 0) ccDrawColor4B(0, 255, 0, 255);
|
if (i == 0) ccDrawColor4B(0, 255, 0, 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CCTextureAtlas* CCSkeleton::getTextureAtlas (RegionAttachment* regionAttachment) const {
|
CCTextureAtlas* CCSkeleton::getTextureAtlas (spRegionAttachment* regionAttachment) const {
|
||||||
return (CCTextureAtlas*)((AtlasRegion*)regionAttachment->rendererObject)->page->rendererObject;
|
return (CCTextureAtlas*)((spAtlasRegion*)regionAttachment->rendererObject)->page->rendererObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCRect CCSkeleton::boundingBox () {
|
CCRect CCSkeleton::boundingBox () {
|
||||||
@ -230,10 +230,10 @@ CCRect CCSkeleton::boundingBox () {
|
|||||||
float scaleY = getScaleY();
|
float scaleY = getScaleY();
|
||||||
float vertices[8];
|
float vertices[8];
|
||||||
for (int i = 0; i < skeleton->slotCount; ++i) {
|
for (int i = 0; i < skeleton->slotCount; ++i) {
|
||||||
Slot* slot = skeleton->slots[i];
|
spSlot* slot = skeleton->slots[i];
|
||||||
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
|
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
|
||||||
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
|
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
|
||||||
RegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, vertices);
|
spRegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, vertices);
|
||||||
minX = min(minX, vertices[VERTEX_X1] * scaleX);
|
minX = min(minX, vertices[VERTEX_X1] * scaleX);
|
||||||
minY = min(minY, vertices[VERTEX_Y1] * scaleY);
|
minY = min(minY, vertices[VERTEX_Y1] * scaleY);
|
||||||
maxX = max(maxX, vertices[VERTEX_X1] * scaleX);
|
maxX = max(maxX, vertices[VERTEX_X1] * scaleX);
|
||||||
@ -258,36 +258,36 @@ CCRect CCSkeleton::boundingBox () {
|
|||||||
// --- Convenience methods for Skeleton_* functions.
|
// --- Convenience methods for Skeleton_* functions.
|
||||||
|
|
||||||
void CCSkeleton::updateWorldTransform () {
|
void CCSkeleton::updateWorldTransform () {
|
||||||
Skeleton_updateWorldTransform(skeleton);
|
spSkeleton_updateWorldTransform(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::setToSetupPose () {
|
void CCSkeleton::setToSetupPose () {
|
||||||
Skeleton_setToSetupPose(skeleton);
|
spSkeleton_setToSetupPose(skeleton);
|
||||||
}
|
}
|
||||||
void CCSkeleton::setBonesToSetupPose () {
|
void CCSkeleton::setBonesToSetupPose () {
|
||||||
Skeleton_setBonesToSetupPose(skeleton);
|
spSkeleton_setBonesToSetupPose(skeleton);
|
||||||
}
|
}
|
||||||
void CCSkeleton::setSlotsToSetupPose () {
|
void CCSkeleton::setSlotsToSetupPose () {
|
||||||
Skeleton_setSlotsToSetupPose(skeleton);
|
spSkeleton_setSlotsToSetupPose(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bone* CCSkeleton::findBone (const char* boneName) const {
|
spBone* CCSkeleton::findBone (const char* boneName) const {
|
||||||
return Skeleton_findBone(skeleton, boneName);
|
return spSkeleton_findBone(skeleton, boneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Slot* CCSkeleton::findSlot (const char* slotName) const {
|
spSlot* CCSkeleton::findSlot (const char* slotName) const {
|
||||||
return Skeleton_findSlot(skeleton, slotName);
|
return spSkeleton_findSlot(skeleton, slotName);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCSkeleton::setSkin (const char* skinName) {
|
bool CCSkeleton::setSkin (const char* skinName) {
|
||||||
return Skeleton_setSkinByName(skeleton, skinName) ? true : false;
|
return spSkeleton_setSkinByName(skeleton, skinName) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Attachment* CCSkeleton::getAttachment (const char* slotName, const char* attachmentName) const {
|
spAttachment* CCSkeleton::getAttachment (const char* slotName, const char* attachmentName) const {
|
||||||
return Skeleton_getAttachmentForSlotName(skeleton, slotName, attachmentName);
|
return spSkeleton_getAttachmentForSlotName(skeleton, slotName, attachmentName);
|
||||||
}
|
}
|
||||||
bool CCSkeleton::setAttachment (const char* slotName, const char* attachmentName) {
|
bool CCSkeleton::setAttachment (const char* slotName, const char* attachmentName) {
|
||||||
return Skeleton_setAttachment(skeleton, slotName, attachmentName) ? true : false;
|
return spSkeleton_setAttachment(skeleton, slotName, attachmentName) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- CCBlendProtocol
|
// --- CCBlendProtocol
|
||||||
|
|||||||
@ -42,19 +42,19 @@ namespace spine {
|
|||||||
/** Draws a skeleton. */
|
/** Draws a skeleton. */
|
||||||
class CCSkeleton: public cocos2d::CCNodeRGBA, public cocos2d::CCBlendProtocol {
|
class CCSkeleton: public cocos2d::CCNodeRGBA, public cocos2d::CCBlendProtocol {
|
||||||
public:
|
public:
|
||||||
Skeleton* skeleton;
|
spSkeleton* skeleton;
|
||||||
Bone* rootBone;
|
spBone* rootBone;
|
||||||
float timeScale;
|
float timeScale;
|
||||||
bool debugSlots;
|
bool debugSlots;
|
||||||
bool debugBones;
|
bool debugBones;
|
||||||
bool premultipliedAlpha;
|
bool premultipliedAlpha;
|
||||||
|
|
||||||
static CCSkeleton* createWithData (SkeletonData* skeletonData, bool ownsSkeletonData = false);
|
static CCSkeleton* createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
|
||||||
static CCSkeleton* createWithFile (const char* skeletonDataFile, Atlas* atlas, float scale = 1);
|
static CCSkeleton* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 1);
|
||||||
static CCSkeleton* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 1);
|
static CCSkeleton* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 1);
|
||||||
|
|
||||||
CCSkeleton (SkeletonData* skeletonData, bool ownsSkeletonData = false);
|
CCSkeleton (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
|
||||||
CCSkeleton (const char* skeletonDataFile, Atlas* atlas, float scale = 1);
|
CCSkeleton (const char* skeletonDataFile, spAtlas* atlas, float scale = 1);
|
||||||
CCSkeleton (const char* skeletonDataFile, const char* atlasFile, float scale = 1);
|
CCSkeleton (const char* skeletonDataFile, const char* atlasFile, float scale = 1);
|
||||||
|
|
||||||
virtual ~CCSkeleton ();
|
virtual ~CCSkeleton ();
|
||||||
@ -71,9 +71,9 @@ public:
|
|||||||
void setSlotsToSetupPose ();
|
void setSlotsToSetupPose ();
|
||||||
|
|
||||||
/* Returns 0 if the bone was not found. */
|
/* Returns 0 if the bone was not found. */
|
||||||
Bone* findBone (const char* boneName) const;
|
spBone* findBone (const char* boneName) const;
|
||||||
/* Returns 0 if the slot was not found. */
|
/* Returns 0 if the slot was not found. */
|
||||||
Slot* findSlot (const char* slotName) const;
|
spSlot* findSlot (const char* slotName) const;
|
||||||
|
|
||||||
/* Sets the skin used to look up attachments not found in the SkeletonData defaultSkin. Attachments from the new skin are
|
/* Sets the skin used to look up attachments not found in the SkeletonData defaultSkin. Attachments from the new skin are
|
||||||
* attached if the corresponding attachment from the old skin was attached. Returns false if the skin was not found.
|
* attached if the corresponding attachment from the old skin was attached. Returns false if the skin was not found.
|
||||||
@ -81,7 +81,7 @@ public:
|
|||||||
bool setSkin (const char* skinName);
|
bool setSkin (const char* skinName);
|
||||||
|
|
||||||
/* Returns 0 if the slot or attachment was not found. */
|
/* Returns 0 if the slot or attachment was not found. */
|
||||||
Attachment* getAttachment (const char* slotName, const char* attachmentName) const;
|
spAttachment* getAttachment (const char* slotName, const char* attachmentName) const;
|
||||||
/* Returns false if the slot or attachment was not found. */
|
/* Returns false if the slot or attachment was not found. */
|
||||||
bool setAttachment (const char* slotName, const char* attachmentName);
|
bool setAttachment (const char* slotName, const char* attachmentName);
|
||||||
|
|
||||||
@ -92,12 +92,12 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
CCSkeleton ();
|
CCSkeleton ();
|
||||||
void setSkeletonData (SkeletonData* skeletonData, bool ownsSkeletonData);
|
void setSkeletonData (spSkeletonData* skeletonData, bool ownsSkeletonData);
|
||||||
cocos2d::CCTextureAtlas* getTextureAtlas (RegionAttachment* regionAttachment) const;
|
cocos2d::CCTextureAtlas* getTextureAtlas (spRegionAttachment* regionAttachment) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool ownsSkeletonData;
|
bool ownsSkeletonData;
|
||||||
Atlas* atlas;
|
spAtlas* atlas;
|
||||||
void initialize ();
|
void initialize ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -42,17 +42,17 @@ using std::vector;
|
|||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
static void callback (AnimationState* state, int trackIndex, EventType type, Event* event, int loopCount) {
|
static void callback (spAnimationState* state, int trackIndex, spEventType type, spEvent* event, int loopCount) {
|
||||||
((CCSkeletonAnimation*)state->context)->onAnimationStateEvent(trackIndex, type, event, loopCount);
|
((CCSkeletonAnimation*)state->context)->onAnimationStateEvent(trackIndex, type, event, loopCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeletonAnimation* CCSkeletonAnimation::createWithData (SkeletonData* skeletonData) {
|
CCSkeletonAnimation* CCSkeletonAnimation::createWithData (spSkeletonData* skeletonData) {
|
||||||
CCSkeletonAnimation* node = new CCSkeletonAnimation(skeletonData);
|
CCSkeletonAnimation* node = new CCSkeletonAnimation(skeletonData);
|
||||||
node->autorelease();
|
node->autorelease();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeletonAnimation* CCSkeletonAnimation::createWithFile (const char* skeletonDataFile, Atlas* atlas, float scale) {
|
CCSkeletonAnimation* CCSkeletonAnimation::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) {
|
||||||
CCSkeletonAnimation* node = new CCSkeletonAnimation(skeletonDataFile, atlas, scale);
|
CCSkeletonAnimation* node = new CCSkeletonAnimation(skeletonDataFile, atlas, scale);
|
||||||
node->autorelease();
|
node->autorelease();
|
||||||
return node;
|
return node;
|
||||||
@ -68,17 +68,17 @@ void CCSkeletonAnimation::initialize () {
|
|||||||
listenerInstance = 0;
|
listenerInstance = 0;
|
||||||
listenerMethod = 0;
|
listenerMethod = 0;
|
||||||
|
|
||||||
state = AnimationState_create(AnimationStateData_create(skeleton->data));
|
state = spAnimationState_create(spAnimationStateData_create(skeleton->data));
|
||||||
state->context = this;
|
state->context = this;
|
||||||
state->listener = callback;
|
state->listener = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeletonAnimation::CCSkeletonAnimation (SkeletonData *skeletonData)
|
CCSkeletonAnimation::CCSkeletonAnimation (spSkeletonData *skeletonData)
|
||||||
: CCSkeleton(skeletonData) {
|
: CCSkeleton(skeletonData) {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeletonAnimation::CCSkeletonAnimation (const char* skeletonDataFile, Atlas* atlas, float scale)
|
CCSkeletonAnimation::CCSkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale)
|
||||||
: CCSkeleton(skeletonDataFile, atlas, scale) {
|
: CCSkeleton(skeletonDataFile, atlas, scale) {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
@ -89,33 +89,33 @@ CCSkeletonAnimation::CCSkeletonAnimation (const char* skeletonDataFile, const ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
CCSkeletonAnimation::~CCSkeletonAnimation () {
|
CCSkeletonAnimation::~CCSkeletonAnimation () {
|
||||||
if (ownsAnimationStateData) AnimationStateData_dispose(state->data);
|
if (ownsAnimationStateData) spAnimationStateData_dispose(state->data);
|
||||||
AnimationState_dispose(state);
|
spAnimationState_dispose(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::update (float deltaTime) {
|
void CCSkeletonAnimation::update (float deltaTime) {
|
||||||
super::update(deltaTime);
|
super::update(deltaTime);
|
||||||
|
|
||||||
deltaTime *= timeScale;
|
deltaTime *= timeScale;
|
||||||
AnimationState_update(state, deltaTime);
|
spAnimationState_update(state, deltaTime);
|
||||||
AnimationState_apply(state, skeleton);
|
spAnimationState_apply(state, skeleton);
|
||||||
Skeleton_updateWorldTransform(skeleton);
|
spSkeleton_updateWorldTransform(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::setAnimationStateData (AnimationStateData* stateData) {
|
void CCSkeletonAnimation::setAnimationStateData (spAnimationStateData* stateData) {
|
||||||
CCAssert(stateData, "stateData cannot be null.");
|
CCAssert(stateData, "stateData cannot be null.");
|
||||||
|
|
||||||
if (ownsAnimationStateData) AnimationStateData_dispose(state->data);
|
if (ownsAnimationStateData) spAnimationStateData_dispose(state->data);
|
||||||
AnimationState_dispose(state);
|
spAnimationState_dispose(state);
|
||||||
|
|
||||||
ownsAnimationStateData = true;
|
ownsAnimationStateData = true;
|
||||||
state = AnimationState_create(stateData);
|
state = spAnimationState_create(stateData);
|
||||||
state->context = this;
|
state->context = this;
|
||||||
state->listener = callback;
|
state->listener = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::setMix (const char* fromAnimation, const char* toAnimation, float duration) {
|
void CCSkeletonAnimation::setMix (const char* fromAnimation, const char* toAnimation, float duration) {
|
||||||
AnimationStateData_setMixByName(state->data, fromAnimation, toAnimation, duration);
|
spAnimationStateData_setMixByName(state->data, fromAnimation, toAnimation, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::setAnimationListener (CCObject* instance, SEL_AnimationStateEvent method) {
|
void CCSkeletonAnimation::setAnimationListener (CCObject* instance, SEL_AnimationStateEvent method) {
|
||||||
@ -123,37 +123,37 @@ void CCSkeletonAnimation::setAnimationListener (CCObject* instance, SEL_Animatio
|
|||||||
listenerMethod = method;
|
listenerMethod = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry* CCSkeletonAnimation::setAnimation (int trackIndex, const char* name, bool loop) {
|
spTrackEntry* CCSkeletonAnimation::setAnimation (int trackIndex, const char* name, bool loop) {
|
||||||
Animation* animation = SkeletonData_findAnimation(skeleton->data, name);
|
spAnimation* animation = spSkeletonData_findAnimation(skeleton->data, name);
|
||||||
if (!animation) {
|
if (!animation) {
|
||||||
CCLog("Spine: Animation not found: %s", name);
|
CCLog("Spine: Animation not found: %s", name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return AnimationState_setAnimation(state, trackIndex, animation, loop);
|
return spAnimationState_setAnimation(state, trackIndex, animation, loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry* CCSkeletonAnimation::addAnimation (int trackIndex, const char* name, bool loop, float delay) {
|
spTrackEntry* CCSkeletonAnimation::addAnimation (int trackIndex, const char* name, bool loop, float delay) {
|
||||||
Animation* animation = SkeletonData_findAnimation(skeleton->data, name);
|
spAnimation* animation = spSkeletonData_findAnimation(skeleton->data, name);
|
||||||
if (!animation) {
|
if (!animation) {
|
||||||
CCLog("Spine: Animation not found: %s", name);
|
CCLog("Spine: Animation not found: %s", name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return AnimationState_addAnimation(state, trackIndex, animation, loop, delay);
|
return spAnimationState_addAnimation(state, trackIndex, animation, loop, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry* CCSkeletonAnimation::getCurrent (int trackIndex) {
|
spTrackEntry* CCSkeletonAnimation::getCurrent (int trackIndex) {
|
||||||
return AnimationState_getCurrent(state, trackIndex);
|
return spAnimationState_getCurrent(state, trackIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::clearTracks () {
|
void CCSkeletonAnimation::clearTracks () {
|
||||||
AnimationState_clearTracks(state);
|
spAnimationState_clearTracks(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::clearTrack (int trackIndex) {
|
void CCSkeletonAnimation::clearTrack (int trackIndex) {
|
||||||
AnimationState_clearTrack(state, trackIndex);
|
spAnimationState_clearTrack(state, trackIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::onAnimationStateEvent (int trackIndex, EventType type, Event* event, int loopCount) {
|
void CCSkeletonAnimation::onAnimationStateEvent (int trackIndex, spEventType type, spEvent* event, int loopCount) {
|
||||||
if (listenerInstance) (listenerInstance->*listenerMethod)(this, trackIndex, type, event, loopCount);
|
if (listenerInstance) (listenerInstance->*listenerMethod)(this, trackIndex, type, event, loopCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,38 +41,38 @@
|
|||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
class CCSkeletonAnimation;
|
class CCSkeletonAnimation;
|
||||||
typedef void (cocos2d::CCObject::*SEL_AnimationStateEvent)(spine::CCSkeletonAnimation* node, int trackIndex, EventType type, Event* event, int loopCount);
|
typedef void (cocos2d::CCObject::*SEL_AnimationStateEvent)(spine::CCSkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount);
|
||||||
#define animationStateEvent_selector(_SELECTOR) (SEL_AnimationStateEvent)(&_SELECTOR)
|
#define animationStateEvent_selector(_SELECTOR) (SEL_AnimationStateEvent)(&_SELECTOR)
|
||||||
|
|
||||||
/** Draws an animated skeleton, providing an AnimationState for applying one or more animations and queuing animations to be
|
/** Draws an animated skeleton, providing an AnimationState for applying one or more animations and queuing animations to be
|
||||||
* played later. */
|
* played later. */
|
||||||
class CCSkeletonAnimation: public CCSkeleton {
|
class CCSkeletonAnimation: public CCSkeleton {
|
||||||
public:
|
public:
|
||||||
AnimationState* state;
|
spAnimationState* state;
|
||||||
|
|
||||||
static CCSkeletonAnimation* createWithData (SkeletonData* skeletonData);
|
static CCSkeletonAnimation* createWithData (spSkeletonData* skeletonData);
|
||||||
static CCSkeletonAnimation* createWithFile (const char* skeletonDataFile, Atlas* atlas, float scale = 1);
|
static CCSkeletonAnimation* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 1);
|
||||||
static CCSkeletonAnimation* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 1);
|
static CCSkeletonAnimation* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 1);
|
||||||
|
|
||||||
CCSkeletonAnimation (SkeletonData* skeletonData);
|
CCSkeletonAnimation (spSkeletonData* skeletonData);
|
||||||
CCSkeletonAnimation (const char* skeletonDataFile, Atlas* atlas, float scale = 1);
|
CCSkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale = 1);
|
||||||
CCSkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale = 1);
|
CCSkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale = 1);
|
||||||
|
|
||||||
virtual ~CCSkeletonAnimation ();
|
virtual ~CCSkeletonAnimation ();
|
||||||
|
|
||||||
virtual void update (float deltaTime);
|
virtual void update (float deltaTime);
|
||||||
|
|
||||||
void setAnimationStateData (AnimationStateData* stateData);
|
void setAnimationStateData (spAnimationStateData* stateData);
|
||||||
void setMix (const char* fromAnimation, const char* toAnimation, float duration);
|
void setMix (const char* fromAnimation, const char* toAnimation, float duration);
|
||||||
|
|
||||||
void setAnimationListener (CCObject* instance, SEL_AnimationStateEvent method);
|
void setAnimationListener (CCObject* instance, SEL_AnimationStateEvent method);
|
||||||
TrackEntry* setAnimation (int trackIndex, const char* name, bool loop);
|
spTrackEntry* setAnimation (int trackIndex, const char* name, bool loop);
|
||||||
TrackEntry* addAnimation (int trackIndex, const char* name, bool loop, float delay = 0);
|
spTrackEntry* addAnimation (int trackIndex, const char* name, bool loop, float delay = 0);
|
||||||
TrackEntry* getCurrent (int trackIndex = 0);
|
spTrackEntry* getCurrent (int trackIndex = 0);
|
||||||
void clearTracks ();
|
void clearTracks ();
|
||||||
void clearTrack (int trackIndex = 0);
|
void clearTrack (int trackIndex = 0);
|
||||||
|
|
||||||
void onAnimationStateEvent (int trackIndex, EventType type, Event* event, int loopCount);
|
void onAnimationStateEvent (int trackIndex, spEventType type, spEvent* event, int loopCount);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CCSkeletonAnimation ();
|
CCSkeletonAnimation ();
|
||||||
|
|||||||
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
USING_NS_CC;
|
USING_NS_CC;
|
||||||
|
|
||||||
void _AtlasPage_createTexture (AtlasPage* self, const char* path) {
|
void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) {
|
||||||
CCTexture2D* texture = CCTextureCache::sharedTextureCache()->addImage(path);
|
CCTexture2D* texture = CCTextureCache::sharedTextureCache()->addImage(path);
|
||||||
CCTextureAtlas* textureAtlas = CCTextureAtlas::createWithTexture(texture, 128);
|
CCTextureAtlas* textureAtlas = CCTextureAtlas::createWithTexture(texture, 128);
|
||||||
textureAtlas->retain();
|
textureAtlas->retain();
|
||||||
@ -45,11 +45,11 @@ void _AtlasPage_createTexture (AtlasPage* self, const char* path) {
|
|||||||
self->height = texture->getPixelsHigh();
|
self->height = texture->getPixelsHigh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _AtlasPage_disposeTexture (AtlasPage* self) {
|
void _spAtlasPage_disposeTexture (spAtlasPage* self) {
|
||||||
((CCTextureAtlas*)self->rendererObject)->release();
|
((CCTextureAtlas*)self->rendererObject)->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
char* _Util_readFile (const char* path, int* length) {
|
char* _spUtil_readFile (const char* path, int* length) {
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
char* data = reinterpret_cast<char*>(CCFileUtils::sharedFileUtils()->getFileData(
|
char* data = reinterpret_cast<char*>(CCFileUtils::sharedFileUtils()->getFileData(
|
||||||
CCFileUtils::sharedFileUtils()->fullPathForFilename(path).c_str(), "r", &size));
|
CCFileUtils::sharedFileUtils()->fullPathForFilename(path).c_str(), "r", &size));
|
||||||
@ -59,9 +59,9 @@ char* _Util_readFile (const char* path, int* length) {
|
|||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
void RegionAttachment_updateQuad (RegionAttachment* self, Slot* slot, ccV3F_C4B_T2F_Quad* quad, bool premultipliedAlpha) {
|
void spRegionAttachment_updateQuad (spRegionAttachment* self, spSlot* slot, ccV3F_C4B_T2F_Quad* quad, bool premultipliedAlpha) {
|
||||||
float vertices[8];
|
float vertices[8];
|
||||||
RegionAttachment_computeWorldVertices(self, slot->skeleton->x, slot->skeleton->y, slot->bone, vertices);
|
spRegionAttachment_computeWorldVertices(self, slot->skeleton->x, slot->skeleton->y, slot->bone, vertices);
|
||||||
|
|
||||||
GLubyte r = slot->skeleton->r * slot->r * 255;
|
GLubyte r = slot->skeleton->r * slot->r * 255;
|
||||||
GLubyte g = slot->skeleton->g * slot->g * 255;
|
GLubyte g = slot->skeleton->g * slot->g * 255;
|
||||||
|
|||||||
@ -39,6 +39,6 @@
|
|||||||
#include <spine/CCSkeleton.h>
|
#include <spine/CCSkeleton.h>
|
||||||
#include <spine/CCSkeletonAnimation.h>
|
#include <spine/CCSkeletonAnimation.h>
|
||||||
|
|
||||||
void RegionAttachment_updateQuad (RegionAttachment* self, Slot* slot, cocos2d::ccV3F_C4B_T2F_Quad* quad, bool premultiplied = false);
|
void spRegionAttachment_updateQuad (spRegionAttachment* self, spSlot* slot, cocos2d::ccV3F_C4B_T2F_Quad* quad, bool premultiplied = false);
|
||||||
|
|
||||||
#endif /* SPINE_COCOS2DX_H_ */
|
#endif /* SPINE_COCOS2DX_H_ */
|
||||||
|
|||||||
@ -34,6 +34,7 @@
|
|||||||
#ifndef SPINE_SFML_H_
|
#ifndef SPINE_SFML_H_
|
||||||
#define SPINE_SFML_H_
|
#define SPINE_SFML_H_
|
||||||
|
|
||||||
|
#define SPINE_SHORT_NAMES
|
||||||
#include <spine/spine.h>
|
#include <spine/spine.h>
|
||||||
#include <SFML/Graphics/Vertex.hpp>
|
#include <SFML/Graphics/Vertex.hpp>
|
||||||
#include <SFML/Graphics/VertexArray.hpp>
|
#include <SFML/Graphics/VertexArray.hpp>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user