mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
wip
This commit is contained in:
parent
35d84fff30
commit
d173aa7e7d
52
spine-cpp/spine-cpp/include/spine/Attachment.h
Normal file
52
spine-cpp/spine-cpp/include/spine/Attachment.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Spine Runtimes Software License v2.5
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2016, Esoteric Software
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* You are granted a perpetual, non-exclusive, non-sublicensable, and
|
||||||
|
* non-transferable license to use, install, execute, and perform the Spine
|
||||||
|
* Runtimes software and derivative works solely for personal or internal
|
||||||
|
* use. Without the written permission of Esoteric Software (see Section 2 of
|
||||||
|
* the Spine Software License Agreement), you may not (a) modify, translate,
|
||||||
|
* adapt, or develop new applications using the Spine Runtimes or otherwise
|
||||||
|
* create derivative works or improvements of the Spine Runtimes or (b) remove,
|
||||||
|
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
|
||||||
|
* or other intellectual property or proprietary rights notices on or in the
|
||||||
|
* Software, including any copy thereof. Redistributions in binary or source
|
||||||
|
* form must include this license and terms.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef Spine_Attachment_h
|
||||||
|
#define Spine_Attachment_h
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace Spine
|
||||||
|
{
|
||||||
|
class Attachment
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Attachment(std::string name);
|
||||||
|
|
||||||
|
const std::string& getName();
|
||||||
|
|
||||||
|
private:
|
||||||
|
const std::string _name;
|
||||||
|
|
||||||
|
friend std::ostream& operator <<(std::ostream& os, const Attachment& ref);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* Spine_Attachment_h */
|
||||||
395
spine-cpp/spine-cpp/include/spine/Bone.h
Normal file
395
spine-cpp/spine-cpp/include/spine/Bone.h
Normal file
@ -0,0 +1,395 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Spine Runtimes Software License v2.5
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2016, Esoteric Software
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* You are granted a perpetual, non-exclusive, non-sublicensable, and
|
||||||
|
* non-transferable license to use, install, execute, and perform the Spine
|
||||||
|
* Runtimes software and derivative works solely for personal or internal
|
||||||
|
* use. Without the written permission of Esoteric Software (see Section 2 of
|
||||||
|
* the Spine Software License Agreement), you may not (a) modify, translate,
|
||||||
|
* adapt, or develop new applications using the Spine Runtimes or otherwise
|
||||||
|
* create derivative works or improvements of the Spine Runtimes or (b) remove,
|
||||||
|
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
|
||||||
|
* or other intellectual property or proprietary rights notices on or in the
|
||||||
|
* Software, including any copy thereof. Redistributions in binary or source
|
||||||
|
* form must include this license and terms.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef Spine_Bone_h
|
||||||
|
#define Spine_Bone_h
|
||||||
|
|
||||||
|
#include <spine/Updatable.h>
|
||||||
|
|
||||||
|
namespace Spine
|
||||||
|
{
|
||||||
|
/// Stores a bone's current pose.
|
||||||
|
///
|
||||||
|
/// A bone has a local transform which is used to compute its world transform. A bone also has an applied transform, which is a
|
||||||
|
/// local transform that can be applied to compute the world transform. The local transform and applied transform may differ if a
|
||||||
|
/// constraint or application code modifies the world transform after it was computed from the local transform.
|
||||||
|
///
|
||||||
|
class Bone : public Updatable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
private:
|
||||||
|
static public bool yDown;
|
||||||
|
|
||||||
|
internal BoneData data;
|
||||||
|
internal Skeleton skeleton;
|
||||||
|
internal Bone parent;
|
||||||
|
internal ExposedList<Bone> children = new ExposedList<Bone>();
|
||||||
|
internal float x, y, rotation, scaleX, scaleY, shearX, shearY;
|
||||||
|
internal float ax, ay, arotation, ascaleX, ascaleY, ashearX, ashearY;
|
||||||
|
internal bool appliedValid;
|
||||||
|
|
||||||
|
internal float a, b, worldX;
|
||||||
|
internal float c, d, worldY;
|
||||||
|
|
||||||
|
// internal float worldSignX, worldSignY;
|
||||||
|
// public float WorldSignX { get { return worldSignX; } }
|
||||||
|
// public float WorldSignY { get { return worldSignY; } }
|
||||||
|
|
||||||
|
internal bool sorted;
|
||||||
|
|
||||||
|
public BoneData Data { get { return data; } }
|
||||||
|
public Skeleton Skeleton { get { return skeleton; } }
|
||||||
|
public Bone Parent { get { return parent; } }
|
||||||
|
public ExposedList<Bone> Children { get { return children; } }
|
||||||
|
/// <summary>The local X translation.</summary>
|
||||||
|
public float X { get { return x; } set { x = value; } }
|
||||||
|
/// <summary>The local Y translation.</summary>
|
||||||
|
public float Y { get { return y; } set { y = value; } }
|
||||||
|
/// <summary>The local rotation.</summary>
|
||||||
|
public float Rotation { get { return rotation; } set { rotation = value; } }
|
||||||
|
|
||||||
|
/// <summary>The local scaleX.</summary>
|
||||||
|
public float ScaleX { get { return scaleX; } set { scaleX = value; } }
|
||||||
|
|
||||||
|
/// <summary>The local scaleY.</summary>
|
||||||
|
public float ScaleY { get { return scaleY; } set { scaleY = value; } }
|
||||||
|
|
||||||
|
/// <summary>The local shearX.</summary>
|
||||||
|
public float ShearX { get { return shearX; } set { shearX = value; } }
|
||||||
|
|
||||||
|
/// <summary>The local shearY.</summary>
|
||||||
|
public float ShearY { get { return shearY; } set { shearY = value; } }
|
||||||
|
|
||||||
|
/// <summary>The rotation, as calculated by any constraints.</summary>
|
||||||
|
public float AppliedRotation { get { return arotation; } set { arotation = value; } }
|
||||||
|
|
||||||
|
/// <summary>The applied local x translation.</summary>
|
||||||
|
public float AX { get { return ax; } set { ax = value; } }
|
||||||
|
|
||||||
|
/// <summary>The applied local y translation.</summary>
|
||||||
|
public float AY { get { return ay; } set { ay = value; } }
|
||||||
|
|
||||||
|
/// <summary>The applied local scaleX.</summary>
|
||||||
|
public float AScaleX { get { return ascaleX; } set { ascaleX = value; } }
|
||||||
|
|
||||||
|
/// <summary>The applied local scaleY.</summary>
|
||||||
|
public float AScaleY { get { return ascaleY; } set { ascaleY = value; } }
|
||||||
|
|
||||||
|
/// <summary>The applied local shearX.</summary>
|
||||||
|
public float AShearX { get { return ashearX; } set { ashearX = value; } }
|
||||||
|
|
||||||
|
/// <summary>The applied local shearY.</summary>
|
||||||
|
public float AShearY { get { return ashearY; } set { ashearY = value; } }
|
||||||
|
|
||||||
|
public float A { get { return a; } }
|
||||||
|
public float B { get { return b; } }
|
||||||
|
public float C { get { return c; } }
|
||||||
|
public float D { get { return d; } }
|
||||||
|
|
||||||
|
public float WorldX { get { return worldX; } }
|
||||||
|
public float WorldY { get { return worldY; } }
|
||||||
|
public float WorldRotationX { get { return MathUtils.Atan2(c, a) * MathUtils.RadDeg; } }
|
||||||
|
public float WorldRotationY { get { return MathUtils.Atan2(d, b) * MathUtils.RadDeg; } }
|
||||||
|
|
||||||
|
/// <summary>Returns the magnitide (always positive) of the world scale X.</summary>
|
||||||
|
public float WorldScaleX { get { return (float)Math.Sqrt(a * a + c * c); } }
|
||||||
|
/// <summary>Returns the magnitide (always positive) of the world scale Y.</summary>
|
||||||
|
public float WorldScaleY { get { return (float)Math.Sqrt(b * b + d * d); } }
|
||||||
|
|
||||||
|
/// <param name="parent">May be null.</param>
|
||||||
|
public Bone (BoneData data, Skeleton skeleton, Bone parent) {
|
||||||
|
if (data == null) throw new ArgumentNullException("data", "data cannot be null.");
|
||||||
|
if (skeleton == null) throw new ArgumentNullException("skeleton", "skeleton cannot be null.");
|
||||||
|
this.data = data;
|
||||||
|
this.skeleton = skeleton;
|
||||||
|
this.parent = parent;
|
||||||
|
SetToSetupPose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Same as <see cref="UpdateWorldTransform"/>. This method exists for Bone to implement <see cref="Spine.IUpdatable"/>.</summary>
|
||||||
|
public void Update () {
|
||||||
|
UpdateWorldTransform(x, y, rotation, scaleX, scaleY, shearX, shearY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Computes the world transform using the parent bone and this bone's local transform.</summary>
|
||||||
|
public void UpdateWorldTransform () {
|
||||||
|
UpdateWorldTransform(x, y, rotation, scaleX, scaleY, shearX, shearY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Computes the world transform using the parent bone and the specified local transform.</summary>
|
||||||
|
public void UpdateWorldTransform (float x, float y, float rotation, float scaleX, float scaleY, float shearX, float shearY) {
|
||||||
|
ax = x;
|
||||||
|
ay = y;
|
||||||
|
arotation = rotation;
|
||||||
|
ascaleX = scaleX;
|
||||||
|
ascaleY = scaleY;
|
||||||
|
ashearX = shearX;
|
||||||
|
ashearY = shearY;
|
||||||
|
appliedValid = true;
|
||||||
|
Skeleton skeleton = this.skeleton;
|
||||||
|
|
||||||
|
Bone parent = this.parent;
|
||||||
|
if (parent == null) { // Root bone.
|
||||||
|
float rotationY = rotation + 90 + shearY;
|
||||||
|
float la = MathUtils.CosDeg(rotation + shearX) * scaleX;
|
||||||
|
float lb = MathUtils.CosDeg(rotationY) * scaleY;
|
||||||
|
float lc = MathUtils.SinDeg(rotation + shearX) * scaleX;
|
||||||
|
float ld = MathUtils.SinDeg(rotationY) * scaleY;
|
||||||
|
if (skeleton.flipX) {
|
||||||
|
x = -x;
|
||||||
|
la = -la;
|
||||||
|
lb = -lb;
|
||||||
|
}
|
||||||
|
if (skeleton.flipY != yDown) {
|
||||||
|
y = -y;
|
||||||
|
lc = -lc;
|
||||||
|
ld = -ld;
|
||||||
|
}
|
||||||
|
a = la;
|
||||||
|
b = lb;
|
||||||
|
c = lc;
|
||||||
|
d = ld;
|
||||||
|
worldX = x + skeleton.x;
|
||||||
|
worldY = y + skeleton.y;
|
||||||
|
// worldSignX = Math.Sign(scaleX);
|
||||||
|
// worldSignY = Math.Sign(scaleY);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
|
||||||
|
worldX = pa * x + pb * y + parent.worldX;
|
||||||
|
worldY = pc * x + pd * y + parent.worldY;
|
||||||
|
// worldSignX = parent.worldSignX * Math.Sign(scaleX);
|
||||||
|
// worldSignY = parent.worldSignY * Math.Sign(scaleY);
|
||||||
|
|
||||||
|
switch (data.transformMode) {
|
||||||
|
case TransformMode.Normal: {
|
||||||
|
float rotationY = rotation + 90 + shearY;
|
||||||
|
float la = MathUtils.CosDeg(rotation + shearX) * scaleX;
|
||||||
|
float lb = MathUtils.CosDeg(rotationY) * scaleY;
|
||||||
|
float lc = MathUtils.SinDeg(rotation + shearX) * scaleX;
|
||||||
|
float ld = MathUtils.SinDeg(rotationY) * scaleY;
|
||||||
|
a = pa * la + pb * lc;
|
||||||
|
b = pa * lb + pb * ld;
|
||||||
|
c = pc * la + pd * lc;
|
||||||
|
d = pc * lb + pd * ld;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case TransformMode.OnlyTranslation: {
|
||||||
|
float rotationY = rotation + 90 + shearY;
|
||||||
|
a = MathUtils.CosDeg(rotation + shearX) * scaleX;
|
||||||
|
b = MathUtils.CosDeg(rotationY) * scaleY;
|
||||||
|
c = MathUtils.SinDeg(rotation + shearX) * scaleX;
|
||||||
|
d = MathUtils.SinDeg(rotationY) * scaleY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TransformMode.NoRotationOrReflection: {
|
||||||
|
float s = pa * pa + pc * pc, prx;
|
||||||
|
if (s > 0.0001f) {
|
||||||
|
s = Math.Abs(pa * pd - pb * pc) / s;
|
||||||
|
pb = pc * s;
|
||||||
|
pd = pa * s;
|
||||||
|
prx = MathUtils.Atan2(pc, pa) * MathUtils.RadDeg;
|
||||||
|
} else {
|
||||||
|
pa = 0;
|
||||||
|
pc = 0;
|
||||||
|
prx = 90 - MathUtils.Atan2(pd, pb) * MathUtils.RadDeg;
|
||||||
|
}
|
||||||
|
float rx = rotation + shearX - prx;
|
||||||
|
float ry = rotation + shearY - prx + 90;
|
||||||
|
float la = MathUtils.CosDeg(rx) * scaleX;
|
||||||
|
float lb = MathUtils.CosDeg(ry) * scaleY;
|
||||||
|
float lc = MathUtils.SinDeg(rx) * scaleX;
|
||||||
|
float ld = MathUtils.SinDeg(ry) * scaleY;
|
||||||
|
a = pa * la - pb * lc;
|
||||||
|
b = pa * lb - pb * ld;
|
||||||
|
c = pc * la + pd * lc;
|
||||||
|
d = pc * lb + pd * ld;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TransformMode.NoScale:
|
||||||
|
case TransformMode.NoScaleOrReflection: {
|
||||||
|
float cos = MathUtils.CosDeg(rotation), sin = MathUtils.SinDeg(rotation);
|
||||||
|
float za = pa * cos + pb * sin;
|
||||||
|
float zc = pc * cos + pd * sin;
|
||||||
|
float s = (float)Math.Sqrt(za * za + zc * zc);
|
||||||
|
if (s > 0.00001f) s = 1 / s;
|
||||||
|
za *= s;
|
||||||
|
zc *= s;
|
||||||
|
s = (float)Math.Sqrt(za * za + zc * zc);
|
||||||
|
float r = MathUtils.PI / 2 + MathUtils.Atan2(zc, za);
|
||||||
|
float zb = MathUtils.Cos(r) * s;
|
||||||
|
float zd = MathUtils.Sin(r) * s;
|
||||||
|
float la = MathUtils.CosDeg(shearX) * scaleX;
|
||||||
|
float lb = MathUtils.CosDeg(90 + shearY) * scaleY;
|
||||||
|
float lc = MathUtils.SinDeg(shearX) * scaleX;
|
||||||
|
float ld = MathUtils.SinDeg(90 + shearY) * scaleY;
|
||||||
|
if (data.transformMode != TransformMode.NoScaleOrReflection? pa * pd - pb* pc< 0 : skeleton.flipX != skeleton.flipY) {
|
||||||
|
zb = -zb;
|
||||||
|
zd = -zd;
|
||||||
|
}
|
||||||
|
a = za * la + zb * lc;
|
||||||
|
b = za * lb + zb * ld;
|
||||||
|
c = zc * la + zd * lc;
|
||||||
|
d = zc * lb + zd * ld;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (skeleton.flipX) {
|
||||||
|
a = -a;
|
||||||
|
b = -b;
|
||||||
|
}
|
||||||
|
if (skeleton.flipY != Bone.yDown) {
|
||||||
|
c = -c;
|
||||||
|
d = -d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetToSetupPose () {
|
||||||
|
BoneData data = this.data;
|
||||||
|
x = data.x;
|
||||||
|
y = data.y;
|
||||||
|
rotation = data.rotation;
|
||||||
|
scaleX = data.scaleX;
|
||||||
|
scaleY = data.scaleY;
|
||||||
|
shearX = data.shearX;
|
||||||
|
shearY = data.shearY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Computes the individual applied transform values from the world transform. This can be useful to perform processing using
|
||||||
|
/// the applied transform after the world transform has been modified directly (eg, by a constraint)..
|
||||||
|
///
|
||||||
|
/// Some information is ambiguous in the world transform, such as -1,-1 scale versus 180 rotation.
|
||||||
|
/// </summary>
|
||||||
|
internal void UpdateAppliedTransform () {
|
||||||
|
appliedValid = true;
|
||||||
|
Bone parent = this.parent;
|
||||||
|
if (parent == null) {
|
||||||
|
ax = worldX;
|
||||||
|
ay = worldY;
|
||||||
|
arotation = MathUtils.Atan2(c, a) * MathUtils.RadDeg;
|
||||||
|
ascaleX = (float)Math.Sqrt(a * a + c * c);
|
||||||
|
ascaleY = (float)Math.Sqrt(b * b + d * d);
|
||||||
|
ashearX = 0;
|
||||||
|
ashearY = MathUtils.Atan2(a * b + c * d, a * d - b * c) * MathUtils.RadDeg;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
float pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
|
||||||
|
float pid = 1 / (pa * pd - pb * pc);
|
||||||
|
float dx = worldX - parent.worldX, dy = worldY - parent.worldY;
|
||||||
|
ax = (dx * pd * pid - dy * pb * pid);
|
||||||
|
ay = (dy * pa * pid - dx * pc * pid);
|
||||||
|
float ia = pid * pd;
|
||||||
|
float id = pid * pa;
|
||||||
|
float ib = pid * pb;
|
||||||
|
float ic = pid * pc;
|
||||||
|
float ra = ia * a - ib * c;
|
||||||
|
float rb = ia * b - ib * d;
|
||||||
|
float rc = id * c - ic * a;
|
||||||
|
float rd = id * d - ic * b;
|
||||||
|
ashearX = 0;
|
||||||
|
ascaleX = (float)Math.Sqrt(ra * ra + rc * rc);
|
||||||
|
if (ascaleX > 0.0001f) {
|
||||||
|
float det = ra * rd - rb * rc;
|
||||||
|
ascaleY = det / ascaleX;
|
||||||
|
ashearY = MathUtils.Atan2(ra * rb + rc * rd, det) * MathUtils.RadDeg;
|
||||||
|
arotation = MathUtils.Atan2(rc, ra) * MathUtils.RadDeg;
|
||||||
|
} else {
|
||||||
|
ascaleX = 0;
|
||||||
|
ascaleY = (float)Math.Sqrt(rb * rb + rd * rd);
|
||||||
|
ashearY = 0;
|
||||||
|
arotation = 90 - MathUtils.Atan2(rd, rb) * MathUtils.RadDeg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WorldToLocal (float worldX, float worldY, out float localX, out float localY) {
|
||||||
|
float a = this.a, b = this.b, c = this.c, d = this.d;
|
||||||
|
float invDet = 1 / (a * d - b * c);
|
||||||
|
float x = worldX - this.worldX, y = worldY - this.worldY;
|
||||||
|
localX = (x * d * invDet - y * b * invDet);
|
||||||
|
localY = (y * a * invDet - x * c * invDet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LocalToWorld (float localX, float localY, out float worldX, out float worldY) {
|
||||||
|
worldX = localX * a + localY * b + this.worldX;
|
||||||
|
worldY = localX * c + localY * d + this.worldY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float WorldToLocalRotationX {
|
||||||
|
get {
|
||||||
|
Bone parent = this.parent;
|
||||||
|
if (parent == null) return arotation;
|
||||||
|
float pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d, a = this.a, c = this.c;
|
||||||
|
return MathUtils.Atan2(pa * c - pc * a, pd * a - pb * c) * MathUtils.RadDeg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public float WorldToLocalRotationY {
|
||||||
|
get {
|
||||||
|
Bone parent = this.parent;
|
||||||
|
if (parent == null) return arotation;
|
||||||
|
float pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d, b = this.b, d = this.d;
|
||||||
|
return MathUtils.Atan2(pa * d - pc * b, pd * b - pb * d) * MathUtils.RadDeg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public float WorldToLocalRotation (float worldRotation) {
|
||||||
|
float sin = MathUtils.SinDeg(worldRotation), cos = MathUtils.CosDeg(worldRotation);
|
||||||
|
return MathUtils.Atan2(a * sin - c * cos, d * cos - b * sin) * MathUtils.RadDeg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float LocalToWorldRotation (float localRotation) {
|
||||||
|
float sin = MathUtils.SinDeg(localRotation), cos = MathUtils.CosDeg(localRotation);
|
||||||
|
return MathUtils.Atan2(cos * c + sin * d, cos * a + sin * b) * MathUtils.RadDeg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Rotates the world transform the specified amount and sets isAppliedValid to false.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="degrees">Degrees.</param>
|
||||||
|
public void RotateWorld (float degrees) {
|
||||||
|
float a = this.a, b = this.b, c = this.c, d = this.d;
|
||||||
|
float cos = MathUtils.CosDeg(degrees), sin = MathUtils.SinDeg(degrees);
|
||||||
|
this.a = cos * a - sin * c;
|
||||||
|
this.b = cos * b - sin * d;
|
||||||
|
this.c = sin * a + cos * c;
|
||||||
|
this.d = sin * b + cos * d;
|
||||||
|
appliedValid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
override public string ToString () {
|
||||||
|
return data.name;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* Spine_Bone_h */
|
||||||
129
spine-cpp/spine-cpp/include/spine/Skin.h
Normal file
129
spine-cpp/spine-cpp/include/spine/Skin.h
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Spine Runtimes Software License v2.5
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2016, Esoteric Software
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* You are granted a perpetual, non-exclusive, non-sublicensable, and
|
||||||
|
* non-transferable license to use, install, execute, and perform the Spine
|
||||||
|
* Runtimes software and derivative works solely for personal or internal
|
||||||
|
* use. Without the written permission of Esoteric Software (see Section 2 of
|
||||||
|
* the Spine Software License Agreement), you may not (a) modify, translate,
|
||||||
|
* adapt, or develop new applications using the Spine Runtimes or otherwise
|
||||||
|
* create derivative works or improvements of the Spine Runtimes or (b) remove,
|
||||||
|
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
|
||||||
|
* or other intellectual property or proprietary rights notices on or in the
|
||||||
|
* Software, including any copy thereof. Redistributions in binary or source
|
||||||
|
* form must include this license and terms.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef Spine_Skin_h
|
||||||
|
#define Spine_Skin_h
|
||||||
|
|
||||||
|
namespace Spine
|
||||||
|
{
|
||||||
|
/// Stores attachments by slot index and attachment name.
|
||||||
|
/// See SkeletonData::getDefaultSkin, Skeleton::getSkin, and
|
||||||
|
/// http://esotericsoftware.com/spine-runtime-skins in the Spine Runtimes Guide.
|
||||||
|
class Skin
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
public std::string Name { get { return name; } }
|
||||||
|
public Dictionary<AttachmentKeyTuple, Attachment> Attachments { get { return attachments; } }
|
||||||
|
|
||||||
|
public Skin (std::string name) {
|
||||||
|
if (name == null) throw new ArgumentNullException("name", "name cannot be null.");
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Adds an attachment to the skin for the specified slot index and name. If the name already exists for the slot, the previous value is replaced.
|
||||||
|
public void AddAttachment (int slotIndex, std::string name, Attachment attachment) {
|
||||||
|
if (attachment == null) throw new ArgumentNullException("attachment", "attachment cannot be null.");
|
||||||
|
attachments[new AttachmentKeyTuple(slotIndex, name)] = attachment;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the attachment for the specified slot index and name, or null.
|
||||||
|
/// <returns>May be null.</returns>
|
||||||
|
public Attachment GetAttachment (int slotIndex, std::string name) {
|
||||||
|
Attachment attachment;
|
||||||
|
attachments.TryGetValue(new AttachmentKeyTuple(slotIndex, name), out attachment);
|
||||||
|
return attachment;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Finds the skin keys for a given slot. The results are added to the passed List(names).
|
||||||
|
/// <param name="slotIndex">The target slotIndex. To find the slot index, use <see cref="Spine.Skeleton.FindSlotIndex"/> or <see cref="Spine.SkeletonData.FindSlotIndex"/>
|
||||||
|
/// <param name="names">Found skin key names will be added to this list.</param>
|
||||||
|
public void FindNamesForSlot (int slotIndex, List<std::string> names) {
|
||||||
|
if (names == null) throw new ArgumentNullException("names", "names cannot be null.");
|
||||||
|
foreach (AttachmentKeyTuple key in attachments.Keys)
|
||||||
|
if (key.slotIndex == slotIndex) names.Add(key.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Finds the attachments for a given slot. The results are added to the passed List(Attachment).
|
||||||
|
/// <param name="slotIndex">The target slotIndex. To find the slot index, use <see cref="Spine.Skeleton.FindSlotIndex"/> or <see cref="Spine.SkeletonData.FindSlotIndex"/>
|
||||||
|
/// <param name="attachments">Found Attachments will be added to this list.</param>
|
||||||
|
public void FindAttachmentsForSlot (int slotIndex, List<Attachment> attachments) {
|
||||||
|
if (attachments == null) throw new ArgumentNullException("attachments", "attachments cannot be null.");
|
||||||
|
foreach (KeyValuePair<AttachmentKeyTuple, Attachment> entry in this.attachments)
|
||||||
|
if (entry.Key.slotIndex == slotIndex) attachments.Add(entry.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
override public std::string ToString () {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
internal std::string name;
|
||||||
|
Dictionary<AttachmentKeyTuple, Attachment> attachments = new Dictionary<AttachmentKeyTuple, Attachment>(AttachmentKeyTupleComparer.Instance);
|
||||||
|
|
||||||
|
/// Attach all attachments from this skin if the corresponding attachment from the old skin is currently attached.
|
||||||
|
internal void AttachAll (Skeleton skeleton, Skin oldSkin) {
|
||||||
|
foreach (KeyValuePair<AttachmentKeyTuple, Attachment> entry in oldSkin.attachments) {
|
||||||
|
int slotIndex = entry.Key.slotIndex;
|
||||||
|
Slot slot = skeleton.slots.Items[slotIndex];
|
||||||
|
if (slot.Attachment == entry.Value) {
|
||||||
|
Attachment attachment = GetAttachment(slotIndex, entry.Key.name);
|
||||||
|
if (attachment != null) slot.Attachment = attachment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct AttachmentKeyTuple {
|
||||||
|
public readonly int slotIndex;
|
||||||
|
public readonly std::string name;
|
||||||
|
internal readonly int nameHashCode;
|
||||||
|
|
||||||
|
public AttachmentKeyTuple (int slotIndex, std::string name) {
|
||||||
|
this.slotIndex = slotIndex;
|
||||||
|
this.name = name;
|
||||||
|
nameHashCode = this.name.GetHashCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Avoids boxing in the dictionary.
|
||||||
|
class AttachmentKeyTupleComparer : IEqualityComparer<AttachmentKeyTuple> {
|
||||||
|
internal static readonly AttachmentKeyTupleComparer Instance = new AttachmentKeyTupleComparer();
|
||||||
|
|
||||||
|
bool IEqualityComparer<AttachmentKeyTuple>.Equals (AttachmentKeyTuple o1, AttachmentKeyTuple o2) {
|
||||||
|
return o1.slotIndex == o2.slotIndex && o1.nameHashCode == o2.nameHashCode && o1.name == o2.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
int IEqualityComparer<AttachmentKeyTuple>.GetHashCode (AttachmentKeyTuple o) {
|
||||||
|
return o.slotIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* Spine_Skin_h */
|
||||||
98
spine-cpp/spine-cpp/include/spine/Slot.h
Normal file
98
spine-cpp/spine-cpp/include/spine/Slot.h
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Spine Runtimes Software License v2.5
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2016, Esoteric Software
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* You are granted a perpetual, non-exclusive, non-sublicensable, and
|
||||||
|
* non-transferable license to use, install, execute, and perform the Spine
|
||||||
|
* Runtimes software and derivative works solely for personal or internal
|
||||||
|
* use. Without the written permission of Esoteric Software (see Section 2 of
|
||||||
|
* the Spine Software License Agreement), you may not (a) modify, translate,
|
||||||
|
* adapt, or develop new applications using the Spine Runtimes or otherwise
|
||||||
|
* create derivative works or improvements of the Spine Runtimes or (b) remove,
|
||||||
|
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
|
||||||
|
* or other intellectual property or proprietary rights notices on or in the
|
||||||
|
* Software, including any copy thereof. Redistributions in binary or source
|
||||||
|
* form must include this license and terms.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef Spine_Slot_h
|
||||||
|
#define Spine_Slot_h
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace Spine
|
||||||
|
{
|
||||||
|
class SlotData;
|
||||||
|
class Bone;
|
||||||
|
class Skeleton;
|
||||||
|
class Attachment;
|
||||||
|
|
||||||
|
class Slot
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Slot(SlotData& data, Bone& bone);
|
||||||
|
|
||||||
|
void setToSetupPose();
|
||||||
|
|
||||||
|
const SlotData& getSlotData();
|
||||||
|
const Bone& getBone();
|
||||||
|
const Skeleton& getSkeleton();
|
||||||
|
|
||||||
|
float getR();
|
||||||
|
void setR(float inValue);
|
||||||
|
float getG();
|
||||||
|
void setG(float inValue);
|
||||||
|
float getB();
|
||||||
|
void setB(float inValue);
|
||||||
|
float getA();
|
||||||
|
void setA(float inValue);
|
||||||
|
|
||||||
|
float getR2();
|
||||||
|
void setR2(float inValue);
|
||||||
|
float getG2();
|
||||||
|
void setG2(float inValue);
|
||||||
|
float getB2();
|
||||||
|
void setB2(float inValue);
|
||||||
|
bool hasSecondColor();
|
||||||
|
void setHasSecondColor(bool inValue);
|
||||||
|
|
||||||
|
/// May be null.
|
||||||
|
Attachment* getAttachment();
|
||||||
|
void setAttachment(Attachment* inValue);
|
||||||
|
|
||||||
|
float getAttachmentTime();
|
||||||
|
void setAttachmentTime(float inValue);
|
||||||
|
|
||||||
|
std::vector<float>& getAttachmentVertices();
|
||||||
|
void setAttachmentVertices(std::vector<float> inValue);
|
||||||
|
|
||||||
|
private:
|
||||||
|
const SlotData& _slotData;
|
||||||
|
const Bone& _bone;
|
||||||
|
const Skeleton& _skeleton;
|
||||||
|
float _r, _g, _b, _a;
|
||||||
|
float _r2, _g2, _b2;
|
||||||
|
bool _hasSecondColor;
|
||||||
|
Attachment* _attachment;
|
||||||
|
float _attachmentTime;
|
||||||
|
std::vector<float> _attachmentVertices;
|
||||||
|
|
||||||
|
friend std::ostream& operator <<(std::ostream& os, const Slot& ref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* Spine_Slot_h */
|
||||||
78
spine-cpp/spine-cpp/include/spine/TransformConstraintData.h
Normal file
78
spine-cpp/spine-cpp/include/spine/TransformConstraintData.h
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Spine Runtimes Software License v2.5
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2016, Esoteric Software
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* You are granted a perpetual, non-exclusive, non-sublicensable, and
|
||||||
|
* non-transferable license to use, install, execute, and perform the Spine
|
||||||
|
* Runtimes software and derivative works solely for personal or internal
|
||||||
|
* use. Without the written permission of Esoteric Software (see Section 2 of
|
||||||
|
* the Spine Software License Agreement), you may not (a) modify, translate,
|
||||||
|
* adapt, or develop new applications using the Spine Runtimes or otherwise
|
||||||
|
* create derivative works or improvements of the Spine Runtimes or (b) remove,
|
||||||
|
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
|
||||||
|
* or other intellectual property or proprietary rights notices on or in the
|
||||||
|
* Software, including any copy thereof. Redistributions in binary or source
|
||||||
|
* form must include this license and terms.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef Spine_TransformConstraintData_h
|
||||||
|
#define Spine_TransformConstraintData_h
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace Spine
|
||||||
|
{
|
||||||
|
class BoneData;
|
||||||
|
|
||||||
|
class TransformConstraintData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TransformConstraintData(std::string name);
|
||||||
|
|
||||||
|
const std::string& getName();
|
||||||
|
int getOrder();
|
||||||
|
std::vector<BoneData*>& getBones();
|
||||||
|
BoneData* getTarget();
|
||||||
|
float getRotateMix();
|
||||||
|
float getTranslateMix();
|
||||||
|
float getScaleMix();
|
||||||
|
float getShearMix();
|
||||||
|
|
||||||
|
float getOffsetRotation();
|
||||||
|
float getOffsetX();
|
||||||
|
float getOffsetY();
|
||||||
|
float getOffsetScaleX();
|
||||||
|
float getOffsetScaleY();
|
||||||
|
float getOffsetShearY();
|
||||||
|
|
||||||
|
bool isRelative();
|
||||||
|
bool isLocal();
|
||||||
|
|
||||||
|
private:
|
||||||
|
const std::string _name;
|
||||||
|
int _order;
|
||||||
|
std::vector<BoneData*> _bones;
|
||||||
|
BoneData* _target;
|
||||||
|
float _rotateMix, _translateMix, _scaleMix, _shearMix;
|
||||||
|
float _offsetRotation, _offsetX, _offsetY, _offsetScaleX, _offsetScaleY, _offsetShearY;
|
||||||
|
bool _relative, _local;
|
||||||
|
|
||||||
|
friend std::ostream& operator <<(std::ostream& os, const TransformConstraintData& ref);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* Spine_TransformConstraintData_h */
|
||||||
53
spine-cpp/spine-cpp/src/spine/Attachment.cpp
Normal file
53
spine-cpp/spine-cpp/src/spine/Attachment.cpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Spine Runtimes Software License v2.5
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2016, Esoteric Software
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* You are granted a perpetual, non-exclusive, non-sublicensable, and
|
||||||
|
* non-transferable license to use, install, execute, and perform the Spine
|
||||||
|
* Runtimes software and derivative works solely for personal or internal
|
||||||
|
* use. Without the written permission of Esoteric Software (see Section 2 of
|
||||||
|
* the Spine Software License Agreement), you may not (a) modify, translate,
|
||||||
|
* adapt, or develop new applications using the Spine Runtimes or otherwise
|
||||||
|
* create derivative works or improvements of the Spine Runtimes or (b) remove,
|
||||||
|
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
|
||||||
|
* or other intellectual property or proprietary rights notices on or in the
|
||||||
|
* Software, including any copy thereof. Redistributions in binary or source
|
||||||
|
* form must include this license and terms.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <spine/Attachment.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
namespace Spine
|
||||||
|
{
|
||||||
|
Attachment::Attachment(std::string name) : _name(name)
|
||||||
|
{
|
||||||
|
assert(_name.length() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& Attachment::getName()
|
||||||
|
{
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& operator <<(std::ostream& os, const Attachment& ref)
|
||||||
|
{
|
||||||
|
os << ref._name;
|
||||||
|
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
}
|
||||||
34
spine-cpp/spine-cpp/src/spine/Bone.cpp
Normal file
34
spine-cpp/spine-cpp/src/spine/Bone.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Spine Runtimes Software License v2.5
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2016, Esoteric Software
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* You are granted a perpetual, non-exclusive, non-sublicensable, and
|
||||||
|
* non-transferable license to use, install, execute, and perform the Spine
|
||||||
|
* Runtimes software and derivative works solely for personal or internal
|
||||||
|
* use. Without the written permission of Esoteric Software (see Section 2 of
|
||||||
|
* the Spine Software License Agreement), you may not (a) modify, translate,
|
||||||
|
* adapt, or develop new applications using the Spine Runtimes or otherwise
|
||||||
|
* create derivative works or improvements of the Spine Runtimes or (b) remove,
|
||||||
|
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
|
||||||
|
* or other intellectual property or proprietary rights notices on or in the
|
||||||
|
* Software, including any copy thereof. Redistributions in binary or source
|
||||||
|
* form must include this license and terms.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
namespace Spine
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
34
spine-cpp/spine-cpp/src/spine/Skin.cpp
Normal file
34
spine-cpp/spine-cpp/src/spine/Skin.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Spine Runtimes Software License v2.5
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2016, Esoteric Software
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* You are granted a perpetual, non-exclusive, non-sublicensable, and
|
||||||
|
* non-transferable license to use, install, execute, and perform the Spine
|
||||||
|
* Runtimes software and derivative works solely for personal or internal
|
||||||
|
* use. Without the written permission of Esoteric Software (see Section 2 of
|
||||||
|
* the Spine Software License Agreement), you may not (a) modify, translate,
|
||||||
|
* adapt, or develop new applications using the Spine Runtimes or otherwise
|
||||||
|
* create derivative works or improvements of the Spine Runtimes or (b) remove,
|
||||||
|
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
|
||||||
|
* or other intellectual property or proprietary rights notices on or in the
|
||||||
|
* Software, including any copy thereof. Redistributions in binary or source
|
||||||
|
* form must include this license and terms.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
namespace Spine
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
215
spine-cpp/spine-cpp/src/spine/Slot.cpp
Normal file
215
spine-cpp/spine-cpp/src/spine/Slot.cpp
Normal file
@ -0,0 +1,215 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Spine Runtimes Software License v2.5
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2016, Esoteric Software
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* You are granted a perpetual, non-exclusive, non-sublicensable, and
|
||||||
|
* non-transferable license to use, install, execute, and perform the Spine
|
||||||
|
* Runtimes software and derivative works solely for personal or internal
|
||||||
|
* use. Without the written permission of Esoteric Software (see Section 2 of
|
||||||
|
* the Spine Software License Agreement), you may not (a) modify, translate,
|
||||||
|
* adapt, or develop new applications using the Spine Runtimes or otherwise
|
||||||
|
* create derivative works or improvements of the Spine Runtimes or (b) remove,
|
||||||
|
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
|
||||||
|
* or other intellectual property or proprietary rights notices on or in the
|
||||||
|
* Software, including any copy thereof. Redistributions in binary or source
|
||||||
|
* form must include this license and terms.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <spine/Slot.h>
|
||||||
|
|
||||||
|
#include <spine/SlotData.h>
|
||||||
|
#include <spine/Bone.h>
|
||||||
|
#include <spine/Skeleton.h>
|
||||||
|
#include <spine/Attachment.h>
|
||||||
|
|
||||||
|
namespace Spine
|
||||||
|
{
|
||||||
|
Slot::Slot(SlotData& data, Bone& bone) :
|
||||||
|
_slotData(data),
|
||||||
|
_bone(bone),
|
||||||
|
_skeleton(bone.getSkeletion()),
|
||||||
|
_r(1),
|
||||||
|
_g(1),
|
||||||
|
_b(1),
|
||||||
|
_a(1),
|
||||||
|
_r2(0),
|
||||||
|
_g2(0),
|
||||||
|
_b2(0),
|
||||||
|
_hasSecondColor(false),
|
||||||
|
_attachment(nullptr),
|
||||||
|
_attachmentTime(0)
|
||||||
|
{
|
||||||
|
setToSetupPose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Slot::setToSetupPose()
|
||||||
|
{
|
||||||
|
_r = _slotData.getR();
|
||||||
|
_g = _slotData.getG();
|
||||||
|
_b = _slotData.getB();
|
||||||
|
_a = _slotData.getA();
|
||||||
|
|
||||||
|
std::string attachmentName = _slotData.getAttachmentName();
|
||||||
|
if (attachmentName.length() > 0)
|
||||||
|
{
|
||||||
|
_attachment = nullptr;
|
||||||
|
setAttachment(_skeleton.getAttachment(_slotData.getIndex(), attachmentName));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setAttachment(nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const SlotData& Slot::getSlotData()
|
||||||
|
{
|
||||||
|
return _slotData;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Bone& Slot::getBone()
|
||||||
|
{
|
||||||
|
return _bone;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Skeleton& Slot::getSkeleton()
|
||||||
|
{
|
||||||
|
return _skeleton;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Slot::getR()
|
||||||
|
{
|
||||||
|
return _r;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Slot::setR(float inValue)
|
||||||
|
{
|
||||||
|
_r = inValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Slot::getG()
|
||||||
|
{
|
||||||
|
return _g;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Slot::setG(float inValue)
|
||||||
|
{
|
||||||
|
_g = inValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Slot::getB()
|
||||||
|
{
|
||||||
|
return _b;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Slot::setB(float inValue)
|
||||||
|
{
|
||||||
|
_b = inValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Slot::getA()
|
||||||
|
{
|
||||||
|
return _a;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Slot::setA(float inValue)
|
||||||
|
{
|
||||||
|
_a = inValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Slot::getR2()
|
||||||
|
{
|
||||||
|
return _r2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Slot::setR2(float inValue)
|
||||||
|
{
|
||||||
|
_r2 = inValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Slot::getG2()
|
||||||
|
{
|
||||||
|
return _g2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Slot::setG2(float inValue)
|
||||||
|
{
|
||||||
|
_g2 = inValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Slot::getB2()
|
||||||
|
{
|
||||||
|
return _b2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Slot::setB2(float inValue)
|
||||||
|
{
|
||||||
|
_b2 = inValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Slot::hasSecondColor()
|
||||||
|
{
|
||||||
|
return _hasSecondColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Slot::setHasSecondColor(bool inValue)
|
||||||
|
{
|
||||||
|
_hasSecondColor = inValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Attachment* Slot::getAttachment()
|
||||||
|
{
|
||||||
|
return _attachment;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Slot::setAttachment(Attachment* inValue)
|
||||||
|
{
|
||||||
|
if (_attachment == inValue)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_attachment = inValue;
|
||||||
|
_attachmentTime = _skeleton.getTime();
|
||||||
|
_attachmentVertices.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
float Slot::getAttachmentTime()
|
||||||
|
{
|
||||||
|
return _skeleton.getTime() - _attachmentTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Slot::setAttachmentTime(float inValue)
|
||||||
|
{
|
||||||
|
_attachmentTime = _skeleton.getTime() - inValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<float>& Slot::getAttachmentVertices()
|
||||||
|
{
|
||||||
|
return _attachmentVertices;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Slot::setAttachmentVertices(std::vector<float> inValue)
|
||||||
|
{
|
||||||
|
_attachmentVertices = inValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& operator <<(std::ostream& os, const Slot& ref)
|
||||||
|
{
|
||||||
|
os << ref._slotData.getName();
|
||||||
|
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
}
|
||||||
144
spine-cpp/spine-cpp/src/spine/TransformConstraintData.cpp
Normal file
144
spine-cpp/spine-cpp/src/spine/TransformConstraintData.cpp
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Spine Runtimes Software License v2.5
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2016, Esoteric Software
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* You are granted a perpetual, non-exclusive, non-sublicensable, and
|
||||||
|
* non-transferable license to use, install, execute, and perform the Spine
|
||||||
|
* Runtimes software and derivative works solely for personal or internal
|
||||||
|
* use. Without the written permission of Esoteric Software (see Section 2 of
|
||||||
|
* the Spine Software License Agreement), you may not (a) modify, translate,
|
||||||
|
* adapt, or develop new applications using the Spine Runtimes or otherwise
|
||||||
|
* create derivative works or improvements of the Spine Runtimes or (b) remove,
|
||||||
|
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
|
||||||
|
* or other intellectual property or proprietary rights notices on or in the
|
||||||
|
* Software, including any copy thereof. Redistributions in binary or source
|
||||||
|
* form must include this license and terms.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <spine/TransformConstraintData.h>
|
||||||
|
|
||||||
|
#include <spine/BoneData.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
namespace Spine
|
||||||
|
{
|
||||||
|
TransformConstraintData::TransformConstraintData(std::string name) :
|
||||||
|
_name(name),
|
||||||
|
_order(0),
|
||||||
|
_target(nullptr),
|
||||||
|
_rotateMix(0),
|
||||||
|
_translateMix(0),
|
||||||
|
_scaleMix(0),
|
||||||
|
_shearMix(0),
|
||||||
|
_offsetRotation(0),
|
||||||
|
_offsetX(0),
|
||||||
|
_offsetY(0),
|
||||||
|
_offsetScaleX(0),
|
||||||
|
_offsetScaleY(0),
|
||||||
|
_offsetShearY(0),
|
||||||
|
_relative(false),
|
||||||
|
_local(false)
|
||||||
|
{
|
||||||
|
assert(_name.length() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& TransformConstraintData::getName()
|
||||||
|
{
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TransformConstraintData::getOrder()
|
||||||
|
{
|
||||||
|
return _order;
|
||||||
|
}
|
||||||
|
std::vector<BoneData*>& TransformConstraintData::getBones()
|
||||||
|
{
|
||||||
|
return _bones;
|
||||||
|
}
|
||||||
|
|
||||||
|
BoneData* TransformConstraintData::getTarget()
|
||||||
|
{
|
||||||
|
return _target;
|
||||||
|
}
|
||||||
|
|
||||||
|
float TransformConstraintData::getRotateMix()
|
||||||
|
{
|
||||||
|
return _rotateMix;
|
||||||
|
}
|
||||||
|
|
||||||
|
float TransformConstraintData::getTranslateMix()
|
||||||
|
{
|
||||||
|
return _translateMix;
|
||||||
|
}
|
||||||
|
|
||||||
|
float TransformConstraintData::getScaleMix()
|
||||||
|
{
|
||||||
|
return _scaleMix;
|
||||||
|
}
|
||||||
|
|
||||||
|
float TransformConstraintData::getShearMix()
|
||||||
|
{
|
||||||
|
return _shearMix;
|
||||||
|
}
|
||||||
|
|
||||||
|
float TransformConstraintData::getOffsetRotation()
|
||||||
|
{
|
||||||
|
return _offsetRotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
float TransformConstraintData::getOffsetX()
|
||||||
|
{
|
||||||
|
return _offsetX;
|
||||||
|
}
|
||||||
|
|
||||||
|
float TransformConstraintData::getOffsetY()
|
||||||
|
{
|
||||||
|
return _offsetY;
|
||||||
|
}
|
||||||
|
|
||||||
|
float TransformConstraintData::getOffsetScaleX()
|
||||||
|
{
|
||||||
|
return _offsetScaleX;
|
||||||
|
}
|
||||||
|
|
||||||
|
float TransformConstraintData::getOffsetScaleY()
|
||||||
|
{
|
||||||
|
return _offsetScaleY;
|
||||||
|
}
|
||||||
|
|
||||||
|
float TransformConstraintData::getOffsetShearY()
|
||||||
|
{
|
||||||
|
return _offsetShearY;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TransformConstraintData::isRelative()
|
||||||
|
{
|
||||||
|
return _relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TransformConstraintData::isLocal()
|
||||||
|
{
|
||||||
|
return _local;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& operator <<(std::ostream& os, const TransformConstraintData& ref)
|
||||||
|
{
|
||||||
|
os << ref._name;
|
||||||
|
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user