mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +08:00
Getting some boiler plate out of the way.
This commit is contained in:
parent
11acfef705
commit
dfa1c2eceb
@ -49,6 +49,21 @@ namespace Spine
|
||||
friend class TranslateTimeline;
|
||||
friend class AnimationStateData;
|
||||
|
||||
friend class AttachmentTimeline;
|
||||
friend class ColorTimeline;
|
||||
friend class DeformTimeline;
|
||||
friend class DrawOrderTimeline;
|
||||
friend class EventTimeline;
|
||||
friend class IkConstraintTimeline;
|
||||
friend class PathConstraintMixTimeline;
|
||||
friend class PathConstraintPositionTimeline;
|
||||
friend class PathConstraintSpacingTimeline;
|
||||
friend class ScaleTimeline;
|
||||
friend class ShearTimeline;
|
||||
friend class TransformConstraintTimeline;
|
||||
friend class TranslateTimeline;
|
||||
friend class TwoColorTimeline;
|
||||
|
||||
public:
|
||||
Animation(std::string name, Vector<Timeline*>& timelines, float duration);
|
||||
|
||||
|
||||
@ -49,68 +49,22 @@ namespace Spine
|
||||
SPINE_RTTI_DECL;
|
||||
|
||||
public:
|
||||
AttachmentTimeline(int frameCount)
|
||||
{
|
||||
_frames.reserve(frameCount);
|
||||
_attachmentNames.reserve(frameCount);
|
||||
}
|
||||
AttachmentTimeline(int frameCount);
|
||||
|
||||
// virtual int getPropertyId()
|
||||
// {
|
||||
// return ((int)TimelineType_Attachment << 24) + slotIndex;
|
||||
// }
|
||||
//
|
||||
// /// Sets the time and value of the specified keyframe.
|
||||
// void setFrame(int frameIndex, float time, std::string attachmentName)
|
||||
// {
|
||||
// frames[frameIndex] = time;
|
||||
// attachmentNames[frameIndex] = attachmentName;
|
||||
// }
|
||||
//
|
||||
// void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*> firedEvents, float alpha, MixPose pose, MixDirection direction)
|
||||
// {
|
||||
// std::string attachmentName;
|
||||
// Slot slot = skeleton.slots.Items[slotIndex];
|
||||
// if (direction == MixDirection_Out && pose == MixPose_Setup)
|
||||
// {
|
||||
// attachmentName = slot.data.attachmentName;
|
||||
// slot.Attachment = attachmentName == NULL ? NULL : skeleton.getAttachment(slotIndex, attachmentName);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// float[] frames = _frames;
|
||||
// if (time < frames[0])
|
||||
// {
|
||||
// // Time is before first frame.
|
||||
// if (pose == MixPose_Setup)
|
||||
// {
|
||||
// attachmentName = slot.data.attachmentName;
|
||||
// slot.Attachment = attachmentName == NULL ? NULL : skeleton.getAttachment(slotIndex, attachmentName);
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// int frameIndex;
|
||||
// if (time >= frames[frames.Length - 1]) // Time is after last frame.
|
||||
// {
|
||||
// frameIndex = frames.Length - 1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// frameIndex = Animation::binarySearch(frames, time, 1) - 1;
|
||||
// }
|
||||
//
|
||||
// attachmentName = attachmentNames[frameIndex];
|
||||
// slot.Attachment = attachmentName == NULL ? NULL : skeleton.getAttachment(slotIndex, attachmentName);
|
||||
// }
|
||||
//
|
||||
// int getSlotIndex() { return _slotIndex; }
|
||||
// void setSlotIndex(int inValue) { _slotIndex = inValue; }
|
||||
// Vector<float>& getFrames() { return _frames; }
|
||||
// void setFrames(Vector<float>& inValue) { _frames = inValue; } // time, ...
|
||||
// Vector<std::string> getAttachmentNames() { return _attachmentNames; }
|
||||
// set { attachmentNames = inValue; }
|
||||
// int getFrameCount() { return frames.Length; }
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
virtual int getPropertyId();
|
||||
|
||||
/// Sets the time and value of the specified keyframe.
|
||||
void setFrame(int frameIndex, float time, std::string attachmentName);
|
||||
|
||||
int getSlotIndex();
|
||||
void setSlotIndex(int inValue);
|
||||
Vector<float>& getFrames();
|
||||
void setFrames(Vector<float>& inValue); // time, ...
|
||||
Vector<std::string> getAttachmentNames();
|
||||
void setAttachmentNames(Vector<std::string>& inValue);
|
||||
int getFrameCount();
|
||||
|
||||
private:
|
||||
int _slotIndex;
|
||||
|
||||
@ -39,104 +39,30 @@ namespace Spine
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
|
||||
// public const int ENTRIES = 5;
|
||||
// protected const int PREV_TIME = -5, PREV_R = -4, PREV_G = -3, PREV_B = -2, PREV_A = -1;
|
||||
// protected const int R = 1, G = 2, B = 3, A = 4;
|
||||
//
|
||||
// internal int slotIndex;
|
||||
// internal float[] frames;
|
||||
//
|
||||
// public int SlotIndex { return slotIndex; } set { slotIndex = inValue; }
|
||||
// public float[] Frames { return frames; } set { frames = inValue; } // time, r, g, b, a, ...
|
||||
//
|
||||
// override public int PropertyId {
|
||||
// get { return ((int)TimelineType.Color << 24) + slotIndex; }
|
||||
// }
|
||||
//
|
||||
// public ColorTimeline (int frameCount)
|
||||
// : base(frameCount) {
|
||||
// frames = new float[frameCount * ENTRIES];
|
||||
// }
|
||||
//
|
||||
// /// Sets the time and value of the specified keyframe.
|
||||
// public void SetFrame (int frameIndex, float time, float r, float g, float b, float a) {
|
||||
// frameIndex *= ENTRIES;
|
||||
// frames[frameIndex] = time;
|
||||
// frames[frameIndex + R] = r;
|
||||
// frames[frameIndex + G] = g;
|
||||
// frames[frameIndex + B] = b;
|
||||
// frames[frameIndex + A] = a;
|
||||
// }
|
||||
//
|
||||
// override public void Apply (Skeleton skeleton, float lastTime, float time, Vector<Event> firedEvents, float alpha, MixPose pose, MixDirection direction) {
|
||||
// Slot slot = skeleton.slots.Items[slotIndex];
|
||||
// float[] frames = _frames;
|
||||
// if (time < frames[0]) {
|
||||
// var slotData = slot.data;
|
||||
// switch (pose) {
|
||||
// case MixPose_Setup:
|
||||
// slot.r = slotData.r;
|
||||
// slot.g = slotData.g;
|
||||
// slot.b = slotData.b;
|
||||
// slot.a = slotData.a;
|
||||
// return;
|
||||
// case MixPose_Current:
|
||||
// slot.r += (slot.r - slotData.r) * alpha;
|
||||
// slot.g += (slot.g - slotData.g) * alpha;
|
||||
// slot.b += (slot.b - slotData.b) * alpha;
|
||||
// slot.a += (slot.a - slotData.a) * alpha;
|
||||
// return;
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// float r, g, b, a;
|
||||
// if (time >= frames[frames.Length - ENTRIES]) { // Time is after last frame.
|
||||
// int i = frames.Length;
|
||||
// r = frames[i + PREV_R];
|
||||
// g = frames[i + PREV_G];
|
||||
// b = frames[i + PREV_B];
|
||||
// a = frames[i + PREV_A];
|
||||
// } else {
|
||||
// // Interpolate between the previous frame and the current frame.
|
||||
// int frame = Animation.BinarySearch(frames, time, ENTRIES);
|
||||
// r = frames[frame + PREV_R];
|
||||
// g = frames[frame + PREV_G];
|
||||
// b = frames[frame + PREV_B];
|
||||
// a = frames[frame + PREV_A];
|
||||
// float frameTime = frames[frame];
|
||||
// float percent = GetCurvePercent(frame / ENTRIES - 1,
|
||||
// 1 - (time - frameTime) / (frames[frame + PREV_TIME] - frameTime));
|
||||
//
|
||||
// r += (frames[frame + R] - r) * percent;
|
||||
// g += (frames[frame + G] - g) * percent;
|
||||
// b += (frames[frame + B] - b) * percent;
|
||||
// a += (frames[frame + A] - a) * percent;
|
||||
// }
|
||||
// if (alpha == 1) {
|
||||
// slot.r = r;
|
||||
// slot.g = g;
|
||||
// slot.b = b;
|
||||
// slot.a = a;
|
||||
// } else {
|
||||
// float br, bg, bb, ba;
|
||||
// if (pose == MixPose_Setup) {
|
||||
// br = slot.data.r;
|
||||
// bg = slot.data.g;
|
||||
// bb = slot.data.b;
|
||||
// ba = slot.data.a;
|
||||
// } else {
|
||||
// br = slot.r;
|
||||
// bg = slot.g;
|
||||
// bb = slot.b;
|
||||
// ba = slot.a;
|
||||
// }
|
||||
// slot.r = br + ((r - br) * alpha);
|
||||
// slot.g = bg + ((g - bg) * alpha);
|
||||
// slot.b = bb + ((b - bb) * alpha);
|
||||
// slot.a = ba + ((a - ba) * alpha);
|
||||
// }
|
||||
// }
|
||||
public:
|
||||
static const int ENTRIES;
|
||||
|
||||
ColorTimeline (int frameCount);
|
||||
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
virtual int getPropertyId();
|
||||
|
||||
/// Sets the time and value of the specified keyframe.
|
||||
void setFrame(int frameIndex, float time, float r, float g, float b, float a);
|
||||
|
||||
int getSlotIndex();
|
||||
void setSlotIndex(int inValue);
|
||||
Vector<float>& getFrames();
|
||||
void setFrames(Vector<float>& inValue); // time, r, g, b, a, ...
|
||||
|
||||
protected:
|
||||
static const int PREV_TIME, PREV_R, PREV_G, PREV_B, PREV_A;
|
||||
static const int R, G, B, A;
|
||||
|
||||
private:
|
||||
int _slotIndex;
|
||||
Vector<float> _frames;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -39,6 +39,10 @@ namespace Spine
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
virtual int getPropertyId();
|
||||
|
||||
// internal int slotIndex;
|
||||
// internal float[] frames;
|
||||
// internal float[][] frameVertices;
|
||||
|
||||
@ -39,6 +39,10 @@ namespace Spine
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
virtual int getPropertyId();
|
||||
|
||||
// internal float[] frames;
|
||||
// private int[][] drawOrders;
|
||||
//
|
||||
|
||||
@ -39,6 +39,10 @@ namespace Spine
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
virtual int getPropertyId();
|
||||
|
||||
// internal float[] frames;
|
||||
// private Event[] events;
|
||||
//
|
||||
|
||||
@ -39,6 +39,10 @@ namespace Spine
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
virtual int getPropertyId();
|
||||
|
||||
// public const int ENTRIES = 3;
|
||||
// private const int PREV_TIME = -3, PREV_MIX = -2, PREV_BEND_DIRECTION = -1;
|
||||
// private const int MIX = 1, BEND_DIRECTION = 2;
|
||||
|
||||
@ -39,6 +39,10 @@ namespace Spine
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
virtual int getPropertyId();
|
||||
|
||||
// public const int ENTRIES = 3;
|
||||
// private const int PREV_TIME = -3, PREV_ROTATE = -2, PREV_TRANSLATE = -1;
|
||||
// private const int ROTATE = 1, TRANSLATE = 2;
|
||||
|
||||
@ -39,6 +39,10 @@ namespace Spine
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
virtual int getPropertyId();
|
||||
|
||||
// public const int ENTRIES = 2;
|
||||
// protected const int PREV_TIME = -2, PREV_VALUE = -1;
|
||||
// protected const int VALUE = 1;
|
||||
|
||||
@ -39,6 +39,10 @@ namespace Spine
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
virtual int getPropertyId();
|
||||
|
||||
// override public int PropertyId {
|
||||
// get { return ((int)TimelineType.PathConstraintSpacing << 24) + pathConstraintIndex; }
|
||||
// }
|
||||
|
||||
@ -39,6 +39,10 @@ namespace Spine
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
virtual int getPropertyId();
|
||||
|
||||
// override public int PropertyId {
|
||||
// get { return ((int)TimelineType.Scale << 24) + boneIndex; }
|
||||
// }
|
||||
|
||||
@ -39,6 +39,10 @@ namespace Spine
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
virtual int getPropertyId();
|
||||
|
||||
// override public int PropertyId {
|
||||
// get { return ((int)TimelineType.Shear << 24) + boneIndex; }
|
||||
// }
|
||||
|
||||
@ -51,6 +51,21 @@ namespace Spine
|
||||
|
||||
class Skeleton
|
||||
{
|
||||
friend class AttachmentTimeline;
|
||||
friend class ColorTimeline;
|
||||
friend class DeformTimeline;
|
||||
friend class DrawOrderTimeline;
|
||||
friend class EventTimeline;
|
||||
friend class IkConstraintTimeline;
|
||||
friend class PathConstraintMixTimeline;
|
||||
friend class PathConstraintPositionTimeline;
|
||||
friend class PathConstraintSpacingTimeline;
|
||||
friend class ScaleTimeline;
|
||||
friend class ShearTimeline;
|
||||
friend class TransformConstraintTimeline;
|
||||
friend class TranslateTimeline;
|
||||
friend class TwoColorTimeline;
|
||||
|
||||
public:
|
||||
Skeleton(SkeletonData& data);
|
||||
|
||||
|
||||
@ -47,6 +47,21 @@ namespace Spine
|
||||
friend class VertexAttachment;
|
||||
friend class Skeleton;
|
||||
|
||||
friend class AttachmentTimeline;
|
||||
friend class ColorTimeline;
|
||||
friend class DeformTimeline;
|
||||
friend class DrawOrderTimeline;
|
||||
friend class EventTimeline;
|
||||
friend class IkConstraintTimeline;
|
||||
friend class PathConstraintMixTimeline;
|
||||
friend class PathConstraintPositionTimeline;
|
||||
friend class PathConstraintSpacingTimeline;
|
||||
friend class ScaleTimeline;
|
||||
friend class ShearTimeline;
|
||||
friend class TransformConstraintTimeline;
|
||||
friend class TranslateTimeline;
|
||||
friend class TwoColorTimeline;
|
||||
|
||||
public:
|
||||
Slot(SlotData& data, Bone& bone);
|
||||
|
||||
|
||||
@ -41,6 +41,21 @@ namespace Spine
|
||||
|
||||
class SlotData
|
||||
{
|
||||
friend class AttachmentTimeline;
|
||||
friend class ColorTimeline;
|
||||
friend class DeformTimeline;
|
||||
friend class DrawOrderTimeline;
|
||||
friend class EventTimeline;
|
||||
friend class IkConstraintTimeline;
|
||||
friend class PathConstraintMixTimeline;
|
||||
friend class PathConstraintPositionTimeline;
|
||||
friend class PathConstraintSpacingTimeline;
|
||||
friend class ScaleTimeline;
|
||||
friend class ShearTimeline;
|
||||
friend class TransformConstraintTimeline;
|
||||
friend class TranslateTimeline;
|
||||
friend class TwoColorTimeline;
|
||||
|
||||
public:
|
||||
SlotData(int index, std::string name, BoneData& boneData);
|
||||
|
||||
|
||||
@ -39,6 +39,10 @@ namespace Spine
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
virtual int getPropertyId();
|
||||
|
||||
// public const int ENTRIES = 5;
|
||||
// private const int PREV_TIME = -5, PREV_ROTATE = -4, PREV_TRANSLATE = -3, PREV_SCALE = -2, PREV_SHEAR = -1;
|
||||
// private const int ROTATE = 1, TRANSLATE = 2, SCALE = 3, SHEAR = 4;
|
||||
|
||||
@ -42,6 +42,10 @@ namespace Spine
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
virtual int getPropertyId();
|
||||
|
||||
// public const int ENTRIES = 3;
|
||||
// protected const int PREV_TIME = -3, PREV_X = -2, PREV_Y = -1;
|
||||
// protected const int X = 1, Y = 2;
|
||||
|
||||
@ -39,6 +39,10 @@ namespace Spine
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
virtual int getPropertyId();
|
||||
|
||||
// public const int ENTRIES = 8;
|
||||
// protected const int PREV_TIME = -8, PREV_R = -7, PREV_G = -6, PREV_B = -5, PREV_A = -4;
|
||||
// protected const int PREV_R2 = -3, PREV_G2 = -2, PREV_B2 = -1;
|
||||
|
||||
@ -35,8 +35,101 @@
|
||||
|
||||
#include <spine/Animation.h>
|
||||
#include <spine/TimelineType.h>
|
||||
#include <spine/Slot.h>
|
||||
#include <spine/SlotData.h>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(AttachmentTimeline, Timeline);
|
||||
|
||||
AttachmentTimeline::AttachmentTimeline(int frameCount)
|
||||
{
|
||||
_frames.reserve(frameCount);
|
||||
_attachmentNames.reserve(frameCount);
|
||||
}
|
||||
|
||||
void AttachmentTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
assert(_slotIndex < skeleton._slots.size());
|
||||
|
||||
std::string attachmentName;
|
||||
Slot* slotP = skeleton._slots[_slotIndex];
|
||||
Slot& slot = *slotP;
|
||||
if (direction == MixDirection_Out && pose == MixPose_Setup)
|
||||
{
|
||||
attachmentName = slot._data._attachmentName;
|
||||
slot._attachment = attachmentName.length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, attachmentName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (time < _frames[0])
|
||||
{
|
||||
// Time is before first frame.
|
||||
if (pose == MixPose_Setup)
|
||||
{
|
||||
attachmentName = slot._data._attachmentName;
|
||||
slot._attachment = attachmentName.length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, attachmentName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int frameIndex;
|
||||
if (time >= _frames[_frames.size() - 1]) // Time is after last frame.
|
||||
{
|
||||
frameIndex = static_cast<int>(_frames.size()) - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
frameIndex = Animation::binarySearch(_frames, time, 1) - 1;
|
||||
}
|
||||
|
||||
attachmentName = _attachmentNames[frameIndex];
|
||||
slot._attachment = attachmentName.length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, attachmentName);
|
||||
}
|
||||
|
||||
int AttachmentTimeline::getPropertyId()
|
||||
{
|
||||
return ((int)TimelineType_Attachment << 24) + _slotIndex;
|
||||
}
|
||||
|
||||
void AttachmentTimeline::setFrame(int frameIndex, float time, std::string attachmentName)
|
||||
{
|
||||
_frames[frameIndex] = time;
|
||||
_attachmentNames[frameIndex] = attachmentName;
|
||||
}
|
||||
|
||||
int AttachmentTimeline::getSlotIndex()
|
||||
{
|
||||
return _slotIndex;
|
||||
}
|
||||
|
||||
void AttachmentTimeline::setSlotIndex(int inValue)
|
||||
{
|
||||
_slotIndex = inValue;
|
||||
}
|
||||
|
||||
Vector<float>& AttachmentTimeline::getFrames()
|
||||
{
|
||||
return _frames;
|
||||
}
|
||||
|
||||
void AttachmentTimeline::setFrames(Vector<float>& inValue)
|
||||
{
|
||||
_frames = inValue;
|
||||
}
|
||||
|
||||
Vector<std::string> AttachmentTimeline::getAttachmentNames()
|
||||
{
|
||||
return _attachmentNames;
|
||||
}
|
||||
|
||||
void AttachmentTimeline::setAttachmentNames(Vector<std::string>& inValue)
|
||||
{
|
||||
_attachmentNames = inValue;
|
||||
}
|
||||
|
||||
int AttachmentTimeline::getFrameCount()
|
||||
{
|
||||
return static_cast<int>(_frames.size());
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,151 @@
|
||||
|
||||
#include <spine/ColorTimeline.h>
|
||||
|
||||
#include <spine/Skeleton.h>
|
||||
#include <spine/Event.h>
|
||||
|
||||
#include <spine/Animation.h>
|
||||
#include <spine/TimelineType.h>
|
||||
#include <spine/Slot.h>
|
||||
#include <spine/SlotData.h>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(ColorTimeline, CurveTimeline);
|
||||
|
||||
const int ColorTimeline::ENTRIES = 5;
|
||||
const int ColorTimeline::PREV_TIME = -5;
|
||||
const int ColorTimeline::PREV_R = -4;
|
||||
const int ColorTimeline::PREV_G = -3;
|
||||
const int ColorTimeline::PREV_B = -2;
|
||||
const int ColorTimeline::PREV_A = -1;
|
||||
const int ColorTimeline::R = 1;
|
||||
const int ColorTimeline::G = 2;
|
||||
const int ColorTimeline::B = 3;
|
||||
const int ColorTimeline::A = 4;
|
||||
|
||||
ColorTimeline::ColorTimeline(int frameCount) : CurveTimeline(frameCount)
|
||||
{
|
||||
_frames.reserve(frameCount * ENTRIES);
|
||||
}
|
||||
|
||||
void ColorTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
Slot* slotP = skeleton._slots[_slotIndex];
|
||||
Slot& slot = *slotP;
|
||||
if (time < _frames[0])
|
||||
{
|
||||
SlotData& slotData = slot._data;
|
||||
switch (pose)
|
||||
{
|
||||
case MixPose_Setup:
|
||||
slot._r = slotData._r;
|
||||
slot._g = slotData._g;
|
||||
slot._b = slotData._b;
|
||||
slot._a = slotData._a;
|
||||
return;
|
||||
case MixPose_Current:
|
||||
slot._r += (slot._r - slotData._r) * alpha;
|
||||
slot._g += (slot._g - slotData._g) * alpha;
|
||||
slot._b += (slot._b - slotData._b) * alpha;
|
||||
slot._a += (slot._a - slotData._a) * alpha;
|
||||
return;
|
||||
case MixPose_CurrentLayered:
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
float r, g, b, a;
|
||||
if (time >= _frames[_frames.size() - ENTRIES])
|
||||
{
|
||||
// Time is after last frame.
|
||||
int i = static_cast<int>(_frames.size());
|
||||
r = _frames[i + PREV_R];
|
||||
g = _frames[i + PREV_G];
|
||||
b = _frames[i + PREV_B];
|
||||
a = _frames[i + PREV_A];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Interpolate between the previous frame and the current frame.
|
||||
int frame = Animation::binarySearch(_frames, time, ENTRIES);
|
||||
r = _frames[frame + PREV_R];
|
||||
g = _frames[frame + PREV_G];
|
||||
b = _frames[frame + PREV_B];
|
||||
a = _frames[frame + PREV_A];
|
||||
float frameTime = _frames[frame];
|
||||
float percent = getCurvePercent(frame / ENTRIES - 1, 1 - (time - frameTime) / (_frames[frame + PREV_TIME] - frameTime));
|
||||
|
||||
r += (_frames[frame + R] - r) * percent;
|
||||
g += (_frames[frame + G] - g) * percent;
|
||||
b += (_frames[frame + B] - b) * percent;
|
||||
a += (_frames[frame + A] - a) * percent;
|
||||
}
|
||||
|
||||
if (alpha == 1)
|
||||
{
|
||||
slot._r = r;
|
||||
slot._g = g;
|
||||
slot._b = b;
|
||||
slot._a = a;
|
||||
}
|
||||
else
|
||||
{
|
||||
float br, bg, bb, ba;
|
||||
if (pose == MixPose_Setup)
|
||||
{
|
||||
br = slot._data._r;
|
||||
bg = slot._data._g;
|
||||
bb = slot._data._b;
|
||||
ba = slot._data._a;
|
||||
}
|
||||
else
|
||||
{
|
||||
br = slot._r;
|
||||
bg = slot._g;
|
||||
bb = slot._b;
|
||||
ba = slot._a;
|
||||
}
|
||||
slot._r = br + ((r - br) * alpha);
|
||||
slot._g = bg + ((g - bg) * alpha);
|
||||
slot._b = bb + ((b - bb) * alpha);
|
||||
slot._a = ba + ((a - ba) * alpha);
|
||||
}
|
||||
}
|
||||
|
||||
int ColorTimeline::getPropertyId()
|
||||
{
|
||||
return ((int)TimelineType_Color << 24) + _slotIndex;
|
||||
}
|
||||
|
||||
void ColorTimeline::setFrame(int frameIndex, float time, float r, float g, float b, float a)
|
||||
{
|
||||
frameIndex *= ENTRIES;
|
||||
_frames[frameIndex] = time;
|
||||
_frames[frameIndex + R] = r;
|
||||
_frames[frameIndex + G] = g;
|
||||
_frames[frameIndex + B] = b;
|
||||
_frames[frameIndex + A] = a;
|
||||
}
|
||||
|
||||
int ColorTimeline::getSlotIndex()
|
||||
{
|
||||
return _slotIndex;
|
||||
}
|
||||
|
||||
void ColorTimeline::setSlotIndex(int inValue)
|
||||
{
|
||||
_slotIndex = inValue;
|
||||
}
|
||||
|
||||
Vector<float>& ColorTimeline::getFrames()
|
||||
{
|
||||
return _frames;
|
||||
}
|
||||
|
||||
void ColorTimeline::setFrames(Vector<float>& inValue)
|
||||
{
|
||||
_frames = inValue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,25 @@
|
||||
|
||||
#include <spine/DeformTimeline.h>
|
||||
|
||||
#include <spine/Skeleton.h>
|
||||
#include <spine/Event.h>
|
||||
|
||||
#include <spine/Animation.h>
|
||||
#include <spine/TimelineType.h>
|
||||
#include <spine/Slot.h>
|
||||
#include <spine/SlotData.h>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(DeformTimeline, CurveTimeline);
|
||||
|
||||
void DeformTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
int DeformTimeline::getPropertyId()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,25 @@
|
||||
|
||||
#include <spine/DrawOrderTimeline.h>
|
||||
|
||||
#include <spine/Skeleton.h>
|
||||
#include <spine/Event.h>
|
||||
|
||||
#include <spine/Animation.h>
|
||||
#include <spine/TimelineType.h>
|
||||
#include <spine/Slot.h>
|
||||
#include <spine/SlotData.h>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(DrawOrderTimeline, Timeline);
|
||||
|
||||
void DrawOrderTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
int DrawOrderTimeline::getPropertyId()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,25 @@
|
||||
|
||||
#include <spine/EventTimeline.h>
|
||||
|
||||
#include <spine/Skeleton.h>
|
||||
#include <spine/Event.h>
|
||||
|
||||
#include <spine/Animation.h>
|
||||
#include <spine/TimelineType.h>
|
||||
#include <spine/Slot.h>
|
||||
#include <spine/SlotData.h>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(EventTimeline, Timeline);
|
||||
|
||||
void EventTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
int EventTimeline::getPropertyId()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,25 @@
|
||||
|
||||
#include <spine/IkConstraintTimeline.h>
|
||||
|
||||
#include <spine/Skeleton.h>
|
||||
#include <spine/Event.h>
|
||||
|
||||
#include <spine/Animation.h>
|
||||
#include <spine/TimelineType.h>
|
||||
#include <spine/Slot.h>
|
||||
#include <spine/SlotData.h>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(IkConstraintTimeline, CurveTimeline);
|
||||
|
||||
void IkConstraintTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
int IkConstraintTimeline::getPropertyId()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,25 @@
|
||||
|
||||
#include <spine/PathConstraintMixTimeline.h>
|
||||
|
||||
#include <spine/Skeleton.h>
|
||||
#include <spine/Event.h>
|
||||
|
||||
#include <spine/Animation.h>
|
||||
#include <spine/TimelineType.h>
|
||||
#include <spine/Slot.h>
|
||||
#include <spine/SlotData.h>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(PathConstraintMixTimeline, CurveTimeline);
|
||||
|
||||
void PathConstraintMixTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
int PathConstraintMixTimeline::getPropertyId()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,25 @@
|
||||
|
||||
#include <spine/PathConstraintPositionTimeline.h>
|
||||
|
||||
#include <spine/Skeleton.h>
|
||||
#include <spine/Event.h>
|
||||
|
||||
#include <spine/Animation.h>
|
||||
#include <spine/TimelineType.h>
|
||||
#include <spine/Slot.h>
|
||||
#include <spine/SlotData.h>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(PathConstraintPositionTimeline, CurveTimeline);
|
||||
|
||||
void PathConstraintPositionTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
int PathConstraintPositionTimeline::getPropertyId()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,25 @@
|
||||
|
||||
#include <spine/PathConstraintSpacingTimeline.h>
|
||||
|
||||
#include <spine/Skeleton.h>
|
||||
#include <spine/Event.h>
|
||||
|
||||
#include <spine/Animation.h>
|
||||
#include <spine/TimelineType.h>
|
||||
#include <spine/Slot.h>
|
||||
#include <spine/SlotData.h>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(PathConstraintSpacingTimeline, PathConstraintPositionTimeline);
|
||||
|
||||
void PathConstraintSpacingTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
int PathConstraintSpacingTimeline::getPropertyId()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,25 @@
|
||||
|
||||
#include <spine/ScaleTimeline.h>
|
||||
|
||||
#include <spine/Skeleton.h>
|
||||
#include <spine/Event.h>
|
||||
|
||||
#include <spine/Animation.h>
|
||||
#include <spine/TimelineType.h>
|
||||
#include <spine/Slot.h>
|
||||
#include <spine/SlotData.h>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(ScaleTimeline, TranslateTimeline);
|
||||
|
||||
void ScaleTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
int ScaleTimeline::getPropertyId()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,25 @@
|
||||
|
||||
#include <spine/ShearTimeline.h>
|
||||
|
||||
#include <spine/Skeleton.h>
|
||||
#include <spine/Event.h>
|
||||
|
||||
#include <spine/Animation.h>
|
||||
#include <spine/TimelineType.h>
|
||||
#include <spine/Slot.h>
|
||||
#include <spine/SlotData.h>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(ShearTimeline, TranslateTimeline);
|
||||
|
||||
void ShearTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
int ShearTimeline::getPropertyId()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,8 +30,25 @@
|
||||
|
||||
#include <spine/TransformConstraintTimeline.h>
|
||||
|
||||
#include <spine/Skeleton.h>
|
||||
#include <spine/Event.h>
|
||||
|
||||
#include <spine/Animation.h>
|
||||
#include <spine/TimelineType.h>
|
||||
#include <spine/Slot.h>
|
||||
#include <spine/SlotData.h>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(TransformConstraintTimeline, CurveTimeline);
|
||||
|
||||
void TransformConstraintTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
int TransformConstraintTimeline::getPropertyId()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,25 @@
|
||||
|
||||
#include <spine/TranslateTimeline.h>
|
||||
|
||||
#include <spine/Skeleton.h>
|
||||
#include <spine/Event.h>
|
||||
|
||||
#include <spine/Animation.h>
|
||||
#include <spine/TimelineType.h>
|
||||
#include <spine/Slot.h>
|
||||
#include <spine/SlotData.h>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(TranslateTimeline, CurveTimeline);
|
||||
|
||||
void TranslateTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
int TranslateTimeline::getPropertyId()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,25 @@
|
||||
|
||||
#include <spine/TwoColorTimeline.h>
|
||||
|
||||
#include <spine/Skeleton.h>
|
||||
#include <spine/Event.h>
|
||||
|
||||
#include <spine/Animation.h>
|
||||
#include <spine/TimelineType.h>
|
||||
#include <spine/Slot.h>
|
||||
#include <spine/SlotData.h>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(TwoColorTimeline, CurveTimeline);
|
||||
|
||||
void TwoColorTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
int TwoColorTimeline::getPropertyId()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user