mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 06:14:53 +08:00
Formatting
This commit is contained in:
parent
e623140c99
commit
120577bfe6
@ -163,9 +163,9 @@ float TrackEntry::getMixDuration() { return _mixDuration; }
|
||||
void TrackEntry::setMixDuration(float inValue) { _mixDuration = inValue; }
|
||||
|
||||
void TrackEntry::setMixDuration(float mixDuration, float delay) {
|
||||
_mixDuration = mixDuration;
|
||||
if (_previous && delay <= 0) delay += _previous->getTrackComplete() - mixDuration;
|
||||
this->_delay = delay;
|
||||
_mixDuration = mixDuration;
|
||||
if (_previous && delay <= 0) delay += _previous->getTrackComplete() - mixDuration;
|
||||
this->_delay = delay;
|
||||
}
|
||||
|
||||
TrackEntry *TrackEntry::getMixingFrom() { return _mixingFrom; }
|
||||
@ -935,15 +935,15 @@ void AnimationState::queueEvents(TrackEntry *entry, float animationTime) {
|
||||
// Queue complete if completed a loop iteration or the animation.
|
||||
bool complete = false;
|
||||
if (entry->_loop) {
|
||||
if (duration == 0)
|
||||
complete = true;
|
||||
else {
|
||||
int cycles = (int) (entry->_trackTime / duration);
|
||||
complete = cycles > 0 && cycles > (int) (entry->_trackLast / duration);
|
||||
}
|
||||
} else {
|
||||
complete = animationTime >= animationEnd && entry->_animationLast < animationEnd;
|
||||
}
|
||||
if (duration == 0)
|
||||
complete = true;
|
||||
else {
|
||||
int cycles = (int) (entry->_trackTime / duration);
|
||||
complete = cycles > 0 && cycles > (int) (entry->_trackLast / duration);
|
||||
}
|
||||
} else {
|
||||
complete = animationTime >= animationEnd && entry->_animationLast < animationEnd;
|
||||
}
|
||||
if (complete) _queue->complete(entry);
|
||||
|
||||
// Queue events after complete.
|
||||
@ -998,7 +998,7 @@ TrackEntry *AnimationState::newTrackEntry(size_t trackIndex, Animation *animatio
|
||||
|
||||
entry._eventThreshold = 0;
|
||||
entry._alphaAttachmentThreshold = 0;
|
||||
entry._mixAttachmentThreshold = 0;
|
||||
entry._mixAttachmentThreshold = 0;
|
||||
entry._mixDrawOrderThreshold = 0;
|
||||
|
||||
entry._animationStart = 0;
|
||||
|
||||
@ -72,7 +72,7 @@ Bone::Bone(BoneData &data, Skeleton &skeleton, Bone *parent) : Updatable(),
|
||||
_worldY(0),
|
||||
_sorted(false),
|
||||
_active(false),
|
||||
_inherit(Inherit_Normal){
|
||||
_inherit(Inherit_Normal) {
|
||||
setToSetupPose();
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ void Bone::setToSetupPose() {
|
||||
_scaleY = data.getScaleY();
|
||||
_shearX = data.getShearX();
|
||||
_shearY = data.getShearY();
|
||||
_inherit = data.getInherit();
|
||||
_inherit = data.getInherit();
|
||||
}
|
||||
|
||||
void Bone::worldToLocal(float worldX, float worldY, float &outLocalX, float &outLocalY) {
|
||||
@ -232,12 +232,12 @@ void Bone::worldToLocal(float worldX, float worldY, float &outLocalX, float &out
|
||||
}
|
||||
|
||||
void Bone::worldToParent(float worldX, float worldY, float &outParentX, float &outParentY) {
|
||||
if (!_parent) {
|
||||
outParentX = worldX;
|
||||
outParentY = worldY;
|
||||
} else {
|
||||
_parent->worldToLocal(worldX, worldY, outParentX, outParentY);
|
||||
}
|
||||
if (!_parent) {
|
||||
outParentX = worldX;
|
||||
outParentY = worldY;
|
||||
} else {
|
||||
_parent->worldToLocal(worldX, worldY, outParentX, outParentY);
|
||||
}
|
||||
}
|
||||
|
||||
void Bone::localToWorld(float localX, float localY, float &outWorldX, float &outWorldY) {
|
||||
@ -246,24 +246,24 @@ void Bone::localToWorld(float localX, float localY, float &outWorldX, float &out
|
||||
}
|
||||
|
||||
void Bone::parentToWorld(float worldX, float worldY, float &outX, float &outY) {
|
||||
if (!_parent) {
|
||||
outX = worldX;
|
||||
outY = worldY;
|
||||
} else {
|
||||
_parent->localToWorld(worldX, worldY, outX, outY);
|
||||
}
|
||||
if (!_parent) {
|
||||
outX = worldX;
|
||||
outY = worldY;
|
||||
} else {
|
||||
_parent->localToWorld(worldX, worldY, outX, outY);
|
||||
}
|
||||
}
|
||||
|
||||
float Bone::worldToLocalRotation(float worldRotation) {
|
||||
worldRotation *= MathUtil::Deg_Rad;
|
||||
float sine = MathUtil::sin(worldRotation), cosine = MathUtil::cos(worldRotation);
|
||||
return MathUtil::atan2Deg(_a * sine - _c * cosine, _d * cosine - _b * sine) + _rotation - _shearX;
|
||||
worldRotation *= MathUtil::Deg_Rad;
|
||||
float sine = MathUtil::sin(worldRotation), cosine = MathUtil::cos(worldRotation);
|
||||
return MathUtil::atan2Deg(_a * sine - _c * cosine, _d * cosine - _b * sine) + _rotation - _shearX;
|
||||
}
|
||||
|
||||
float Bone::localToWorldRotation(float localRotation) {
|
||||
localRotation = (localRotation - _rotation - _shearX) * MathUtil::Deg_Rad;
|
||||
float sine = MathUtil::sin(localRotation), cosine = MathUtil::cos(localRotation);
|
||||
return MathUtil::atan2Deg(cosine * _c + sine * _d, cosine * _a + sine * _b);
|
||||
localRotation = (localRotation - _rotation - _shearX) * MathUtil::Deg_Rad;
|
||||
float sine = MathUtil::sin(localRotation), cosine = MathUtil::cos(localRotation);
|
||||
return MathUtil::atan2Deg(cosine * _c + sine * _d, cosine * _a + sine * _b);
|
||||
}
|
||||
|
||||
void Bone::rotateWorld(float degrees) {
|
||||
@ -540,7 +540,7 @@ void Bone::updateAppliedTransform() {
|
||||
case Inherit_NoScale:
|
||||
case Inherit_NoScaleOrReflection: {
|
||||
float r = _rotation * MathUtil::Deg_Rad;
|
||||
float cos = MathUtil::cos(r), sin = MathUtil::sin(r);
|
||||
float cos = MathUtil::cos(r), sin = MathUtil::sin(r);
|
||||
pa = (pa * cos + pb * sin) / _skeleton.getScaleX();
|
||||
pc = (pc * cos + pd * sin) / _skeleton.getScaleY();
|
||||
float s = MathUtil::sqrt(pa * pa + pc * pc);
|
||||
|
||||
@ -34,21 +34,21 @@
|
||||
using namespace spine;
|
||||
|
||||
BoneData::BoneData(int index, const String &name, BoneData *parent) : _index(index),
|
||||
_name(name),
|
||||
_parent(parent),
|
||||
_length(0),
|
||||
_x(0),
|
||||
_y(0),
|
||||
_rotation(0),
|
||||
_scaleX(1),
|
||||
_scaleY(1),
|
||||
_shearX(0),
|
||||
_shearY(0),
|
||||
_inherit(Inherit_Normal),
|
||||
_skinRequired(false),
|
||||
_color(),
|
||||
_icon(),
|
||||
_visible(true) {
|
||||
_name(name),
|
||||
_parent(parent),
|
||||
_length(0),
|
||||
_x(0),
|
||||
_y(0),
|
||||
_rotation(0),
|
||||
_scaleX(1),
|
||||
_scaleY(1),
|
||||
_shearX(0),
|
||||
_shearY(0),
|
||||
_inherit(Inherit_Normal),
|
||||
_skinRequired(false),
|
||||
_color(),
|
||||
_icon(),
|
||||
_visible(true) {
|
||||
assert(index >= 0);
|
||||
assert(_name.length() > 0);
|
||||
}
|
||||
@ -134,7 +134,7 @@ Inherit BoneData::getInherit() {
|
||||
}
|
||||
|
||||
void BoneData::setInherit(Inherit inValue) {
|
||||
_inherit = inValue;
|
||||
_inherit = inValue;
|
||||
}
|
||||
|
||||
bool BoneData::isSkinRequired() {
|
||||
|
||||
@ -109,8 +109,8 @@ void IkConstraint::apply(Bone &parent, Bone &child, float targetX, float targetY
|
||||
Bone *pp = parent.getParent();
|
||||
float tx, ty, dx, dy, dd, l1, l2, a1, a2, r, td, sd, p;
|
||||
float id, x, y;
|
||||
if (parent._inherit != Inherit_Normal || child._inherit != Inherit_Normal) return;
|
||||
px = parent._ax;
|
||||
if (parent._inherit != Inherit_Normal || child._inherit != Inherit_Normal) return;
|
||||
px = parent._ax;
|
||||
py = parent._ay;
|
||||
psx = parent._ascaleX;
|
||||
psy = parent._ascaleY;
|
||||
|
||||
@ -42,8 +42,8 @@ using namespace spine;
|
||||
RTTI_IMPL(InheritTimeline, Timeline)
|
||||
|
||||
InheritTimeline::InheritTimeline(size_t frameCount, int boneIndex) : Timeline(frameCount, ENTRIES),
|
||||
_boneIndex(boneIndex) {
|
||||
PropertyId ids[] = {((PropertyId) Property_Inherit << 32) | boneIndex };
|
||||
_boneIndex(boneIndex) {
|
||||
PropertyId ids[] = {((PropertyId) Property_Inherit << 32) | boneIndex};
|
||||
setPropertyIds(ids, 1);
|
||||
}
|
||||
|
||||
@ -51,27 +51,26 @@ InheritTimeline::~InheritTimeline() {
|
||||
}
|
||||
|
||||
void InheritTimeline::setFrame(int frame, float time, Inherit inherit) {
|
||||
frame *= ENTRIES;
|
||||
_frames[frame] = time;
|
||||
_frames[frame + INHERIT] = inherit;
|
||||
frame *= ENTRIES;
|
||||
_frames[frame] = time;
|
||||
_frames[frame + INHERIT] = inherit;
|
||||
}
|
||||
|
||||
|
||||
void InheritTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
||||
MixBlend blend, MixDirection direction) {
|
||||
MixBlend blend, MixDirection direction) {
|
||||
SP_UNUSED(lastTime);
|
||||
SP_UNUSED(pEvents);
|
||||
SP_UNUSED(direction);
|
||||
SP_UNUSED(alpha);
|
||||
SP_UNUSED(alpha);
|
||||
|
||||
Bone *bone = skeleton.getBones()[_boneIndex];
|
||||
if (!bone->isActive()) return;
|
||||
Bone *bone = skeleton.getBones()[_boneIndex];
|
||||
if (!bone->isActive()) return;
|
||||
|
||||
if (time < _frames[0]) {
|
||||
if (blend == MixBlend_Setup || blend == MixBlend_First) bone->_inherit = bone->_data.getInherit();
|
||||
return;
|
||||
}
|
||||
int idx = Animation::search(_frames, time, ENTRIES) + INHERIT;
|
||||
bone->_inherit = (Inherit)_frames[idx];
|
||||
if (time < _frames[0]) {
|
||||
if (blend == MixBlend_Setup || blend == MixBlend_First) bone->_inherit = bone->_data.getInherit();
|
||||
return;
|
||||
}
|
||||
int idx = Animation::search(_frames, time, ENTRIES) + INHERIT;
|
||||
bone->_inherit = (Inherit) _frames[idx];
|
||||
}
|
||||
|
||||
|
||||
@ -34,19 +34,19 @@
|
||||
using namespace spine;
|
||||
|
||||
LinkedMesh::LinkedMesh(MeshAttachment *mesh, const int skinIndex, size_t slotIndex, const String &parent,
|
||||
bool inheritTimeline) : _mesh(mesh),
|
||||
_skinIndex(skinIndex),
|
||||
_skin(""),
|
||||
_slotIndex(slotIndex),
|
||||
_parent(parent),
|
||||
_inheritTimeline(inheritTimeline) {
|
||||
bool inheritTimeline) : _mesh(mesh),
|
||||
_skinIndex(skinIndex),
|
||||
_skin(""),
|
||||
_slotIndex(slotIndex),
|
||||
_parent(parent),
|
||||
_inheritTimeline(inheritTimeline) {
|
||||
}
|
||||
|
||||
LinkedMesh::LinkedMesh(MeshAttachment *mesh, const String &skin, size_t slotIndex, const String &parent,
|
||||
bool inheritTimeline) : _mesh(mesh),
|
||||
_skinIndex(-1),
|
||||
_skin(skin),
|
||||
_slotIndex(slotIndex),
|
||||
_parent(parent),
|
||||
_inheritTimeline(inheritTimeline) {
|
||||
bool inheritTimeline) : _mesh(mesh),
|
||||
_skinIndex(-1),
|
||||
_skin(skin),
|
||||
_slotIndex(slotIndex),
|
||||
_parent(parent),
|
||||
_inheritTimeline(inheritTimeline) {
|
||||
}
|
||||
|
||||
@ -324,7 +324,7 @@ void PhysicsConstraint::update(Physics physics) {
|
||||
reset();
|
||||
// Fall through.
|
||||
case Physics::Physics_Update: {
|
||||
float delta = MathUtil::max(_skeleton.getTime() - _lastTime, 0.0f);
|
||||
float delta = MathUtil::max(_skeleton.getTime() - _lastTime, 0.0f);
|
||||
_remaining += delta;
|
||||
_lastTime = _skeleton.getTime();
|
||||
|
||||
@ -334,92 +334,94 @@ void PhysicsConstraint::update(Physics physics) {
|
||||
_ux = bx;
|
||||
_uy = by;
|
||||
} else {
|
||||
float a = _remaining, i = _inertia, q = _data._limit * delta, t = _data._step, f = _skeleton.getData()->getReferenceScale(), d = -1;
|
||||
float a = _remaining, i = _inertia, q = _data._limit * delta, t = _data._step, f = _skeleton.getData()->getReferenceScale(), d = -1;
|
||||
if (x || y) {
|
||||
if (x) {
|
||||
float u = (_ux - bx) * i;
|
||||
_xOffset += u > q ? q : u < -q ? -q : u;
|
||||
_ux = bx;
|
||||
}
|
||||
if (y) {
|
||||
float u = (_uy - by) * i;
|
||||
_yOffset += u > q ? q : u < -q ? -q : u;
|
||||
_uy = by;
|
||||
}
|
||||
if (x) {
|
||||
float u = (_ux - bx) * i;
|
||||
_xOffset += u > q ? q : u < -q ? -q
|
||||
: u;
|
||||
_ux = bx;
|
||||
}
|
||||
if (y) {
|
||||
float u = (_uy - by) * i;
|
||||
_yOffset += u > q ? q : u < -q ? -q
|
||||
: u;
|
||||
_uy = by;
|
||||
}
|
||||
if (a >= t) {
|
||||
d = MathUtil::pow(_damping, 60 * t);
|
||||
float m = _massInverse * t, e = _strength, w = _wind * f, g = _gravity * f * (Bone::yDown ? -1 : 1);
|
||||
do {
|
||||
if (x) {
|
||||
_xVelocity += (w - _xOffset * e) * m;
|
||||
_xOffset += _xVelocity * t;
|
||||
_xVelocity *= d;
|
||||
}
|
||||
if (y) {
|
||||
_yVelocity -= (g + _yOffset * e) * m;
|
||||
_yOffset += _yVelocity * t;
|
||||
_yVelocity *= d;
|
||||
}
|
||||
a -= t;
|
||||
} while (a >= t);
|
||||
d = MathUtil::pow(_damping, 60 * t);
|
||||
float m = _massInverse * t, e = _strength, w = _wind * f, g = _gravity * f * (Bone::yDown ? -1 : 1);
|
||||
do {
|
||||
if (x) {
|
||||
_xVelocity += (w - _xOffset * e) * m;
|
||||
_xOffset += _xVelocity * t;
|
||||
_xVelocity *= d;
|
||||
}
|
||||
if (y) {
|
||||
_yVelocity -= (g + _yOffset * e) * m;
|
||||
_yOffset += _yVelocity * t;
|
||||
_yVelocity *= d;
|
||||
}
|
||||
a -= t;
|
||||
} while (a >= t);
|
||||
}
|
||||
if (x) bone->_worldX += _xOffset * mix * _data._x;
|
||||
if (y) bone->_worldY += _yOffset * mix * _data._y;
|
||||
}
|
||||
|
||||
if (rotateOrShearX || scaleX) {
|
||||
float ca = MathUtil::atan2(bone->_c, bone->_a), c, s, mr = 0;
|
||||
float dx = _cx - bone->_worldX, dy = _cy - bone->_worldY;
|
||||
if (dx > q)
|
||||
dx = q;
|
||||
else if (dx < -q) //
|
||||
dx = -q;
|
||||
if (dy > q)
|
||||
dy = q;
|
||||
else if (dy < -q) //
|
||||
dy = -q;
|
||||
if (rotateOrShearX) {
|
||||
mr = (_data._rotate + _data._shearX) * mix;
|
||||
float r = MathUtil::atan2(dy + _ty, dx + _tx) - ca - _rotateOffset * mr;
|
||||
_rotateOffset += (r - MathUtil::ceil(r * MathUtil::InvPi_2 - 0.5f) * MathUtil::Pi_2) * i;
|
||||
r = _rotateOffset * mr + ca;
|
||||
c = MathUtil::cos(r);
|
||||
s = MathUtil::sin(r);
|
||||
if (scaleX) {
|
||||
r = l * bone->getWorldScaleX();
|
||||
if (r > 0) _scaleOffset += (dx * c + dy * s) * i / r;
|
||||
}
|
||||
} else {
|
||||
c = MathUtil::cos(ca);
|
||||
s = MathUtil::sin(ca);
|
||||
float r = l * bone->getWorldScaleX();
|
||||
if (r > 0) _scaleOffset += (dx * c + dy * s) * i / r;
|
||||
}
|
||||
a = _remaining;
|
||||
if (a >= t) {
|
||||
if (d == -1) d = MathUtil::pow(_damping, 60 * t);
|
||||
float m = _massInverse * t, e = _strength, w = _wind, g = _gravity, h = l / f;
|
||||
while (true) {
|
||||
a -= t;
|
||||
if (scaleX) {
|
||||
_scaleVelocity += (w * c - g * s - _scaleOffset * e) * m;
|
||||
_scaleOffset += _scaleVelocity * t;
|
||||
_scaleVelocity *= d;
|
||||
}
|
||||
if (rotateOrShearX) {
|
||||
_rotateVelocity -= ((w * s + g * c) * h + _rotateOffset * e) * m;
|
||||
_rotateOffset += _rotateVelocity * t;
|
||||
_rotateVelocity *= d;
|
||||
if (a < t) break;
|
||||
float r = _rotateOffset * mr + ca;
|
||||
c = MathUtil::cos(r);
|
||||
s = MathUtil::sin(r);
|
||||
} else if (a < t) //
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_remaining = a;
|
||||
if (rotateOrShearX || scaleX) {
|
||||
float ca = MathUtil::atan2(bone->_c, bone->_a), c, s, mr = 0;
|
||||
float dx = _cx - bone->_worldX, dy = _cy - bone->_worldY;
|
||||
if (dx > q)
|
||||
dx = q;
|
||||
else if (dx < -q)//
|
||||
dx = -q;
|
||||
if (dy > q)
|
||||
dy = q;
|
||||
else if (dy < -q)//
|
||||
dy = -q;
|
||||
if (rotateOrShearX) {
|
||||
mr = (_data._rotate + _data._shearX) * mix;
|
||||
float r = MathUtil::atan2(dy + _ty, dx + _tx) - ca - _rotateOffset * mr;
|
||||
_rotateOffset += (r - MathUtil::ceil(r * MathUtil::InvPi_2 - 0.5f) * MathUtil::Pi_2) * i;
|
||||
r = _rotateOffset * mr + ca;
|
||||
c = MathUtil::cos(r);
|
||||
s = MathUtil::sin(r);
|
||||
if (scaleX) {
|
||||
r = l * bone->getWorldScaleX();
|
||||
if (r > 0) _scaleOffset += (dx * c + dy * s) * i / r;
|
||||
}
|
||||
} else {
|
||||
c = MathUtil::cos(ca);
|
||||
s = MathUtil::sin(ca);
|
||||
float r = l * bone->getWorldScaleX();
|
||||
if (r > 0) _scaleOffset += (dx * c + dy * s) * i / r;
|
||||
}
|
||||
a = _remaining;
|
||||
if (a >= t) {
|
||||
if (d == -1) d = MathUtil::pow(_damping, 60 * t);
|
||||
float m = _massInverse * t, e = _strength, w = _wind, g = _gravity, h = l / f;
|
||||
while (true) {
|
||||
a -= t;
|
||||
if (scaleX) {
|
||||
_scaleVelocity += (w * c - g * s - _scaleOffset * e) * m;
|
||||
_scaleOffset += _scaleVelocity * t;
|
||||
_scaleVelocity *= d;
|
||||
}
|
||||
if (rotateOrShearX) {
|
||||
_rotateVelocity -= ((w * s + g * c) * h + _rotateOffset * e) * m;
|
||||
_rotateOffset += _rotateVelocity * t;
|
||||
_rotateVelocity *= d;
|
||||
if (a < t) break;
|
||||
float r = _rotateOffset * mr + ca;
|
||||
c = MathUtil::cos(r);
|
||||
s = MathUtil::sin(r);
|
||||
} else if (a < t)//
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_remaining = a;
|
||||
}
|
||||
|
||||
_cx = bone->_worldX;
|
||||
@ -476,9 +478,9 @@ void PhysicsConstraint::update(Physics physics) {
|
||||
}
|
||||
|
||||
void PhysicsConstraint::rotate(float x, float y, float degrees) {
|
||||
float r = degrees * MathUtil::Deg_Rad, cos = MathUtil::cos(r), sin = MathUtil::sin(r);
|
||||
float dx = _cx - x, dy = _cy - y;
|
||||
translate(dx * cos - dy * sin - dx, dx * sin + dy * cos - dy);
|
||||
float r = degrees * MathUtil::Deg_Rad, cos = MathUtil::cos(r), sin = MathUtil::sin(r);
|
||||
float dx = _cx - x, dy = _cy - y;
|
||||
translate(dx * cos - dy * sin - dx, dx * sin + dy * cos - dy);
|
||||
}
|
||||
|
||||
void PhysicsConstraint::translate(float x, float y) {
|
||||
|
||||
@ -95,11 +95,11 @@ float PhysicsConstraintData::getShearX() const {
|
||||
}
|
||||
|
||||
void PhysicsConstraintData::setLimit(float limit) {
|
||||
_limit = limit;
|
||||
_limit = limit;
|
||||
}
|
||||
|
||||
float PhysicsConstraintData::getLimit() const {
|
||||
return _limit;
|
||||
return _limit;
|
||||
}
|
||||
|
||||
void PhysicsConstraintData::setStep(float step) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -132,7 +132,7 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
||||
skeletonData->_y = readFloat(input);
|
||||
skeletonData->_width = readFloat(input);
|
||||
skeletonData->_height = readFloat(input);
|
||||
skeletonData->_referenceScale = readFloat(input) * this->_scale;
|
||||
skeletonData->_referenceScale = readFloat(input) * this->_scale;
|
||||
|
||||
nonessential = readBoolean(input);
|
||||
|
||||
@ -165,8 +165,8 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
||||
data->_skinRequired = readBoolean(input);
|
||||
if (nonessential) {
|
||||
readColor(input, data->getColor());
|
||||
data->_icon.own(readString(input));
|
||||
data->_visible = readBoolean(input);
|
||||
data->_icon.own(readString(input));
|
||||
data->_visible = readBoolean(input);
|
||||
}
|
||||
skeletonData->_bones[i] = data;
|
||||
}
|
||||
@ -176,14 +176,14 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
||||
skeletonData->_slots.setSize(slotsCount, 0);
|
||||
for (int i = 0; i < slotsCount; ++i) {
|
||||
String slotName = String(readString(input), true);
|
||||
String pathName = "";
|
||||
if (nonessential) {
|
||||
int slash = slotName.lastIndexOf('/');
|
||||
if (slash != -1) {
|
||||
pathName = slotName.substring(0, slash);
|
||||
slotName = slotName.substring(slash + 1);
|
||||
}
|
||||
}
|
||||
String pathName = "";
|
||||
if (nonessential) {
|
||||
int slash = slotName.lastIndexOf('/');
|
||||
if (slash != -1) {
|
||||
pathName = slotName.substring(0, slash);
|
||||
slotName = slotName.substring(slash + 1);
|
||||
}
|
||||
}
|
||||
BoneData *boneData = skeletonData->_bones[readVarint(input, true)];
|
||||
SlotData *slotData = new (__FILE__, __LINE__) SlotData(i, slotName, *boneData);
|
||||
|
||||
@ -198,10 +198,10 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
||||
}
|
||||
slotData->_attachmentName = readStringRef(input, skeletonData);
|
||||
slotData->_blendMode = static_cast<BlendMode>(readVarint(input, true));
|
||||
if (nonessential) {
|
||||
slotData->_visible = readBoolean(input);
|
||||
slotData->_path = pathName;
|
||||
}
|
||||
if (nonessential) {
|
||||
slotData->_visible = readBoolean(input);
|
||||
slotData->_path = pathName;
|
||||
}
|
||||
skeletonData->_slots[i] = slotData;
|
||||
}
|
||||
|
||||
@ -217,14 +217,14 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
||||
for (int ii = 0; ii < bonesCount; ++ii)
|
||||
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
||||
data->_target = skeletonData->_bones[readVarint(input, true)];
|
||||
int flags = readByte(input);
|
||||
data->_skinRequired = (flags & 1) != 0;
|
||||
data->_bendDirection = (flags & 2) != 0 ? 1 : -1;
|
||||
data->_compress = (flags & 4) != 0;
|
||||
data->_stretch = (flags & 8) != 0;
|
||||
data->_uniform = (flags & 16) != 0;
|
||||
if ((flags & 32) != 0) data->_mix = (flags & 64) != 0 ? readFloat(input) : 1;
|
||||
if ((flags & 128) != 0) data->_softness = readFloat(input) * _scale;
|
||||
int flags = readByte(input);
|
||||
data->_skinRequired = (flags & 1) != 0;
|
||||
data->_bendDirection = (flags & 2) != 0 ? 1 : -1;
|
||||
data->_compress = (flags & 4) != 0;
|
||||
data->_stretch = (flags & 8) != 0;
|
||||
data->_uniform = (flags & 16) != 0;
|
||||
if ((flags & 32) != 0) data->_mix = (flags & 64) != 0 ? readFloat(input) : 1;
|
||||
if ((flags & 128) != 0) data->_softness = readFloat(input) * _scale;
|
||||
|
||||
skeletonData->_ikConstraints[i] = data;
|
||||
}
|
||||
@ -241,25 +241,25 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
||||
for (int ii = 0; ii < bonesCount; ++ii)
|
||||
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
||||
data->_target = skeletonData->_bones[readVarint(input, true)];
|
||||
int flags = readByte(input);
|
||||
data->_skinRequired = (flags & 1) != 0;
|
||||
data->_local = (flags & 2) != 0;
|
||||
data->_relative = (flags & 4) != 0;
|
||||
if ((flags & 8) != 0) data->_offsetRotation = readFloat(input);
|
||||
if ((flags & 16) != 0) data->_offsetX =readFloat(input) * _scale;
|
||||
if ((flags & 32) != 0) data->_offsetY = readFloat(input) * _scale;
|
||||
if ((flags & 64) != 0) data->_offsetScaleX = readFloat(input);
|
||||
if ((flags & 128) != 0) data->_offsetScaleY = readFloat(input);
|
||||
flags = readByte(input);
|
||||
if ((flags & 1) != 0) data->_offsetShearY = readFloat(input);
|
||||
if ((flags & 2) != 0) data->_mixRotate = readFloat(input);
|
||||
if ((flags & 4) != 0) data->_mixX = readFloat(input);
|
||||
if ((flags & 8) != 0) data->_mixY = readFloat(input);
|
||||
if ((flags & 16) != 0) data->_mixScaleX = readFloat(input);
|
||||
if ((flags & 32) != 0) data->_mixScaleY = readFloat(input);
|
||||
if ((flags & 64) != 0) data->_mixShearY = readFloat(input);
|
||||
int flags = readByte(input);
|
||||
data->_skinRequired = (flags & 1) != 0;
|
||||
data->_local = (flags & 2) != 0;
|
||||
data->_relative = (flags & 4) != 0;
|
||||
if ((flags & 8) != 0) data->_offsetRotation = readFloat(input);
|
||||
if ((flags & 16) != 0) data->_offsetX = readFloat(input) * _scale;
|
||||
if ((flags & 32) != 0) data->_offsetY = readFloat(input) * _scale;
|
||||
if ((flags & 64) != 0) data->_offsetScaleX = readFloat(input);
|
||||
if ((flags & 128) != 0) data->_offsetScaleY = readFloat(input);
|
||||
flags = readByte(input);
|
||||
if ((flags & 1) != 0) data->_offsetShearY = readFloat(input);
|
||||
if ((flags & 2) != 0) data->_mixRotate = readFloat(input);
|
||||
if ((flags & 4) != 0) data->_mixX = readFloat(input);
|
||||
if ((flags & 8) != 0) data->_mixY = readFloat(input);
|
||||
if ((flags & 16) != 0) data->_mixScaleX = readFloat(input);
|
||||
if ((flags & 32) != 0) data->_mixScaleY = readFloat(input);
|
||||
if ((flags & 64) != 0) data->_mixShearY = readFloat(input);
|
||||
|
||||
skeletonData->_transformConstraints[i] = data;
|
||||
skeletonData->_transformConstraints[i] = data;
|
||||
}
|
||||
|
||||
/* Path constraints */
|
||||
@ -275,11 +275,11 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
||||
for (int ii = 0; ii < bonesCount; ++ii)
|
||||
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
||||
data->_target = skeletonData->_slots[readVarint(input, true)];
|
||||
int flags = readByte(input);
|
||||
data->_positionMode = (PositionMode)(flags & 1);
|
||||
data->_spacingMode = (SpacingMode)((flags >> 1) & 3);
|
||||
data->_rotateMode = (RotateMode)((flags >> 3) & 3);
|
||||
if ((flags & 128) != 0) data->_offsetRotation = readFloat(input);
|
||||
int flags = readByte(input);
|
||||
data->_positionMode = (PositionMode) (flags & 1);
|
||||
data->_spacingMode = (SpacingMode) ((flags >> 1) & 3);
|
||||
data->_rotateMode = (RotateMode) ((flags >> 3) & 3);
|
||||
if ((flags & 128) != 0) data->_offsetRotation = readFloat(input);
|
||||
data->_position = readFloat(input);
|
||||
if (data->_positionMode == PositionMode_Fixed) data->_position *= _scale;
|
||||
data->_spacing = readFloat(input);
|
||||
@ -291,40 +291,40 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
||||
skeletonData->_pathConstraints[i] = data;
|
||||
}
|
||||
|
||||
// Physics constraints.
|
||||
int physicsConstraintsCount = readVarint(input, true);
|
||||
skeletonData->_physicsConstraints.setSize(physicsConstraintsCount, 0);
|
||||
for (int i = 0; i < physicsConstraintsCount; i++) {
|
||||
const char *name = readString(input);
|
||||
PhysicsConstraintData *data = new (__FILE__, __LINE__) PhysicsConstraintData(String(name, true));
|
||||
data->_order = readVarint(input, true);
|
||||
data->_bone = skeletonData->_bones[readVarint(input, true)];
|
||||
int flags = readByte(input);
|
||||
data->_skinRequired = (flags & 1) != 0;
|
||||
if ((flags & 2) != 0) data->_x = readFloat(input);
|
||||
if ((flags & 4) != 0) data->_y = readFloat(input);
|
||||
if ((flags & 8) != 0) data->_rotate = readFloat(input);
|
||||
if ((flags & 16) != 0) data->_scaleX = readFloat(input);
|
||||
if ((flags & 32) != 0) data->_shearX = readFloat(input);
|
||||
data->_limit = ((flags & 64) != 0 ? readFloat(input) : 5000) * _scale;
|
||||
data->_step = 1.f / readByte(input);
|
||||
data->_inertia = readFloat(input);
|
||||
data->_strength = readFloat(input);
|
||||
data->_damping = readFloat(input);
|
||||
data->_massInverse = (flags & 128) != 0 ? readFloat(input) : 1;
|
||||
data->_wind = readFloat(input);
|
||||
data->_gravity = readFloat(input);
|
||||
flags = readByte(input);
|
||||
if ((flags & 1) != 0) data->_inertiaGlobal = true;
|
||||
if ((flags & 2) != 0) data->_strengthGlobal = true;
|
||||
if ((flags & 4) != 0) data->_dampingGlobal = true;
|
||||
if ((flags & 8) != 0) data->_massGlobal = true;
|
||||
if ((flags & 16) != 0) data->_windGlobal = true;
|
||||
if ((flags & 32) != 0) data->_gravityGlobal = true;
|
||||
if ((flags & 64) != 0) data->_mixGlobal = true;
|
||||
data->_mix = (flags & 128) != 0 ? readFloat(input) : 1;
|
||||
skeletonData->_physicsConstraints[i] = data;
|
||||
}
|
||||
// Physics constraints.
|
||||
int physicsConstraintsCount = readVarint(input, true);
|
||||
skeletonData->_physicsConstraints.setSize(physicsConstraintsCount, 0);
|
||||
for (int i = 0; i < physicsConstraintsCount; i++) {
|
||||
const char *name = readString(input);
|
||||
PhysicsConstraintData *data = new (__FILE__, __LINE__) PhysicsConstraintData(String(name, true));
|
||||
data->_order = readVarint(input, true);
|
||||
data->_bone = skeletonData->_bones[readVarint(input, true)];
|
||||
int flags = readByte(input);
|
||||
data->_skinRequired = (flags & 1) != 0;
|
||||
if ((flags & 2) != 0) data->_x = readFloat(input);
|
||||
if ((flags & 4) != 0) data->_y = readFloat(input);
|
||||
if ((flags & 8) != 0) data->_rotate = readFloat(input);
|
||||
if ((flags & 16) != 0) data->_scaleX = readFloat(input);
|
||||
if ((flags & 32) != 0) data->_shearX = readFloat(input);
|
||||
data->_limit = ((flags & 64) != 0 ? readFloat(input) : 5000) * _scale;
|
||||
data->_step = 1.f / readByte(input);
|
||||
data->_inertia = readFloat(input);
|
||||
data->_strength = readFloat(input);
|
||||
data->_damping = readFloat(input);
|
||||
data->_massInverse = (flags & 128) != 0 ? readFloat(input) : 1;
|
||||
data->_wind = readFloat(input);
|
||||
data->_gravity = readFloat(input);
|
||||
flags = readByte(input);
|
||||
if ((flags & 1) != 0) data->_inertiaGlobal = true;
|
||||
if ((flags & 2) != 0) data->_strengthGlobal = true;
|
||||
if ((flags & 4) != 0) data->_dampingGlobal = true;
|
||||
if ((flags & 8) != 0) data->_massGlobal = true;
|
||||
if ((flags & 16) != 0) data->_windGlobal = true;
|
||||
if ((flags & 32) != 0) data->_gravityGlobal = true;
|
||||
if ((flags & 64) != 0) data->_mixGlobal = true;
|
||||
data->_mix = (flags & 128) != 0 ? readFloat(input) : 1;
|
||||
skeletonData->_physicsConstraints[i] = data;
|
||||
}
|
||||
|
||||
/* Default skin. */
|
||||
Skin *defaultSkin = readSkin(input, true, skeletonData, nonessential);
|
||||
@ -507,7 +507,7 @@ Skin *SkeletonBinary::readSkin(DataInput *input, bool defaultSkin, SkeletonData
|
||||
} else {
|
||||
skin = new (__FILE__, __LINE__) Skin(String(readString(input), true));
|
||||
|
||||
if (nonessential) readColor(input, skin->getColor());
|
||||
if (nonessential) readColor(input, skin->getColor());
|
||||
|
||||
for (int i = 0, n = readVarint(input, true); i < n; i++) {
|
||||
int boneIndex = readVarint(input, true);
|
||||
@ -533,11 +533,11 @@ Skin *SkeletonBinary::readSkin(DataInput *input, bool defaultSkin, SkeletonData
|
||||
skin->getConstraints().add(skeletonData->_pathConstraints[pathIndex]);
|
||||
}
|
||||
|
||||
for (int i = 0, n = readVarint(input, true); i < n; i++) {
|
||||
int physicsIndex = readVarint(input, true);
|
||||
if (physicsIndex >= (int) skeletonData->_physicsConstraints.size()) return NULL;
|
||||
skin->getConstraints().add(skeletonData->_physicsConstraints[physicsIndex]);
|
||||
}
|
||||
for (int i = 0, n = readVarint(input, true); i < n; i++) {
|
||||
int physicsIndex = readVarint(input, true);
|
||||
if (physicsIndex >= (int) skeletonData->_physicsConstraints.size()) return NULL;
|
||||
skin->getConstraints().add(skeletonData->_physicsConstraints[physicsIndex]);
|
||||
}
|
||||
slotCount = readVarint(input, true);
|
||||
}
|
||||
|
||||
@ -568,16 +568,16 @@ Sequence *SkeletonBinary::readSequence(DataInput *input) {
|
||||
Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slotIndex, const String &attachmentName,
|
||||
SkeletonData *skeletonData, bool nonessential) {
|
||||
|
||||
int flags = readByte(input);
|
||||
String name = (flags & 8) != 0 ? readStringRef(input, skeletonData) : attachmentName;
|
||||
int flags = readByte(input);
|
||||
String name = (flags & 8) != 0 ? readStringRef(input, skeletonData) : attachmentName;
|
||||
AttachmentType type = static_cast<AttachmentType>(flags & 0x7);
|
||||
switch (type) {
|
||||
case AttachmentType_Region: {
|
||||
String path = (flags & 16) != 0 ? readStringRef(input, skeletonData) : name;
|
||||
Color color(1, 1, 1, 1);
|
||||
if ((flags & 32) != 0) readColor(input, color);
|
||||
Sequence *sequence = (flags & 64) != 0 ? readSequence(input) : nullptr;
|
||||
float rotation = (flags & 128) != 0 ? readFloat(input) : 0;
|
||||
String path = (flags & 16) != 0 ? readStringRef(input, skeletonData) : name;
|
||||
Color color(1, 1, 1, 1);
|
||||
if ((flags & 32) != 0) readColor(input, color);
|
||||
Sequence *sequence = (flags & 64) != 0 ? readSequence(input) : nullptr;
|
||||
float rotation = (flags & 128) != 0 ? readFloat(input) : 0;
|
||||
float x = readFloat(input) * _scale;
|
||||
float y = readFloat(input) * _scale;
|
||||
float scaleX = readFloat(input);
|
||||
@ -627,14 +627,14 @@ Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slo
|
||||
float height = 0;
|
||||
Vector<unsigned short> edges;
|
||||
|
||||
String path = (flags & 16) != 0 ? readStringRef(input, skeletonData) : name;
|
||||
Color color(1, 1, 1, 1);
|
||||
if ((flags & 32) != 0) readColor(input, color);
|
||||
Sequence *sequence = (flags & 64) != 0 ? readSequence(input) : nullptr;
|
||||
String path = (flags & 16) != 0 ? readStringRef(input, skeletonData) : name;
|
||||
Color color(1, 1, 1, 1);
|
||||
if ((flags & 32) != 0) readColor(input, color);
|
||||
Sequence *sequence = (flags & 64) != 0 ? readSequence(input) : nullptr;
|
||||
hullLength = readVarint(input, true);
|
||||
int verticesLength = readVertices(input, vertices, bones, (flags & 128) != 0);
|
||||
readFloatArray(input, verticesLength, 1, uvs);
|
||||
readShortArray(input, triangles, (verticesLength - hullLength - 2) * 3);
|
||||
int verticesLength = readVertices(input, vertices, bones, (flags & 128) != 0);
|
||||
readFloatArray(input, verticesLength, 1, uvs);
|
||||
readShortArray(input, triangles, (verticesLength - hullLength - 2) * 3);
|
||||
|
||||
if (nonessential) {
|
||||
readShortArray(input, edges, readVarint(input, true));
|
||||
@ -666,14 +666,14 @@ Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slo
|
||||
return mesh;
|
||||
}
|
||||
case AttachmentType_Linkedmesh: {
|
||||
String path = (flags & 16) != 0 ? readStringRef(input, skeletonData) : name;
|
||||
Color color(1, 1, 1, 1);
|
||||
if ((flags & 32) != 0) readColor(input, color);
|
||||
Sequence *sequence = (flags & 64) != 0 ? readSequence(input) : nullptr;
|
||||
bool inheritTimelines = (flags & 128) != 0;
|
||||
int skinIndex = readVarint(input, true);
|
||||
String path = (flags & 16) != 0 ? readStringRef(input, skeletonData) : name;
|
||||
Color color(1, 1, 1, 1);
|
||||
if ((flags & 32) != 0) readColor(input, color);
|
||||
Sequence *sequence = (flags & 64) != 0 ? readSequence(input) : nullptr;
|
||||
bool inheritTimelines = (flags & 128) != 0;
|
||||
int skinIndex = readVarint(input, true);
|
||||
String parent(readStringRef(input, skeletonData));
|
||||
float width = 0, height = 0;
|
||||
float width = 0, height = 0;
|
||||
if (nonessential) {
|
||||
width = readFloat(input) * _scale;
|
||||
height = readFloat(input) * _scale;
|
||||
@ -756,14 +756,14 @@ Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slo
|
||||
|
||||
int SkeletonBinary::readVertices(DataInput *input, Vector<float> &vertices, Vector<int> &bones, bool weighted) {
|
||||
float scale = _scale;
|
||||
int vertexCount = readVarint(input, true);
|
||||
int vertexCount = readVarint(input, true);
|
||||
int verticesLength = vertexCount << 1;
|
||||
if (!weighted) {
|
||||
readFloatArray(input, verticesLength, scale, vertices);
|
||||
return verticesLength;
|
||||
}
|
||||
vertices.ensureCapacity(verticesLength * 3 * 3);
|
||||
bones.ensureCapacity(verticesLength * 3);
|
||||
if (!weighted) {
|
||||
readFloatArray(input, verticesLength, scale, vertices);
|
||||
return verticesLength;
|
||||
}
|
||||
vertices.ensureCapacity(verticesLength * 3 * 3);
|
||||
bones.ensureCapacity(verticesLength * 3);
|
||||
for (int i = 0; i < vertexCount; ++i) {
|
||||
int boneCount = readVarint(input, true);
|
||||
bones.add(boneCount);
|
||||
@ -774,7 +774,7 @@ int SkeletonBinary::readVertices(DataInput *input, Vector<float> &vertices, Vect
|
||||
vertices.add(readFloat(input));
|
||||
}
|
||||
}
|
||||
return verticesLength;
|
||||
return verticesLength;
|
||||
}
|
||||
|
||||
void SkeletonBinary::readFloatArray(DataInput *input, int n, float scale, Vector<float> &array) {
|
||||
@ -795,7 +795,7 @@ void SkeletonBinary::readFloatArray(DataInput *input, int n, float scale, Vector
|
||||
void SkeletonBinary::readShortArray(DataInput *input, Vector<unsigned short> &array, int n) {
|
||||
array.setSize(n, 0);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
array[i] = (short)readVarint(input, true);
|
||||
array[i] = (short) readVarint(input, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -809,7 +809,7 @@ void SkeletonBinary::setBezier(DataInput *input, CurveTimeline *timeline, int be
|
||||
timeline->setBezier(bezier, frame, value, time1, value1, cx1, cy1 * scale, cx2, cy2 * scale, time2, value2);
|
||||
}
|
||||
|
||||
void SkeletonBinary::readTimeline(DataInput *input, Vector<Timeline*> &timelines, CurveTimeline1 *timeline, float scale) {
|
||||
void SkeletonBinary::readTimeline(DataInput *input, Vector<Timeline *> &timelines, CurveTimeline1 *timeline, float scale) {
|
||||
float time = readFloat(input);
|
||||
float value = readFloat(input) * scale;
|
||||
for (int frame = 0, bezier = 0, frameLast = (int) timeline->getFrameCount() - 1;; frame++) {
|
||||
@ -827,10 +827,10 @@ void SkeletonBinary::readTimeline(DataInput *input, Vector<Timeline*> &timelines
|
||||
time = time2;
|
||||
value = value2;
|
||||
}
|
||||
timelines.add(timeline);
|
||||
timelines.add(timeline);
|
||||
}
|
||||
|
||||
void SkeletonBinary::readTimeline2(DataInput *input, Vector<Timeline*> &timelines, CurveTimeline2 *timeline, float scale) {
|
||||
void SkeletonBinary::readTimeline2(DataInput *input, Vector<Timeline *> &timelines, CurveTimeline2 *timeline, float scale) {
|
||||
float time = readFloat(input);
|
||||
float value1 = readFloat(input) * scale;
|
||||
float value2 = readFloat(input) * scale;
|
||||
@ -1086,61 +1086,61 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
|
||||
for (int ii = 0, nn = readVarint(input, true); ii < nn; ++ii) {
|
||||
unsigned char timelineType = readByte(input);
|
||||
int frameCount = readVarint(input, true);
|
||||
if (timelineType == BONE_INHERIT) {
|
||||
InheritTimeline *timeline = new (__FILE__, __LINE__) InheritTimeline(frameCount, boneIndex);
|
||||
for (int frame = 0; frame < frameCount; frame++) {
|
||||
float time = readFloat(input);
|
||||
Inherit inherit = (Inherit)readByte(input);
|
||||
timeline->setFrame(frame, time, inherit);
|
||||
}
|
||||
timelines.add(timeline);
|
||||
continue;
|
||||
}
|
||||
int bezierCount = readVarint(input, true);
|
||||
if (timelineType == BONE_INHERIT) {
|
||||
InheritTimeline *timeline = new (__FILE__, __LINE__) InheritTimeline(frameCount, boneIndex);
|
||||
for (int frame = 0; frame < frameCount; frame++) {
|
||||
float time = readFloat(input);
|
||||
Inherit inherit = (Inherit) readByte(input);
|
||||
timeline->setFrame(frame, time, inherit);
|
||||
}
|
||||
timelines.add(timeline);
|
||||
continue;
|
||||
}
|
||||
int bezierCount = readVarint(input, true);
|
||||
switch (timelineType) {
|
||||
case BONE_ROTATE:
|
||||
readTimeline(input, timelines,
|
||||
new (__FILE__, __LINE__) RotateTimeline(frameCount, bezierCount, boneIndex),
|
||||
1);
|
||||
new (__FILE__, __LINE__) RotateTimeline(frameCount, bezierCount, boneIndex),
|
||||
1);
|
||||
break;
|
||||
case BONE_TRANSLATE:
|
||||
readTimeline2(input, timelines,new (__FILE__, __LINE__) TranslateTimeline(frameCount, bezierCount, boneIndex), scale);
|
||||
readTimeline2(input, timelines, new (__FILE__, __LINE__) TranslateTimeline(frameCount, bezierCount, boneIndex), scale);
|
||||
break;
|
||||
case BONE_TRANSLATEX:
|
||||
readTimeline(input, timelines, new (__FILE__, __LINE__) TranslateXTimeline(frameCount, bezierCount, boneIndex), scale);
|
||||
break;
|
||||
case BONE_TRANSLATEY:
|
||||
readTimeline(input, timelines, new (__FILE__, __LINE__) TranslateYTimeline(frameCount, bezierCount, boneIndex), scale);
|
||||
readTimeline(input, timelines, new (__FILE__, __LINE__) TranslateYTimeline(frameCount, bezierCount, boneIndex), scale);
|
||||
break;
|
||||
case BONE_SCALE:
|
||||
readTimeline2(input, timelines,
|
||||
new (__FILE__, __LINE__) ScaleTimeline(frameCount, bezierCount, boneIndex),
|
||||
1);
|
||||
new (__FILE__, __LINE__) ScaleTimeline(frameCount, bezierCount, boneIndex),
|
||||
1);
|
||||
break;
|
||||
case BONE_SCALEX:
|
||||
readTimeline(input, timelines,
|
||||
new (__FILE__, __LINE__) ScaleXTimeline(frameCount, bezierCount, boneIndex),
|
||||
1);
|
||||
new (__FILE__, __LINE__) ScaleXTimeline(frameCount, bezierCount, boneIndex),
|
||||
1);
|
||||
break;
|
||||
case BONE_SCALEY:
|
||||
readTimeline(input, timelines,
|
||||
new (__FILE__, __LINE__) ScaleYTimeline(frameCount, bezierCount, boneIndex),
|
||||
1);
|
||||
new (__FILE__, __LINE__) ScaleYTimeline(frameCount, bezierCount, boneIndex),
|
||||
1);
|
||||
break;
|
||||
case BONE_SHEAR:
|
||||
readTimeline2(input, timelines,
|
||||
new (__FILE__, __LINE__) ShearTimeline(frameCount, bezierCount, boneIndex),
|
||||
1);
|
||||
new (__FILE__, __LINE__) ShearTimeline(frameCount, bezierCount, boneIndex),
|
||||
1);
|
||||
break;
|
||||
case BONE_SHEARX:
|
||||
readTimeline(input, timelines,
|
||||
new (__FILE__, __LINE__) ShearXTimeline(frameCount, bezierCount, boneIndex),
|
||||
1);
|
||||
new (__FILE__, __LINE__) ShearXTimeline(frameCount, bezierCount, boneIndex),
|
||||
1);
|
||||
break;
|
||||
case BONE_SHEARY:
|
||||
readTimeline(input, timelines,
|
||||
new (__FILE__, __LINE__) ShearYTimeline(frameCount, bezierCount, boneIndex),
|
||||
1);
|
||||
new (__FILE__, __LINE__) ShearYTimeline(frameCount, bezierCount, boneIndex),
|
||||
1);
|
||||
break;
|
||||
default: {
|
||||
ContainerUtil::cleanUpVectorOfPointers(timelines);
|
||||
@ -1158,19 +1158,19 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
|
||||
int frameLast = frameCount - 1;
|
||||
int bezierCount = readVarint(input, true);
|
||||
IkConstraintTimeline *timeline = new (__FILE__, __LINE__) IkConstraintTimeline(frameCount, bezierCount, index);
|
||||
int flags = readByte(input);
|
||||
float time = readFloat(input), mix = (flags & 1) != 0 ? ((flags & 2) != 0 ? readFloat(input) : 1) : 0;
|
||||
float softness = (flags & 4) != 0 ? readFloat(input) * scale : 0;
|
||||
for (int frame = 0, bezier = 0;; frame++) {
|
||||
int flags = readByte(input);
|
||||
float time = readFloat(input), mix = (flags & 1) != 0 ? ((flags & 2) != 0 ? readFloat(input) : 1) : 0;
|
||||
float softness = (flags & 4) != 0 ? readFloat(input) * scale : 0;
|
||||
for (int frame = 0, bezier = 0;; frame++) {
|
||||
timeline->setFrame(frame, time, mix, softness, (flags & 8) != 0 ? 1 : -1, (flags & 16) != 0, (flags & 32) != 0);
|
||||
if (frame == frameLast) break;
|
||||
flags = readByte(input);
|
||||
float time2 = readFloat(input), mix2 = (flags & 1) != 0 ? ((flags & 2) != 0 ? readFloat(input) : 1) : 0;
|
||||
float softness2 = (flags & 4) != 0 ? readFloat(input) * scale : 0;
|
||||
if ((flags & 64) != 0)
|
||||
timeline->setStepped(frame);
|
||||
else if ((flags & 128) != 0) {
|
||||
setBezier(input, timeline, bezier++, frame, 0, time, time2, mix, mix2, 1);
|
||||
flags = readByte(input);
|
||||
float time2 = readFloat(input), mix2 = (flags & 1) != 0 ? ((flags & 2) != 0 ? readFloat(input) : 1) : 0;
|
||||
float softness2 = (flags & 4) != 0 ? readFloat(input) * scale : 0;
|
||||
if ((flags & 64) != 0)
|
||||
timeline->setStepped(frame);
|
||||
else if ((flags & 128) != 0) {
|
||||
setBezier(input, timeline, bezier++, frame, 0, time, time2, mix, mix2, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 1, time, time2, softness, softness2, scale);
|
||||
}
|
||||
time = time2;
|
||||
@ -1235,21 +1235,21 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
|
||||
int type = readByte(input);
|
||||
int frameCount = readVarint(input, true);
|
||||
int bezierCount = readVarint(input, true);
|
||||
switch (type) {
|
||||
switch (type) {
|
||||
case PATH_POSITION: {
|
||||
readTimeline(input, timelines, new PathConstraintPositionTimeline(frameCount, bezierCount, index),
|
||||
data->_positionMode == PositionMode_Fixed ? scale : 1);
|
||||
data->_positionMode == PositionMode_Fixed ? scale : 1);
|
||||
break;
|
||||
}
|
||||
case PATH_SPACING: {
|
||||
readTimeline(input, timelines,
|
||||
new PathConstraintSpacingTimeline(frameCount,
|
||||
bezierCount,
|
||||
index),
|
||||
data->_spacingMode == SpacingMode_Length ||
|
||||
data->_spacingMode == SpacingMode_Fixed
|
||||
? scale
|
||||
: 1);
|
||||
new PathConstraintSpacingTimeline(frameCount,
|
||||
bezierCount,
|
||||
index),
|
||||
data->_spacingMode == SpacingMode_Length ||
|
||||
data->_spacingMode == SpacingMode_Fixed
|
||||
? scale
|
||||
: 1);
|
||||
break;
|
||||
}
|
||||
case PATH_MIX:
|
||||
@ -1284,44 +1284,44 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
|
||||
}
|
||||
}
|
||||
|
||||
// Physics timelines.
|
||||
for (int i = 0, n = readVarint(input, true); i < n; i++) {
|
||||
int index = readVarint(input, true) - 1;
|
||||
for (int ii = 0, nn = readVarint(input, true); ii < nn; ii++) {
|
||||
int type = readByte(input);
|
||||
int frameCount = readVarint(input, true);
|
||||
if (type == PHYSICS_RESET) {
|
||||
PhysicsConstraintResetTimeline *timeline = new (__FILE__, __LINE__) PhysicsConstraintResetTimeline(frameCount, index);
|
||||
for (int frame = 0; frame < frameCount; frame++)
|
||||
timeline->setFrame(frame, readFloat(input));
|
||||
timelines.add(timeline);
|
||||
continue;
|
||||
}
|
||||
int bezierCount = readVarint(input, true);
|
||||
switch (type) {
|
||||
case PHYSICS_INERTIA:
|
||||
readTimeline(input, timelines, new PhysicsConstraintInertiaTimeline(frameCount, bezierCount, index), 1);
|
||||
break;
|
||||
case PHYSICS_STRENGTH:
|
||||
readTimeline(input, timelines, new PhysicsConstraintStrengthTimeline(frameCount, bezierCount, index), 1);
|
||||
break;
|
||||
case PHYSICS_DAMPING:
|
||||
readTimeline(input, timelines, new PhysicsConstraintDampingTimeline(frameCount, bezierCount, index), 1);
|
||||
break;
|
||||
case PHYSICS_MASS:
|
||||
readTimeline(input, timelines, new PhysicsConstraintMassTimeline(frameCount, bezierCount, index), 1);
|
||||
break;
|
||||
case PHYSICS_WIND:
|
||||
readTimeline(input, timelines, new PhysicsConstraintWindTimeline(frameCount, bezierCount, index), 1);
|
||||
break;
|
||||
case PHYSICS_GRAVITY:
|
||||
readTimeline(input, timelines, new PhysicsConstraintGravityTimeline(frameCount, bezierCount, index), 1);
|
||||
break;
|
||||
case PHYSICS_MIX:
|
||||
readTimeline(input, timelines, new PhysicsConstraintMixTimeline(frameCount, bezierCount, index), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Physics timelines.
|
||||
for (int i = 0, n = readVarint(input, true); i < n; i++) {
|
||||
int index = readVarint(input, true) - 1;
|
||||
for (int ii = 0, nn = readVarint(input, true); ii < nn; ii++) {
|
||||
int type = readByte(input);
|
||||
int frameCount = readVarint(input, true);
|
||||
if (type == PHYSICS_RESET) {
|
||||
PhysicsConstraintResetTimeline *timeline = new (__FILE__, __LINE__) PhysicsConstraintResetTimeline(frameCount, index);
|
||||
for (int frame = 0; frame < frameCount; frame++)
|
||||
timeline->setFrame(frame, readFloat(input));
|
||||
timelines.add(timeline);
|
||||
continue;
|
||||
}
|
||||
int bezierCount = readVarint(input, true);
|
||||
switch (type) {
|
||||
case PHYSICS_INERTIA:
|
||||
readTimeline(input, timelines, new PhysicsConstraintInertiaTimeline(frameCount, bezierCount, index), 1);
|
||||
break;
|
||||
case PHYSICS_STRENGTH:
|
||||
readTimeline(input, timelines, new PhysicsConstraintStrengthTimeline(frameCount, bezierCount, index), 1);
|
||||
break;
|
||||
case PHYSICS_DAMPING:
|
||||
readTimeline(input, timelines, new PhysicsConstraintDampingTimeline(frameCount, bezierCount, index), 1);
|
||||
break;
|
||||
case PHYSICS_MASS:
|
||||
readTimeline(input, timelines, new PhysicsConstraintMassTimeline(frameCount, bezierCount, index), 1);
|
||||
break;
|
||||
case PHYSICS_WIND:
|
||||
readTimeline(input, timelines, new PhysicsConstraintWindTimeline(frameCount, bezierCount, index), 1);
|
||||
break;
|
||||
case PHYSICS_GRAVITY:
|
||||
readTimeline(input, timelines, new PhysicsConstraintGravityTimeline(frameCount, bezierCount, index), 1);
|
||||
break;
|
||||
case PHYSICS_MIX:
|
||||
readTimeline(input, timelines, new PhysicsConstraintMixTimeline(frameCount, bezierCount, index), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Attachment timelines.
|
||||
for (int i = 0, n = readVarint(input, true); i < n; ++i) {
|
||||
@ -1467,12 +1467,12 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
|
||||
event->_intValue = readVarint(input, false);
|
||||
event->_floatValue = readFloat(input);
|
||||
const char *event_stringValue = readString(input);
|
||||
if (event_stringValue == nullptr) {
|
||||
event->_stringValue = eventData->_stringValue;
|
||||
} else {
|
||||
event->_stringValue = String(event_stringValue);
|
||||
SpineExtension::free(event_stringValue, __FILE__, __LINE__);
|
||||
}
|
||||
if (event_stringValue == nullptr) {
|
||||
event->_stringValue = eventData->_stringValue;
|
||||
} else {
|
||||
event->_stringValue = String(event_stringValue);
|
||||
SpineExtension::free(event_stringValue, __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
if (!eventData->_audioPath.isEmpty()) {
|
||||
event->_volume = readFloat(input);
|
||||
|
||||
@ -163,8 +163,8 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
||||
skeletonData->_y = Json::getFloat(skeleton, "y", 0);
|
||||
skeletonData->_width = Json::getFloat(skeleton, "width", 0);
|
||||
skeletonData->_height = Json::getFloat(skeleton, "height", 0);
|
||||
skeletonData->_referenceScale = Json::getFloat(skeleton, "referenceScale", 100) * _scale;
|
||||
skeletonData->_fps = Json::getFloat(skeleton, "fps", 30);
|
||||
skeletonData->_referenceScale = Json::getFloat(skeleton, "referenceScale", 100) * _scale;
|
||||
skeletonData->_fps = Json::getFloat(skeleton, "fps", 30);
|
||||
skeletonData->_audioPath = Json::getString(skeleton, "audio", 0);
|
||||
skeletonData->_imagesPath = Json::getString(skeleton, "images", 0);
|
||||
}
|
||||
@ -214,8 +214,8 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
||||
const char *color = Json::getString(boneMap, "color", NULL);
|
||||
if (color) toColor(data->getColor(), color, true);
|
||||
|
||||
data->_icon = Json::getString(boneMap, "icon", "");
|
||||
data->_visible = Json::getBoolean(boneMap, "visible", true);
|
||||
data->_icon = Json::getString(boneMap, "icon", "");
|
||||
data->_visible = Json::getBoolean(boneMap, "visible", true);
|
||||
|
||||
skeletonData->_bones[i] = data;
|
||||
bonesCount++;
|
||||
@ -241,13 +241,13 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
String pathName = "";
|
||||
String slotName = String(Json::getString(slotMap, "name", 0));
|
||||
int slash = slotName.lastIndexOf('/');
|
||||
if (slash != -1) {
|
||||
pathName = slotName.substring(0, slash);
|
||||
slotName = slotName.substring(slash + 1);
|
||||
}
|
||||
String pathName = "";
|
||||
String slotName = String(Json::getString(slotMap, "name", 0));
|
||||
int slash = slotName.lastIndexOf('/');
|
||||
if (slash != -1) {
|
||||
pathName = slotName.substring(0, slash);
|
||||
slotName = slotName.substring(slash + 1);
|
||||
}
|
||||
data = new (__FILE__, __LINE__) SlotData(i, slotName, *boneData);
|
||||
|
||||
color = Json::getString(slotMap, "color", 0);
|
||||
@ -280,8 +280,8 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
||||
else if (strcmp(item->_valueString, "screen") == 0)
|
||||
data->_blendMode = BlendMode_Screen;
|
||||
}
|
||||
data->_visible = Json::getBoolean(slotMap, "visible", true);
|
||||
data->_path = pathName;
|
||||
data->_visible = Json::getBoolean(slotMap, "visible", true);
|
||||
data->_path = pathName;
|
||||
skeletonData->_slots[i] = data;
|
||||
}
|
||||
}
|
||||
@ -457,53 +457,53 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Physics constraints */
|
||||
physics = Json::getItem(root, "physics");
|
||||
if (physics) {
|
||||
Json *constraintMap;
|
||||
skeletonData->_physicsConstraints.ensureCapacity(physics->_size);
|
||||
skeletonData->_physicsConstraints.setSize(physics->_size, 0);
|
||||
for (constraintMap = physics->_child, i = 0; constraintMap; constraintMap = constraintMap->_next, ++i) {
|
||||
const char *name;
|
||||
/* Physics constraints */
|
||||
physics = Json::getItem(root, "physics");
|
||||
if (physics) {
|
||||
Json *constraintMap;
|
||||
skeletonData->_physicsConstraints.ensureCapacity(physics->_size);
|
||||
skeletonData->_physicsConstraints.setSize(physics->_size, 0);
|
||||
for (constraintMap = physics->_child, i = 0; constraintMap; constraintMap = constraintMap->_next, ++i) {
|
||||
const char *name;
|
||||
|
||||
PhysicsConstraintData *data = new (__FILE__, __LINE__) PhysicsConstraintData(
|
||||
Json::getString(constraintMap, "name", 0));
|
||||
data->setOrder(Json::getInt(constraintMap, "order", 0));
|
||||
data->setSkinRequired(Json::getBoolean(constraintMap, "skin", false));
|
||||
PhysicsConstraintData *data = new (__FILE__, __LINE__) PhysicsConstraintData(
|
||||
Json::getString(constraintMap, "name", 0));
|
||||
data->setOrder(Json::getInt(constraintMap, "order", 0));
|
||||
data->setSkinRequired(Json::getBoolean(constraintMap, "skin", false));
|
||||
|
||||
name = Json::getString(constraintMap, "bone", 0);
|
||||
data->_bone = skeletonData->findBone(name);
|
||||
if (!data->_bone) {
|
||||
delete skeletonData;
|
||||
setError(root, "Physics bone not found: ", name);
|
||||
return NULL;
|
||||
}
|
||||
name = Json::getString(constraintMap, "bone", 0);
|
||||
data->_bone = skeletonData->findBone(name);
|
||||
if (!data->_bone) {
|
||||
delete skeletonData;
|
||||
setError(root, "Physics bone not found: ", name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data->_x = Json::getFloat(constraintMap, "x", 0);
|
||||
data->_y = Json::getFloat(constraintMap, "y", 0);
|
||||
data->_rotate = Json::getFloat(constraintMap, "rotate", 0);
|
||||
data->_scaleX = Json::getFloat(constraintMap, "scaleX", 0);
|
||||
data->_shearX = Json::getFloat(constraintMap, "shearX", 0);
|
||||
data->_limit = Json::getFloat(constraintMap, "limit", 5000) * _scale;
|
||||
data->_step = 1.0f / Json::getInt(constraintMap, "fps", 60);
|
||||
data->_inertia = Json::getFloat(constraintMap, "inertia", 1);
|
||||
data->_strength = Json::getFloat(constraintMap, "strength", 100);
|
||||
data->_damping = Json::getFloat(constraintMap, "damping", 1);
|
||||
data->_massInverse = 1.0f / Json::getFloat(constraintMap, "mass", 1);
|
||||
data->_wind = Json::getFloat(constraintMap, "wind", 0);
|
||||
data->_gravity = Json::getFloat(constraintMap, "gravity", 0);
|
||||
data->_mix = Json::getFloat(constraintMap, "mix", 1);
|
||||
data->_inertiaGlobal = Json::getBoolean(constraintMap, "inertiaGlobal", false);
|
||||
data->_strengthGlobal = Json::getBoolean(constraintMap, "strengthGlobal", false);
|
||||
data->_dampingGlobal = Json::getBoolean(constraintMap, "dampingGlobal", false);
|
||||
data->_massGlobal = Json::getBoolean(constraintMap, "massGlobal", false);
|
||||
data->_windGlobal = Json::getBoolean(constraintMap, "windGlobal", false);
|
||||
data->_gravityGlobal = Json::getBoolean(constraintMap, "gravityGlobal", false);
|
||||
data->_mixGlobal = Json::getBoolean(constraintMap, "mixGlobal", false);
|
||||
data->_x = Json::getFloat(constraintMap, "x", 0);
|
||||
data->_y = Json::getFloat(constraintMap, "y", 0);
|
||||
data->_rotate = Json::getFloat(constraintMap, "rotate", 0);
|
||||
data->_scaleX = Json::getFloat(constraintMap, "scaleX", 0);
|
||||
data->_shearX = Json::getFloat(constraintMap, "shearX", 0);
|
||||
data->_limit = Json::getFloat(constraintMap, "limit", 5000) * _scale;
|
||||
data->_step = 1.0f / Json::getInt(constraintMap, "fps", 60);
|
||||
data->_inertia = Json::getFloat(constraintMap, "inertia", 1);
|
||||
data->_strength = Json::getFloat(constraintMap, "strength", 100);
|
||||
data->_damping = Json::getFloat(constraintMap, "damping", 1);
|
||||
data->_massInverse = 1.0f / Json::getFloat(constraintMap, "mass", 1);
|
||||
data->_wind = Json::getFloat(constraintMap, "wind", 0);
|
||||
data->_gravity = Json::getFloat(constraintMap, "gravity", 0);
|
||||
data->_mix = Json::getFloat(constraintMap, "mix", 1);
|
||||
data->_inertiaGlobal = Json::getBoolean(constraintMap, "inertiaGlobal", false);
|
||||
data->_strengthGlobal = Json::getBoolean(constraintMap, "strengthGlobal", false);
|
||||
data->_dampingGlobal = Json::getBoolean(constraintMap, "dampingGlobal", false);
|
||||
data->_massGlobal = Json::getBoolean(constraintMap, "massGlobal", false);
|
||||
data->_windGlobal = Json::getBoolean(constraintMap, "windGlobal", false);
|
||||
data->_gravityGlobal = Json::getBoolean(constraintMap, "gravityGlobal", false);
|
||||
data->_mixGlobal = Json::getBoolean(constraintMap, "mixGlobal", false);
|
||||
|
||||
skeletonData->_physicsConstraints[i] = data;
|
||||
}
|
||||
}
|
||||
skeletonData->_physicsConstraints[i] = data;
|
||||
}
|
||||
}
|
||||
|
||||
/* Skins. */
|
||||
skins = Json::getItem(root, "skins");
|
||||
@ -570,18 +570,18 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
||||
}
|
||||
}
|
||||
|
||||
item = Json::getItem(skinMap, "physics");
|
||||
if (item) {
|
||||
for (item = item->_child; item; item = item->_next) {
|
||||
PhysicsConstraintData *data = skeletonData->findPhysicsConstraint(item->_valueString);
|
||||
if (!data) {
|
||||
delete skeletonData;
|
||||
setError(root, String("Skin physics constraint not found: "), item->_valueString);
|
||||
return NULL;
|
||||
}
|
||||
skin->getConstraints().add(data);
|
||||
}
|
||||
}
|
||||
item = Json::getItem(skinMap, "physics");
|
||||
if (item) {
|
||||
for (item = item->_child; item; item = item->_next) {
|
||||
PhysicsConstraintData *data = skeletonData->findPhysicsConstraint(item->_valueString);
|
||||
if (!data) {
|
||||
delete skeletonData;
|
||||
setError(root, String("Skin physics constraint not found: "), item->_valueString);
|
||||
return NULL;
|
||||
}
|
||||
skin->getConstraints().add(data);
|
||||
}
|
||||
}
|
||||
|
||||
skeletonData->_skins[skinsIndex++] = skin;
|
||||
if (strcmp(Json::getString(skinMap, "name", ""), "default") == 0) {
|
||||
@ -956,7 +956,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
|
||||
Json *ik = Json::getItem(root, "ik");
|
||||
Json *transform = Json::getItem(root, "transform");
|
||||
Json *paths = Json::getItem(root, "path");
|
||||
Json *physics = Json::getItem(root, "physics");
|
||||
Json *physics = Json::getItem(root, "physics");
|
||||
Json *attachments = Json::getItem(root, "attachments");
|
||||
Json *drawOrder = Json::getItem(root, "drawOrder");
|
||||
Json *events = Json::getItem(root, "events");
|
||||
@ -1163,26 +1163,26 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
|
||||
frames, boneIndex);
|
||||
timelines.add(readTimeline(timelineMap->_child, timeline, 0, 1));
|
||||
} else if (strcmp(timelineMap->_name, "inherit") == 0) {
|
||||
InheritTimeline *timeline = new (__FILE__, __LINE__) InheritTimeline(frames, boneIndex);
|
||||
for (frame = 0;; frame++) {
|
||||
float time = Json::getFloat(keyMap, "time", 0);
|
||||
const char *value = Json::getString(keyMap, "value", "normal");
|
||||
Inherit inherit = Inherit_Normal;
|
||||
if (strcmp(value, "normal") == 0) inherit = Inherit_Normal;
|
||||
else if (strcmp(value, "onlyTranslation") == 0)
|
||||
inherit = Inherit_OnlyTranslation;
|
||||
else if (strcmp(value, "noRotationOrReflection") == 0)
|
||||
inherit = Inherit_NoRotationOrReflection;
|
||||
else if (strcmp(value, "noScale") == 0)
|
||||
inherit = Inherit_NoScale;
|
||||
else if (strcmp(value, "noScaleOrReflection") == 0)
|
||||
inherit = Inherit_NoScaleOrReflection;
|
||||
timeline->setFrame(frame, time, inherit);
|
||||
nextMap = keyMap->_next;
|
||||
if (!nextMap) break;
|
||||
}
|
||||
timelines.add(timeline);
|
||||
}else {
|
||||
InheritTimeline *timeline = new (__FILE__, __LINE__) InheritTimeline(frames, boneIndex);
|
||||
for (frame = 0;; frame++) {
|
||||
float time = Json::getFloat(keyMap, "time", 0);
|
||||
const char *value = Json::getString(keyMap, "value", "normal");
|
||||
Inherit inherit = Inherit_Normal;
|
||||
if (strcmp(value, "normal") == 0) inherit = Inherit_Normal;
|
||||
else if (strcmp(value, "onlyTranslation") == 0)
|
||||
inherit = Inherit_OnlyTranslation;
|
||||
else if (strcmp(value, "noRotationOrReflection") == 0)
|
||||
inherit = Inherit_NoRotationOrReflection;
|
||||
else if (strcmp(value, "noScale") == 0)
|
||||
inherit = Inherit_NoScale;
|
||||
else if (strcmp(value, "noScaleOrReflection") == 0)
|
||||
inherit = Inherit_NoScaleOrReflection;
|
||||
timeline->setFrame(frame, time, inherit);
|
||||
nextMap = keyMap->_next;
|
||||
if (!nextMap) break;
|
||||
}
|
||||
timelines.add(timeline);
|
||||
} else {
|
||||
ContainerUtil::cleanUpVectorOfPointers(timelines);
|
||||
setError(NULL, "Invalid timeline type for a bone: ", timelineMap->_name);
|
||||
return NULL;
|
||||
@ -1351,53 +1351,53 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Physics constraint timelines. */
|
||||
for (Json *constraintMap = physics ? physics->_child : 0; constraintMap; constraintMap = constraintMap->_next) {
|
||||
int index = -1;
|
||||
if (constraintMap->_name && strlen(constraintMap->_name) > 0) {
|
||||
PhysicsConstraintData *constraint = skeletonData->findPhysicsConstraint(constraintMap->_name);
|
||||
if (!constraint) {
|
||||
ContainerUtil::cleanUpVectorOfPointers(timelines);
|
||||
setError(NULL, "Physics constraint not found: ", constraintMap->_name);
|
||||
return NULL;
|
||||
}
|
||||
index = skeletonData->_physicsConstraints.indexOf(constraint);
|
||||
}
|
||||
for (Json *timelineMap = constraintMap->_child; timelineMap; timelineMap = timelineMap->_next) {
|
||||
keyMap = timelineMap->_child;
|
||||
if (keyMap == NULL) continue;
|
||||
const char *timelineName = timelineMap->_name;
|
||||
int frames = timelineMap->_size;
|
||||
if (strcmp(timelineName, "reset") == 0) {
|
||||
PhysicsConstraintResetTimeline *timeline = new (__FILE__, __LINE__) PhysicsConstraintResetTimeline(frames, index);
|
||||
for (frame = 0; keyMap != nullptr; keyMap = keyMap->_next, frame++) {
|
||||
timeline->setFrame(frame, Json::getFloat(keyMap, "time", 0));
|
||||
}
|
||||
timelines.add(timeline);
|
||||
continue;
|
||||
}
|
||||
/** Physics constraint timelines. */
|
||||
for (Json *constraintMap = physics ? physics->_child : 0; constraintMap; constraintMap = constraintMap->_next) {
|
||||
int index = -1;
|
||||
if (constraintMap->_name && strlen(constraintMap->_name) > 0) {
|
||||
PhysicsConstraintData *constraint = skeletonData->findPhysicsConstraint(constraintMap->_name);
|
||||
if (!constraint) {
|
||||
ContainerUtil::cleanUpVectorOfPointers(timelines);
|
||||
setError(NULL, "Physics constraint not found: ", constraintMap->_name);
|
||||
return NULL;
|
||||
}
|
||||
index = skeletonData->_physicsConstraints.indexOf(constraint);
|
||||
}
|
||||
for (Json *timelineMap = constraintMap->_child; timelineMap; timelineMap = timelineMap->_next) {
|
||||
keyMap = timelineMap->_child;
|
||||
if (keyMap == NULL) continue;
|
||||
const char *timelineName = timelineMap->_name;
|
||||
int frames = timelineMap->_size;
|
||||
if (strcmp(timelineName, "reset") == 0) {
|
||||
PhysicsConstraintResetTimeline *timeline = new (__FILE__, __LINE__) PhysicsConstraintResetTimeline(frames, index);
|
||||
for (frame = 0; keyMap != nullptr; keyMap = keyMap->_next, frame++) {
|
||||
timeline->setFrame(frame, Json::getFloat(keyMap, "time", 0));
|
||||
}
|
||||
timelines.add(timeline);
|
||||
continue;
|
||||
}
|
||||
|
||||
CurveTimeline1 *timeline = nullptr;
|
||||
if (strcmp(timelineName, "inertia") == 0) {
|
||||
timeline = new PhysicsConstraintInertiaTimeline(frames, frames, index);
|
||||
} else if (strcmp(timelineName, "strength") == 0) {
|
||||
timeline = new PhysicsConstraintStrengthTimeline(frames, frames, index);
|
||||
} else if (strcmp(timelineName, "damping") == 0) {
|
||||
timeline = new PhysicsConstraintDampingTimeline(frames, frames, index);
|
||||
} else if (strcmp(timelineName, "mass") == 0) {
|
||||
timeline = new PhysicsConstraintMassTimeline(frames, frames, index);
|
||||
} else if (strcmp(timelineName, "wind") == 0) {
|
||||
timeline = new PhysicsConstraintWindTimeline(frames, frames, index);
|
||||
} else if (strcmp(timelineName, "gravity") == 0) {
|
||||
timeline = new PhysicsConstraintGravityTimeline(frames, frames, index);
|
||||
} else if (strcmp(timelineName, "mix") == 0) {
|
||||
timeline = new PhysicsConstraintMixTimeline(frames, frames, index);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
timelines.add(readTimeline(keyMap, timeline, 0, 1));
|
||||
}
|
||||
}
|
||||
CurveTimeline1 *timeline = nullptr;
|
||||
if (strcmp(timelineName, "inertia") == 0) {
|
||||
timeline = new PhysicsConstraintInertiaTimeline(frames, frames, index);
|
||||
} else if (strcmp(timelineName, "strength") == 0) {
|
||||
timeline = new PhysicsConstraintStrengthTimeline(frames, frames, index);
|
||||
} else if (strcmp(timelineName, "damping") == 0) {
|
||||
timeline = new PhysicsConstraintDampingTimeline(frames, frames, index);
|
||||
} else if (strcmp(timelineName, "mass") == 0) {
|
||||
timeline = new PhysicsConstraintMassTimeline(frames, frames, index);
|
||||
} else if (strcmp(timelineName, "wind") == 0) {
|
||||
timeline = new PhysicsConstraintWindTimeline(frames, frames, index);
|
||||
} else if (strcmp(timelineName, "gravity") == 0) {
|
||||
timeline = new PhysicsConstraintGravityTimeline(frames, frames, index);
|
||||
} else if (strcmp(timelineName, "mix") == 0) {
|
||||
timeline = new PhysicsConstraintMixTimeline(frames, frames, index);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
timelines.add(readTimeline(keyMap, timeline, 0, 1));
|
||||
}
|
||||
}
|
||||
|
||||
/** Attachment timelines. */
|
||||
for (Json *attachmenstMap = attachments ? attachments->_child : NULL; attachmenstMap; attachmenstMap = attachmenstMap->_next) {
|
||||
|
||||
@ -54,7 +54,7 @@ SkeletonDrawable::~SkeletonDrawable() {
|
||||
void SkeletonDrawable::update(float delta, Physics physics) {
|
||||
animationState->update(delta);
|
||||
animationState->apply(*skeleton);
|
||||
skeleton->update(delta);
|
||||
skeleton->update(delta);
|
||||
skeleton->updateWorldTransform(physics);
|
||||
}
|
||||
|
||||
|
||||
@ -612,139 +612,139 @@ void mixAndMatch(SkeletonData *skeletonData, Atlas *atlas) {
|
||||
}
|
||||
|
||||
void celestialCircus(SkeletonData *skeletonData, Atlas *atlas) {
|
||||
SP_UNUSED(atlas);
|
||||
SP_UNUSED(atlas);
|
||||
|
||||
SkeletonDrawable drawable(skeletonData);
|
||||
drawable.timeScale = 1;
|
||||
drawable.setUsePremultipliedAlpha(true);
|
||||
SkeletonDrawable drawable(skeletonData);
|
||||
drawable.timeScale = 1;
|
||||
drawable.setUsePremultipliedAlpha(true);
|
||||
|
||||
Skeleton *skeleton = drawable.skeleton;
|
||||
skeleton->setPosition(320, 480);
|
||||
skeleton->updateWorldTransform(Physics_Update);
|
||||
Skeleton *skeleton = drawable.skeleton;
|
||||
skeleton->setPosition(320, 480);
|
||||
skeleton->updateWorldTransform(Physics_Update);
|
||||
|
||||
drawable.state->setAnimation(0, "swing", true);
|
||||
drawable.state->setAnimation(0, "swing", true);
|
||||
|
||||
sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - celestial circus");
|
||||
window.setFramerateLimit(60);
|
||||
sf::Event event;
|
||||
sf::Clock deltaClock;
|
||||
sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - celestial circus");
|
||||
window.setFramerateLimit(60);
|
||||
sf::Event event;
|
||||
sf::Clock deltaClock;
|
||||
|
||||
while (window.isOpen()) {
|
||||
while (window.pollEvent(event)) {
|
||||
if (event.type == sf::Event::Closed) window.close();
|
||||
}
|
||||
while (window.isOpen()) {
|
||||
while (window.pollEvent(event)) {
|
||||
if (event.type == sf::Event::Closed) window.close();
|
||||
}
|
||||
|
||||
float delta = deltaClock.getElapsedTime().asSeconds();
|
||||
deltaClock.restart();
|
||||
float delta = deltaClock.getElapsedTime().asSeconds();
|
||||
deltaClock.restart();
|
||||
|
||||
drawable.update(delta);
|
||||
drawable.update(delta);
|
||||
|
||||
window.clear();
|
||||
window.draw(drawable);
|
||||
window.display();
|
||||
}
|
||||
window.clear();
|
||||
window.draw(drawable);
|
||||
window.display();
|
||||
}
|
||||
}
|
||||
|
||||
void sack(SkeletonData *skeletonData, Atlas *atlas) {
|
||||
SP_UNUSED(atlas);
|
||||
SP_UNUSED(atlas);
|
||||
|
||||
SkeletonDrawable drawable(skeletonData);
|
||||
drawable.timeScale = 1;
|
||||
drawable.setUsePremultipliedAlpha(true);
|
||||
SkeletonDrawable drawable(skeletonData);
|
||||
drawable.timeScale = 1;
|
||||
drawable.setUsePremultipliedAlpha(true);
|
||||
|
||||
Skeleton *skeleton = drawable.skeleton;
|
||||
skeleton->setPosition(320, 480);
|
||||
skeleton->updateWorldTransform(Physics_Update);
|
||||
Skeleton *skeleton = drawable.skeleton;
|
||||
skeleton->setPosition(320, 480);
|
||||
skeleton->updateWorldTransform(Physics_Update);
|
||||
|
||||
drawable.state->setAnimation(0, "walk", true);
|
||||
drawable.state->setAnimation(0, "walk", true);
|
||||
|
||||
sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - sack");
|
||||
window.setFramerateLimit(60);
|
||||
sf::Event event;
|
||||
sf::Clock deltaClock;
|
||||
sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - sack");
|
||||
window.setFramerateLimit(60);
|
||||
sf::Event event;
|
||||
sf::Clock deltaClock;
|
||||
|
||||
while (window.isOpen()) {
|
||||
while (window.pollEvent(event)) {
|
||||
if (event.type == sf::Event::Closed) window.close();
|
||||
}
|
||||
while (window.isOpen()) {
|
||||
while (window.pollEvent(event)) {
|
||||
if (event.type == sf::Event::Closed) window.close();
|
||||
}
|
||||
|
||||
float delta = deltaClock.getElapsedTime().asSeconds();
|
||||
deltaClock.restart();
|
||||
float delta = deltaClock.getElapsedTime().asSeconds();
|
||||
deltaClock.restart();
|
||||
|
||||
drawable.update(delta);
|
||||
drawable.update(delta);
|
||||
|
||||
window.clear();
|
||||
window.draw(drawable);
|
||||
window.display();
|
||||
}
|
||||
window.clear();
|
||||
window.draw(drawable);
|
||||
window.display();
|
||||
}
|
||||
}
|
||||
|
||||
void snowglobe(SkeletonData *skeletonData, Atlas *atlas) {
|
||||
SP_UNUSED(atlas);
|
||||
SP_UNUSED(atlas);
|
||||
|
||||
SkeletonDrawable drawable(skeletonData);
|
||||
drawable.timeScale = 1;
|
||||
drawable.setUsePremultipliedAlpha(true);
|
||||
SkeletonDrawable drawable(skeletonData);
|
||||
drawable.timeScale = 1;
|
||||
drawable.setUsePremultipliedAlpha(true);
|
||||
|
||||
Skeleton *skeleton = drawable.skeleton;
|
||||
skeleton->setPosition(320, 480);
|
||||
skeleton->updateWorldTransform(Physics_Update);
|
||||
Skeleton *skeleton = drawable.skeleton;
|
||||
skeleton->setPosition(320, 480);
|
||||
skeleton->updateWorldTransform(Physics_Update);
|
||||
|
||||
drawable.state->setAnimation(0, "shake", true);
|
||||
drawable.state->setAnimation(0, "shake", true);
|
||||
|
||||
sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - snowglobe");
|
||||
window.setFramerateLimit(60);
|
||||
sf::Event event;
|
||||
sf::Clock deltaClock;
|
||||
sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - snowglobe");
|
||||
window.setFramerateLimit(60);
|
||||
sf::Event event;
|
||||
sf::Clock deltaClock;
|
||||
|
||||
while (window.isOpen()) {
|
||||
while (window.pollEvent(event)) {
|
||||
if (event.type == sf::Event::Closed) window.close();
|
||||
}
|
||||
while (window.isOpen()) {
|
||||
while (window.pollEvent(event)) {
|
||||
if (event.type == sf::Event::Closed) window.close();
|
||||
}
|
||||
|
||||
float delta = deltaClock.getElapsedTime().asSeconds();
|
||||
deltaClock.restart();
|
||||
float delta = deltaClock.getElapsedTime().asSeconds();
|
||||
deltaClock.restart();
|
||||
|
||||
drawable.update(delta);
|
||||
drawable.update(delta);
|
||||
|
||||
window.clear();
|
||||
window.draw(drawable);
|
||||
window.display();
|
||||
}
|
||||
window.clear();
|
||||
window.draw(drawable);
|
||||
window.display();
|
||||
}
|
||||
}
|
||||
|
||||
void cloudpot(SkeletonData *skeletonData, Atlas *atlas) {
|
||||
SP_UNUSED(atlas);
|
||||
SP_UNUSED(atlas);
|
||||
|
||||
SkeletonDrawable drawable(skeletonData);
|
||||
drawable.timeScale = 1;
|
||||
drawable.setUsePremultipliedAlpha(true);
|
||||
SkeletonDrawable drawable(skeletonData);
|
||||
drawable.timeScale = 1;
|
||||
drawable.setUsePremultipliedAlpha(true);
|
||||
|
||||
Skeleton *skeleton = drawable.skeleton;
|
||||
skeleton->setPosition(320, 480);
|
||||
skeleton->updateWorldTransform(Physics_Update);
|
||||
Skeleton *skeleton = drawable.skeleton;
|
||||
skeleton->setPosition(320, 480);
|
||||
skeleton->updateWorldTransform(Physics_Update);
|
||||
|
||||
drawable.state->setAnimation(0, "playing-in-the-rain", true);
|
||||
drawable.state->setAnimation(0, "playing-in-the-rain", true);
|
||||
|
||||
sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - cloudpot");
|
||||
window.setFramerateLimit(60);
|
||||
sf::Event event;
|
||||
sf::Clock deltaClock;
|
||||
sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - cloudpot");
|
||||
window.setFramerateLimit(60);
|
||||
sf::Event event;
|
||||
sf::Clock deltaClock;
|
||||
|
||||
while (window.isOpen()) {
|
||||
while (window.pollEvent(event)) {
|
||||
if (event.type == sf::Event::Closed) window.close();
|
||||
}
|
||||
while (window.isOpen()) {
|
||||
while (window.pollEvent(event)) {
|
||||
if (event.type == sf::Event::Closed) window.close();
|
||||
}
|
||||
|
||||
float delta = deltaClock.getElapsedTime().asSeconds();
|
||||
deltaClock.restart();
|
||||
float delta = deltaClock.getElapsedTime().asSeconds();
|
||||
deltaClock.restart();
|
||||
|
||||
drawable.update(delta);
|
||||
drawable.update(delta);
|
||||
|
||||
window.clear();
|
||||
window.draw(drawable);
|
||||
window.display();
|
||||
}
|
||||
window.clear();
|
||||
window.draw(drawable);
|
||||
window.display();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -772,12 +772,12 @@ DebugExtension dbgExtension(SpineExtension::getInstance());
|
||||
int main() {
|
||||
SpineExtension::setInstance(&dbgExtension);
|
||||
|
||||
testcase(cloudpot, "data/cloud-pot.json", "data/cloud-pot.skel", "data/cloud-pot-pma.atlas", 0.2);
|
||||
testcase(sack, "data/sack-pro.json", "data/sack-pro.skel", "data/sack-pma.atlas", 0.2f);
|
||||
testcase(celestialCircus, "data/celestial-circus-pro.json", "data/celestial-circus-pro.skel", "data/celestial-circus-pma.atlas", 0.2f);
|
||||
testcase(snowglobe, "data/snowglobe-pro.json", "data/snowglobe-pro.skel", "data/snowglobe-pma.atlas", 0.2f);
|
||||
testcase(spineboy, "data/spineboy-pro.json", "data/spineboy-pro.skel", "data/spineboy-pma.atlas", 0.62f);
|
||||
testcase(ikDemo, "data/spineboy-pro.json", "data/spineboy-pro.skel", "data/spineboy-pma.atlas", 0.6f);
|
||||
testcase(cloudpot, "data/cloud-pot.json", "data/cloud-pot.skel", "data/cloud-pot-pma.atlas", 0.2);
|
||||
testcase(sack, "data/sack-pro.json", "data/sack-pro.skel", "data/sack-pma.atlas", 0.2f);
|
||||
testcase(celestialCircus, "data/celestial-circus-pro.json", "data/celestial-circus-pro.skel", "data/celestial-circus-pma.atlas", 0.2f);
|
||||
testcase(snowglobe, "data/snowglobe-pro.json", "data/snowglobe-pro.skel", "data/snowglobe-pma.atlas", 0.2f);
|
||||
testcase(spineboy, "data/spineboy-pro.json", "data/spineboy-pro.skel", "data/spineboy-pma.atlas", 0.62f);
|
||||
testcase(ikDemo, "data/spineboy-pro.json", "data/spineboy-pro.skel", "data/spineboy-pma.atlas", 0.6f);
|
||||
testcase(vine, "data/vine-pro.json", "data/vine-pro.skel", "data/vine-pma.atlas", 0.5f);
|
||||
testcase(dragon, "data/dragon-ess.json", "data/dragon-ess.skel", "data/dragon-pma.atlas", 0.6f);
|
||||
testcase(owl, "data/owl-pro.json", "data/owl-pro.skel", "data/owl-pma.atlas", 0.5f);
|
||||
|
||||
@ -50,7 +50,7 @@ namespace spine {
|
||||
SkeletonDrawable::SkeletonDrawable(SkeletonData *skeletonData, AnimationStateData *stateData) : timeScale(1),
|
||||
vertexArray(new VertexArray(Triangles, skeletonData->getBones().size() * 4)),
|
||||
worldVertices(), clipper(), usePremultipliedAlpha(false) {
|
||||
Bone::setYDown(true);
|
||||
Bone::setYDown(true);
|
||||
worldVertices.ensureCapacity(SPINE_MESH_VERTEX_COUNT_MAX);
|
||||
skeleton = new (__FILE__, __LINE__) Skeleton(skeletonData);
|
||||
tempUvs.ensureCapacity(16);
|
||||
@ -79,7 +79,7 @@ namespace spine {
|
||||
void SkeletonDrawable::update(float deltaTime, Physics physics) {
|
||||
state->update(deltaTime * timeScale);
|
||||
state->apply(*skeleton);
|
||||
skeleton->update(deltaTime * timeScale);
|
||||
skeleton->update(deltaTime * timeScale);
|
||||
skeleton->updateWorldTransform(physics);
|
||||
}
|
||||
|
||||
|
||||
@ -6,26 +6,26 @@
|
||||
|
||||
// Sets default values for this component's properties
|
||||
UMySceneComponent::UMySceneComponent(
|
||||
const FObjectInitializer &ObjectInitializer)
|
||||
: USpineSkeletonRendererComponent(ObjectInitializer) {
|
||||
// Set this component to be initialized when the game starts, and to be ticked
|
||||
// every frame. You can turn these features off to improve performance if you
|
||||
// don't need them.
|
||||
PrimaryComponentTick.bCanEverTick = true;
|
||||
const FObjectInitializer &ObjectInitializer)
|
||||
: USpineSkeletonRendererComponent(ObjectInitializer) {
|
||||
// Set this component to be initialized when the game starts, and to be ticked
|
||||
// every frame. You can turn these features off to improve performance if you
|
||||
// don't need them.
|
||||
PrimaryComponentTick.bCanEverTick = true;
|
||||
}
|
||||
|
||||
// Called when the game starts
|
||||
void UMySceneComponent::BeginPlay() {
|
||||
Super::BeginPlay();
|
||||
Super::BeginPlay();
|
||||
|
||||
// ...
|
||||
// ...
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void UMySceneComponent::TickComponent(
|
||||
float DeltaTime, ELevelTick TickType,
|
||||
FActorComponentTickFunction *ThisTickFunction) {
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
float DeltaTime, ELevelTick TickType,
|
||||
FActorComponentTickFunction *ThisTickFunction) {
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
|
||||
// ...
|
||||
// ...
|
||||
}
|
||||
|
||||
@ -9,19 +9,19 @@
|
||||
|
||||
UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
|
||||
class SPINEUE_API UMySceneComponent : public USpineSkeletonRendererComponent {
|
||||
GENERATED_BODY()
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this component's properties
|
||||
UMySceneComponent(const FObjectInitializer &ObjectInitializer);
|
||||
// Sets default values for this component's properties
|
||||
UMySceneComponent(const FObjectInitializer &ObjectInitializer);
|
||||
|
||||
protected:
|
||||
// Called when the game starts
|
||||
virtual void BeginPlay() override;
|
||||
// Called when the game starts
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void
|
||||
TickComponent(float DeltaTime, ELevelTick TickType,
|
||||
FActorComponentTickFunction *ThisTickFunction) override;
|
||||
// Called every frame
|
||||
virtual void
|
||||
TickComponent(float DeltaTime, ELevelTick TickType,
|
||||
FActorComponentTickFunction *ThisTickFunction) override;
|
||||
};
|
||||
|
||||
@ -2,4 +2,3 @@
|
||||
|
||||
#include "SpineUEGameMode.h"
|
||||
#include "SpineUE.h"
|
||||
|
||||
|
||||
@ -10,5 +10,5 @@
|
||||
*/
|
||||
UCLASS()
|
||||
class SPINEUE_API ASpineUEGameMode : public AGameMode {
|
||||
GENERATED_BODY()
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
@ -6,35 +6,35 @@
|
||||
|
||||
// Sets default values
|
||||
ASpineboyCppPawn::ASpineboyCppPawn() {
|
||||
// Set this pawn to call Tick() every frame. You can turn this off to improve
|
||||
// performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
// Set this pawn to call Tick() every frame. You can turn this off to improve
|
||||
// performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void ASpineboyCppPawn::BeginPlay() {
|
||||
Super::BeginPlay();
|
||||
USpineSkeletonAnimationComponent *animationComponent =
|
||||
FindComponentByClass<USpineSkeletonAnimationComponent>();
|
||||
animationComponent->SetAnimation(0, FString("walk"), true);
|
||||
Super::BeginPlay();
|
||||
USpineSkeletonAnimationComponent *animationComponent =
|
||||
FindComponentByClass<USpineSkeletonAnimationComponent>();
|
||||
animationComponent->SetAnimation(0, FString("walk"), true);
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void ASpineboyCppPawn::Tick(float DeltaTime) {
|
||||
Super::Tick(DeltaTime);
|
||||
USpineSkeletonAnimationComponent *animationComponent =
|
||||
FindComponentByClass<USpineSkeletonAnimationComponent>();
|
||||
spine::AnimationState *state = animationComponent->GetAnimationState();
|
||||
spine::TrackEntry *entry = state->getCurrent(0);
|
||||
if (entry) {
|
||||
GEngine->AddOnScreenDebugMessage(
|
||||
-1, 0.5f, FColor::Yellow,
|
||||
FString(entry->getAnimation()->getName().buffer()));
|
||||
}
|
||||
Super::Tick(DeltaTime);
|
||||
USpineSkeletonAnimationComponent *animationComponent =
|
||||
FindComponentByClass<USpineSkeletonAnimationComponent>();
|
||||
spine::AnimationState *state = animationComponent->GetAnimationState();
|
||||
spine::TrackEntry *entry = state->getCurrent(0);
|
||||
if (entry) {
|
||||
GEngine->AddOnScreenDebugMessage(
|
||||
-1, 0.5f, FColor::Yellow,
|
||||
FString(entry->getAnimation()->getName().buffer()));
|
||||
}
|
||||
}
|
||||
|
||||
// Called to bind functionality to input
|
||||
void ASpineboyCppPawn::SetupPlayerInputComponent(
|
||||
UInputComponent *PlayerInputComponent) {
|
||||
Super::SetupPlayerInputComponent(PlayerInputComponent);
|
||||
UInputComponent *PlayerInputComponent) {
|
||||
Super::SetupPlayerInputComponent(PlayerInputComponent);
|
||||
}
|
||||
|
||||
@ -8,21 +8,21 @@
|
||||
|
||||
UCLASS()
|
||||
class SPINEUE_API ASpineboyCppPawn : public APawn {
|
||||
GENERATED_BODY()
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this pawn's properties
|
||||
ASpineboyCppPawn();
|
||||
// Sets default values for this pawn's properties
|
||||
ASpineboyCppPawn();
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
// Called to bind functionality to input
|
||||
virtual void SetupPlayerInputComponent(
|
||||
class UInputComponent *PlayerInputComponent) override;
|
||||
// Called to bind functionality to input
|
||||
virtual void SetupPlayerInputComponent(
|
||||
class UInputComponent *PlayerInputComponent) override;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user