mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
wip
This commit is contained in:
parent
2a00853fe2
commit
175365a039
@ -35,6 +35,8 @@
|
||||
|
||||
#include <spine/Vector.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
/// Attachment that displays a texture region using a mesh.
|
||||
@ -43,92 +45,88 @@ namespace Spine
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
// int HullLength { get { return _hulllength; } set { _hulllength = value; } }
|
||||
// Vector<float>& RegionUVs { get { return _regionUVs; } set { _regionUVs = value; } }
|
||||
// /// The UV pair for each vertex, normalized within the entire texture. <seealso cref="MeshAttachment.updateUVs"/>
|
||||
// Vector<float>& UVs { get { return _uvs; } set { _uvs = value; } }
|
||||
// Vector<int>& Triangles { get { return _triangles; } set { _triangles = value; } }
|
||||
//
|
||||
// float R { get { return r; } set { r = value; } }
|
||||
// float G { get { return g; } set { g = value; } }
|
||||
// float B { get { return b; } set { b = value; } }
|
||||
// float A { get { return a; } set { a = value; } }
|
||||
//
|
||||
// std::string Path { get; set; }
|
||||
// void* RendererObject; //Object RendererObject { get; set; }
|
||||
// float RegionU { get; set; }
|
||||
// float RegionV { get; set; }
|
||||
// float RegionU2 { get; set; }
|
||||
// float RegionV2 { get; set; }
|
||||
// bool RegionRotate { get; set; }
|
||||
// float RegionOffsetX { get { return _regionOffsetX; } set { _regionOffsetX = value; } }
|
||||
// float RegionOffsetY { get { return _regionOffsetY; } set { _regionOffsetY = value; } } // Pixels stripped from the bottom left, unrotated.
|
||||
// float RegionWidth { get { return _regionWidth; } set { _regionWidth = value; } }
|
||||
// float RegionHeight { get { return _regionHeight; } set { _regionHeight = value; } } // Unrotated, stripped size.
|
||||
// float RegionOriginalWidth { get { return _regionOriginalWidth; } set { _regionOriginalWidth = value; } }
|
||||
// float RegionOriginalHeight { get { return _regionOriginalHeight; } set { _regionOriginalHeight = value; } } // Unrotated, unstripped size.
|
||||
//
|
||||
// bool InheritDeform { get { return _inheritDeform; } set { _inheritDeform = value; } }
|
||||
//
|
||||
// MeshAttachment ParentMesh {
|
||||
// get { return _parentMesh; }
|
||||
// set {
|
||||
// _parentMesh = value;
|
||||
// if (value != null) {
|
||||
// bones = value.bones;
|
||||
// vertices = value.vertices;
|
||||
// worldVerticesLength = value.worldVerticesLength;
|
||||
// _regionUVs = value._regionUVs;
|
||||
// _triangles = value._triangles;
|
||||
// HullLength = value.HullLength;
|
||||
// Edges = value.Edges;
|
||||
// Width = value.Width;
|
||||
// Height = value.Height;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Nonessential.
|
||||
// Vector<int>& Edges { get; set; }
|
||||
// float Width { get; set; }
|
||||
// float Height { get; set; }
|
||||
MeshAttachment(std::string name);
|
||||
|
||||
MeshAttachment(std::string name) : VertexAttachment(name)
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
void updateUVs();
|
||||
|
||||
// void updateUVs()
|
||||
// {
|
||||
// float u = RegionU, v = RegionV, width = RegionU2 - RegionU, height = RegionV2 - RegionV;
|
||||
// if (_uvs == null || _uvs.Length != _regionUVs.Length)
|
||||
// {
|
||||
// _uvs = new float[_regionUVs.Length];
|
||||
// }
|
||||
//
|
||||
// Vector<float> _uvs = _uvs;
|
||||
// if (_regionRotate)
|
||||
// {
|
||||
// for (int i = 0, n = _uvs.Length; i < n; i += 2)
|
||||
// {
|
||||
// _uvs[i] = u + _regionUVs[i + 1] * width;
|
||||
// _uvs[i + 1] = v + height - _regionUVs[i] * height;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// for (int i = 0, n = _uvs.Length; i < n; i += 2)
|
||||
// {
|
||||
// _uvs[i] = u + _regionUVs[i] * width;
|
||||
// _uvs[i + 1] = v + _regionUVs[i + 1] * height;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
virtual bool applyDeform(VertexAttachment* sourceAttachment);
|
||||
|
||||
virtual bool applyDeform(VertexAttachment* sourceAttachment)
|
||||
{
|
||||
return this == sourceAttachment || (_inheritDeform && _parentMesh == sourceAttachment);
|
||||
}
|
||||
int getHullLength();
|
||||
void setHullLength(float inValue);
|
||||
|
||||
Vector<float>& getRegionUVs();
|
||||
void setRegionUVs(Vector<float>& inValue);
|
||||
|
||||
/// The UV pair for each vertex, normalized within the entire texture. See also MeshAttachment::updateUVs
|
||||
Vector<float>& getUVs();
|
||||
void setUVs(Vector<float>& inValue);
|
||||
|
||||
Vector<int>& getTriangles();
|
||||
void setTriangles(Vector<int>& inValue);
|
||||
|
||||
float getR();
|
||||
void setR(float inValue);
|
||||
float getG();
|
||||
void setG(float inValue);
|
||||
float getB();
|
||||
void setB(float inValue);
|
||||
float getA();
|
||||
void setA(float inValue);
|
||||
|
||||
std::string getPath();
|
||||
void setPath(std::string inValue);
|
||||
void* getRendererObject();
|
||||
void setRendererObject(void* inValue);
|
||||
|
||||
float getRegionU();
|
||||
void setRegionU(float inValue);
|
||||
|
||||
float getRegionV();
|
||||
void setRegionV(float inValue);
|
||||
|
||||
float getRegionU2();
|
||||
void setRegionU2(float inValue);
|
||||
|
||||
float getRegionV2();
|
||||
void setRegionV2(float inValue);
|
||||
|
||||
bool getRegionRotate();
|
||||
void setRegionRotate(float inValue);
|
||||
|
||||
float getRegionOffsetX();
|
||||
void setRegionOffsetX(float inValue);
|
||||
|
||||
// Pixels stripped from the bottom left, unrotated.
|
||||
float getRegionOffsetY();
|
||||
void setRegionOffsetY(float inValue);
|
||||
|
||||
float getRegionWidth();
|
||||
void setRegionWidth(float inValue);
|
||||
|
||||
// Unrotated, stripped size.
|
||||
float getRegionHeight();
|
||||
void setRegionHeight(float inValue);
|
||||
|
||||
float getRegionOriginalWidth();
|
||||
void setRegionOriginalWidth(float inValue);
|
||||
|
||||
// Unrotated, unstripped size.
|
||||
float getRegionOriginalHeight();
|
||||
void setRegionOriginalHeight(float inValue);
|
||||
|
||||
bool getInheritDeform();
|
||||
void setInheritDeform(bool inValue);
|
||||
|
||||
MeshAttachment* getParentMesh();
|
||||
void setParentMesh(MeshAttachment* inValue);
|
||||
|
||||
// Nonessential.
|
||||
Vector<int>& getEdges();
|
||||
void setEdges(Vector<int>& inValue);
|
||||
float getWidth();
|
||||
void setWidth(float inValue);
|
||||
float getHeight();
|
||||
void setHeight(float inValue);
|
||||
|
||||
private:
|
||||
float _regionOffsetX, _regionOffsetY, _regionWidth, _regionHeight, _regionOriginalWidth, _regionOriginalHeight;
|
||||
@ -137,8 +135,16 @@ namespace Spine
|
||||
Vector<float> _regionUVs;
|
||||
Vector<int> _triangles;
|
||||
Vector<int> _edges;
|
||||
float _r = 1, _g = 1, _b = 1, _a = 1;
|
||||
int _hulllength;
|
||||
void* _rendererObject;
|
||||
std::string _path;
|
||||
float _regionU;
|
||||
float _regionV;
|
||||
float _regionU2;
|
||||
float _regionV2;
|
||||
float _width;
|
||||
float _height;
|
||||
float _r, _g, _b, _a;
|
||||
int _hullLength;
|
||||
bool _inheritDeform;
|
||||
bool _regionRotate;
|
||||
};
|
||||
|
||||
@ -34,9 +34,8 @@
|
||||
#include <spine/Attachment.h>
|
||||
|
||||
#include <spine/Vector.h>
|
||||
#include <spine/MathUtil.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <string>
|
||||
|
||||
#define NUM_UVS 8
|
||||
|
||||
@ -50,92 +49,12 @@ namespace Spine
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
// float X { get { return x; } set { x = value; } }
|
||||
// float Y { get { return y; } set { y = value; } }
|
||||
// float Rotation { get { return _rotation; } set { _rotation = value; } }
|
||||
// float ScaleX { get { return scaleX; } set { scaleX = value; } }
|
||||
// float ScaleY { get { return scaleY; } set { scaleY = value; } }
|
||||
// float Width { get { return width; } set { width = value; } }
|
||||
// float Height { get { return height; } set { height = value; } }
|
||||
//
|
||||
// float R { get { return r; } set { r = value; } }
|
||||
// float G { get { return g; } set { g = value; } }
|
||||
// float B { get { return b; } set { b = value; } }
|
||||
// float A { get { return a; } set { a = value; } }
|
||||
//
|
||||
// std::string Path { get; set; }
|
||||
// void* RendererObject; //object RendererObject { get; set; }
|
||||
// float RegionOffsetX { get { return _regionOffsetX; } set { _regionOffsetX = value; } }
|
||||
// float RegionOffsetY { get { return _regionOffsetY; } set { _regionOffsetY = value; } } // Pixels stripped from the bottom left, unrotated.
|
||||
// float RegionWidth { get { return _regionWidth; } set { _regionWidth = value; } }
|
||||
// float RegionHeight { get { return _regionHeight; } set { _regionHeight = value; } } // Unrotated, stripped size.
|
||||
// float RegionOriginalWidth { get { return _regionOriginalWidth; } set { _regionOriginalWidth = value; } }
|
||||
// float RegionOriginalHeight { get { return _regionOriginalHeight; } set { _regionOriginalHeight = value; } } // Unrotated, unstripped size.
|
||||
//
|
||||
// Vector<float>& Offset { get { return _offset; } }
|
||||
// Vector<float>& UVs { get { return _uvs; } }
|
||||
//
|
||||
RegionAttachment(std::string name) : Attachment(name)
|
||||
{
|
||||
_offset.reserve(NUM_UVS);
|
||||
_uvs.reserve(NUM_UVS);
|
||||
}
|
||||
//
|
||||
// void updateOffset()
|
||||
// {
|
||||
// float regionScaleX = _width / _regionOriginalWidth * _scaleX;
|
||||
// float regionScaleY = _height / _regionOriginalHeight * _scaleY;
|
||||
// float localX = -_width / 2 * _scaleX + _regionOffsetX * regionScaleX;
|
||||
// float localY = -_height / 2 * _scaleY + _regionOffsetY * regionScaleY;
|
||||
// float localX2 = localX + _regionWidth * regionScaleX;
|
||||
// float localY2 = localY + _regionHeight * regionScaleY;
|
||||
// float cos = MathUtil::cosDeg(_rotation);
|
||||
// float sin = MathUtil::sinDeg(_rotation);
|
||||
// float localXCos = localX * cos + _x;
|
||||
// float localXSin = localX * sin;
|
||||
// float localYCos = localY * cos + _y;
|
||||
// float localYSin = localY * sin;
|
||||
// float localX2Cos = localX2 * cos + _x;
|
||||
// float localX2Sin = localX2 * sin;
|
||||
// float localY2Cos = localY2 * cos + _y;
|
||||
// float localY2Sin = localY2 * sin;
|
||||
//
|
||||
// _offset[BLX] = localXCos - localYSin;
|
||||
// _offset[BLY] = localYCos + localXSin;
|
||||
// _offset[ULX] = localXCos - localY2Sin;
|
||||
// _offset[ULY] = localY2Cos + localXSin;
|
||||
// _offset[URX] = localX2Cos - localY2Sin;
|
||||
// _offset[URY] = localY2Cos + localX2Sin;
|
||||
// _offset[BRX] = localX2Cos - localYSin;
|
||||
// _offset[BRY] = localYCos + localX2Sin;
|
||||
// }
|
||||
//
|
||||
// void setUVs(float u, float v, float u2, float v2, bool rotate)
|
||||
// {
|
||||
// if (rotate)
|
||||
// {
|
||||
// _uvs[URX] = u;
|
||||
// _uvs[URY] = v2;
|
||||
// _uvs[BRX] = u;
|
||||
// _uvs[BRY] = v;
|
||||
// _uvs[BLX] = u2;
|
||||
// _uvs[BLY] = v;
|
||||
// _uvs[ULX] = u2;
|
||||
// _uvs[ULY] = v2;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _uvs[ULX] = u;
|
||||
// _uvs[ULY] = v2;
|
||||
// _uvs[URX] = u;
|
||||
// _uvs[URY] = v;
|
||||
// _uvs[BRX] = u2;
|
||||
// _uvs[BRY] = v;
|
||||
// _uvs[BLX] = u2;
|
||||
// _uvs[BLY] = v2;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
RegionAttachment(std::string name);
|
||||
|
||||
void updateOffset();
|
||||
|
||||
void setUVs(float u, float v, float u2, float v2, bool rotate);
|
||||
|
||||
/// Transforms the attachment's four vertices to world coordinates.
|
||||
/// @param bone The parent bone.
|
||||
/// @param worldVertices The output world vertices. Must have a length greater than or equal to offset + 8.
|
||||
@ -143,6 +62,56 @@ namespace Spine
|
||||
/// @param stride The number of worldVertices entries between the value pairs written.
|
||||
void computeWorldVertices(Bone& bone, Vector<float>& worldVertices, int offset, int stride = 2);
|
||||
|
||||
float getX();
|
||||
void setX(float inValue);
|
||||
float getY();
|
||||
void setY(float inValue);
|
||||
float getRotation();
|
||||
void setRotation(float inValue);
|
||||
float getScaleX();
|
||||
void setScaleX(float inValue);
|
||||
float getScaleY();
|
||||
void setScaleY(float inValue);
|
||||
float getWidth();
|
||||
void setWidth(float inValue);
|
||||
float getHeight();
|
||||
void setHeight(float inValue);
|
||||
|
||||
float getR();
|
||||
void setR(float inValue);
|
||||
float getG();
|
||||
void setG(float inValue);
|
||||
float getB();
|
||||
void setB(float inValue);
|
||||
float getA();
|
||||
void setA(float inValue);
|
||||
|
||||
std::string getPath();
|
||||
void setPath(std::string inValue);
|
||||
void* getRendererObject();
|
||||
void setRendererObject(void* inValue);
|
||||
float getRegionOffsetX();
|
||||
void setRegionOffsetX(float inValue);
|
||||
|
||||
// Pixels stripped from the bottom left, unrotated.
|
||||
float getRegionOffsetY();
|
||||
void setRegionOffsetY(float inValue);
|
||||
float getRegionWidth();
|
||||
void setRegionWidth(float inValue);
|
||||
|
||||
// Unrotated, stripped size.
|
||||
float getRegionHeight();
|
||||
void setRegionHeight(float inValue);
|
||||
float getRegionOriginalWidth();
|
||||
void setRegionOriginalWidth(float inValue);
|
||||
|
||||
// Unrotated, unstripped size.
|
||||
float getRegionOriginalHeight();
|
||||
void setRegionOriginalHeight(float inValue);
|
||||
|
||||
Vector<float>& getOffset();
|
||||
Vector<float>& getUVs();
|
||||
|
||||
private:
|
||||
static const int BLX;
|
||||
static const int BLY;
|
||||
@ -157,7 +126,13 @@ namespace Spine
|
||||
float _regionOffsetX, _regionOffsetY, _regionWidth, _regionHeight, _regionOriginalWidth, _regionOriginalHeight;
|
||||
Vector<float> _offset;
|
||||
Vector<float> _uvs;
|
||||
float r = 1, g = 1, b = 1, a = 1;
|
||||
void* _rendererObject;
|
||||
std::string _path;
|
||||
float _regionU;
|
||||
float _regionV;
|
||||
float _regionU2;
|
||||
float _regionV2;
|
||||
float _r, _g, _b, _a;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -72,12 +72,14 @@ namespace Spine
|
||||
int getWorldVerticesLength();
|
||||
void setWorldVerticesLength(int inValue);
|
||||
|
||||
private:
|
||||
const int _id;
|
||||
protected:
|
||||
Vector<int> _bones;
|
||||
Vector<float> _vertices;
|
||||
int _worldVerticesLength;
|
||||
|
||||
private:
|
||||
const int _id;
|
||||
|
||||
static int getNextID();
|
||||
};
|
||||
}
|
||||
|
||||
@ -34,6 +34,8 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
RTTI_IMPL_NOPARENT(Attachment);
|
||||
|
||||
Attachment::Attachment(std::string name) : _name(name)
|
||||
{
|
||||
assert(_name.length() > 0);
|
||||
@ -43,6 +45,4 @@ namespace Spine
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
RTTI_IMPL_NOPARENT(Attachment);
|
||||
}
|
||||
|
||||
@ -38,6 +38,8 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
RTTI_IMPL(Bone, Updatable);
|
||||
|
||||
bool Bone::yDown = false;
|
||||
|
||||
void Bone::setYDown(bool inValue)
|
||||
@ -621,6 +623,4 @@ namespace Spine
|
||||
_arotation = 90 - MathUtil::atan2(rd, rb) * RadDeg;
|
||||
}
|
||||
}
|
||||
|
||||
RTTI_IMPL(Bone, Updatable);
|
||||
}
|
||||
|
||||
@ -32,6 +32,8 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
RTTI_IMPL(Constraint, Updatable);
|
||||
|
||||
Constraint::Constraint()
|
||||
{
|
||||
// Empty
|
||||
@ -41,6 +43,4 @@ namespace Spine
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
RTTI_IMPL(Constraint, Updatable);
|
||||
}
|
||||
|
||||
@ -34,6 +34,8 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
RTTI_IMPL(CurveTimeline, Timeline);
|
||||
|
||||
const float CurveTimeline::LINEAR = 0;
|
||||
const float CurveTimeline::STEPPED = 1;
|
||||
const float CurveTimeline::BEZIER = 2;
|
||||
@ -133,6 +135,4 @@ namespace Spine
|
||||
{
|
||||
return _curves[frameIndex * BEZIER_SIZE];
|
||||
}
|
||||
|
||||
RTTI_IMPL(CurveTimeline, Timeline);
|
||||
}
|
||||
|
||||
@ -39,6 +39,8 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
RTTI_IMPL(IkConstraint, Constraint);
|
||||
|
||||
void IkConstraint::apply(Bone& bone, float targetX, float targetY, float alpha)
|
||||
{
|
||||
if (!bone._appliedValid)
|
||||
@ -357,6 +359,4 @@ namespace Spine
|
||||
{
|
||||
_mix = inValue;
|
||||
}
|
||||
|
||||
RTTI_IMPL(IkConstraint, Constraint);
|
||||
}
|
||||
|
||||
@ -33,4 +33,335 @@
|
||||
namespace Spine
|
||||
{
|
||||
RTTI_IMPL(MeshAttachment, VertexAttachment);
|
||||
|
||||
MeshAttachment::MeshAttachment(std::string name) : VertexAttachment(name),
|
||||
_regionOffsetX(0),
|
||||
_regionOffsetY(0),
|
||||
_regionWidth(0),
|
||||
_regionHeight(0),
|
||||
_regionOriginalWidth(0),
|
||||
_regionOriginalHeight(0),
|
||||
_parentMesh(NULL),
|
||||
_rendererObject(NULL),
|
||||
_path(),
|
||||
_regionU(0),
|
||||
_regionV(0),
|
||||
_regionU2(0),
|
||||
_regionV2(0),
|
||||
_width(0),
|
||||
_height(0),
|
||||
_r(1),
|
||||
_g(1),
|
||||
_b(1),
|
||||
_a(1),
|
||||
_hullLength(0),
|
||||
_inheritDeform(false),
|
||||
_regionRotate(false)
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
void MeshAttachment::updateUVs()
|
||||
{
|
||||
float u = _regionU, v = _regionV, width = _regionU2 - _regionU, height = _regionV2 - _regionV;
|
||||
if (_uvs.size() != _regionUVs.size())
|
||||
{
|
||||
_uvs.reserve(_regionUVs.size());
|
||||
}
|
||||
|
||||
|
||||
if (_regionRotate)
|
||||
{
|
||||
for (size_t i = 0, n = _uvs.size(); i < n; i += 2)
|
||||
{
|
||||
_uvs[i] = u + _regionUVs[i + 1] * width;
|
||||
_uvs[i + 1] = v + height - _regionUVs[i] * height;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t i = 0, n = _uvs.size(); i < n; i += 2)
|
||||
{
|
||||
_uvs[i] = u + _regionUVs[i] * width;
|
||||
_uvs[i + 1] = v + _regionUVs[i + 1] * height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool MeshAttachment::applyDeform(VertexAttachment* sourceAttachment)
|
||||
{
|
||||
return this == sourceAttachment || (_inheritDeform && _parentMesh == sourceAttachment);
|
||||
}
|
||||
|
||||
int MeshAttachment::getHullLength()
|
||||
{
|
||||
return _hullLength;
|
||||
}
|
||||
|
||||
void MeshAttachment::setHullLength(float inValue)
|
||||
{
|
||||
_hullLength = inValue;
|
||||
}
|
||||
|
||||
Vector<float>& MeshAttachment::getRegionUVs()
|
||||
{
|
||||
return _regionUVs;
|
||||
}
|
||||
|
||||
void MeshAttachment::setRegionUVs(Vector<float>& inValue)
|
||||
{
|
||||
_regionUVs = inValue;
|
||||
}
|
||||
|
||||
Vector<float>& MeshAttachment::getUVs()
|
||||
{
|
||||
return _uvs;
|
||||
}
|
||||
|
||||
void MeshAttachment::setUVs(Vector<float>& inValue)
|
||||
{
|
||||
_uvs = inValue;
|
||||
}
|
||||
|
||||
Vector<int>& MeshAttachment::getTriangles()
|
||||
{
|
||||
return _triangles;
|
||||
}
|
||||
|
||||
void MeshAttachment::setTriangles(Vector<int>& inValue)
|
||||
{
|
||||
_triangles = inValue;
|
||||
}
|
||||
|
||||
float MeshAttachment::getR()
|
||||
{
|
||||
return _r;
|
||||
}
|
||||
|
||||
void MeshAttachment::setR(float inValue)
|
||||
{
|
||||
_r = inValue;
|
||||
}
|
||||
|
||||
float MeshAttachment::getG()
|
||||
{
|
||||
return _g;
|
||||
}
|
||||
|
||||
void MeshAttachment::setG(float inValue)
|
||||
{
|
||||
_g = inValue;
|
||||
}
|
||||
|
||||
float MeshAttachment::getB()
|
||||
{
|
||||
return _b;
|
||||
}
|
||||
|
||||
void MeshAttachment::setB(float inValue)
|
||||
{
|
||||
_b = inValue;
|
||||
}
|
||||
|
||||
float MeshAttachment::getA()
|
||||
{
|
||||
return _a;
|
||||
}
|
||||
|
||||
void MeshAttachment::setA(float inValue)
|
||||
{
|
||||
_a = inValue;
|
||||
}
|
||||
|
||||
std::string MeshAttachment::getPath()
|
||||
{
|
||||
return _path;
|
||||
}
|
||||
|
||||
void MeshAttachment::setPath(std::string inValue)
|
||||
{
|
||||
_path = inValue;
|
||||
}
|
||||
|
||||
void* MeshAttachment::getRendererObject()
|
||||
{
|
||||
return _rendererObject;
|
||||
}
|
||||
|
||||
void MeshAttachment::setRendererObject(void* inValue)
|
||||
{
|
||||
_rendererObject = inValue;
|
||||
}
|
||||
|
||||
float MeshAttachment::getRegionU()
|
||||
{
|
||||
return _regionU;
|
||||
}
|
||||
|
||||
void MeshAttachment::setRegionU(float inValue)
|
||||
{
|
||||
_regionU = inValue;
|
||||
}
|
||||
|
||||
float MeshAttachment::getRegionV()
|
||||
{
|
||||
return _regionV;
|
||||
}
|
||||
|
||||
void MeshAttachment::setRegionV(float inValue)
|
||||
{
|
||||
_regionV = inValue;
|
||||
}
|
||||
|
||||
float MeshAttachment::getRegionU2()
|
||||
{
|
||||
return _regionU2;
|
||||
}
|
||||
|
||||
void MeshAttachment::setRegionU2(float inValue)
|
||||
{
|
||||
_regionU2 = inValue;
|
||||
}
|
||||
|
||||
float MeshAttachment::getRegionV2()
|
||||
{
|
||||
return _regionV2;
|
||||
}
|
||||
|
||||
void MeshAttachment::setRegionV2(float inValue)
|
||||
{
|
||||
_regionV2 = inValue;
|
||||
}
|
||||
|
||||
bool MeshAttachment::getRegionRotate()
|
||||
{
|
||||
return _regionRotate;
|
||||
}
|
||||
|
||||
void MeshAttachment::setRegionRotate(float inValue)
|
||||
{
|
||||
_regionRotate = inValue;
|
||||
}
|
||||
|
||||
float MeshAttachment::getRegionOffsetX()
|
||||
{
|
||||
return _regionOffsetX;
|
||||
}
|
||||
|
||||
void MeshAttachment::setRegionOffsetX(float inValue)
|
||||
{
|
||||
_regionOffsetX = inValue;
|
||||
}
|
||||
|
||||
float MeshAttachment::getRegionOffsetY()
|
||||
{
|
||||
return _regionOffsetY;
|
||||
}
|
||||
|
||||
void MeshAttachment::setRegionOffsetY(float inValue)
|
||||
{
|
||||
_regionOffsetY = inValue;
|
||||
}
|
||||
|
||||
float MeshAttachment::getRegionWidth()
|
||||
{
|
||||
return _regionWidth;
|
||||
}
|
||||
|
||||
void MeshAttachment::setRegionWidth(float inValue)
|
||||
{
|
||||
_regionWidth = inValue;
|
||||
}
|
||||
|
||||
float MeshAttachment::getRegionHeight()
|
||||
{
|
||||
return _regionHeight;
|
||||
}
|
||||
|
||||
void MeshAttachment::setRegionHeight(float inValue)
|
||||
{
|
||||
_regionHeight = inValue;
|
||||
}
|
||||
|
||||
float MeshAttachment::getRegionOriginalWidth()
|
||||
{
|
||||
return _regionOriginalWidth;
|
||||
}
|
||||
|
||||
void MeshAttachment::setRegionOriginalWidth(float inValue)
|
||||
{
|
||||
_regionOriginalWidth = inValue;
|
||||
}
|
||||
|
||||
float MeshAttachment::getRegionOriginalHeight()
|
||||
{
|
||||
return _regionOriginalHeight;
|
||||
}
|
||||
|
||||
void MeshAttachment::setRegionOriginalHeight(float inValue)
|
||||
{
|
||||
_regionOriginalHeight = inValue;
|
||||
}
|
||||
|
||||
bool MeshAttachment::getInheritDeform()
|
||||
{
|
||||
return _inheritDeform;
|
||||
}
|
||||
|
||||
void MeshAttachment::setInheritDeform(bool inValue)
|
||||
{
|
||||
_inheritDeform = inValue;
|
||||
}
|
||||
|
||||
MeshAttachment* MeshAttachment::getParentMesh()
|
||||
{
|
||||
return _parentMesh;
|
||||
}
|
||||
|
||||
void MeshAttachment::setParentMesh(MeshAttachment* inValue)
|
||||
{
|
||||
_parentMesh = inValue;
|
||||
if (inValue != NULL)
|
||||
{
|
||||
_bones = inValue->_bones;
|
||||
_vertices = inValue->_vertices;
|
||||
_worldVerticesLength = inValue->_worldVerticesLength;
|
||||
_regionUVs = inValue->_regionUVs;
|
||||
_triangles = inValue->_triangles;
|
||||
_hullLength = inValue->_hullLength;
|
||||
_edges = inValue->_edges;
|
||||
_width = inValue->_width;
|
||||
_height = inValue->_height;
|
||||
}
|
||||
}
|
||||
|
||||
Vector<int>& MeshAttachment::getEdges()
|
||||
{
|
||||
return _edges;
|
||||
}
|
||||
|
||||
void MeshAttachment::setEdges(Vector<int>& inValue)
|
||||
{
|
||||
_edges = inValue;
|
||||
}
|
||||
|
||||
float MeshAttachment::getWidth()
|
||||
{
|
||||
return _width;
|
||||
}
|
||||
|
||||
void MeshAttachment::setWidth(float inValue)
|
||||
{
|
||||
_width = inValue;
|
||||
}
|
||||
|
||||
float MeshAttachment::getHeight()
|
||||
{
|
||||
return _height;
|
||||
}
|
||||
|
||||
void MeshAttachment::setHeight(float inValue)
|
||||
{
|
||||
_height = inValue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,6 +32,8 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
RTTI_IMPL(PathAttachment, VertexAttachment);
|
||||
|
||||
PathAttachment::PathAttachment(std::string name) : VertexAttachment(name)
|
||||
{
|
||||
// Empty
|
||||
@ -66,6 +68,4 @@ namespace Spine
|
||||
{
|
||||
_constantSpeed = inValue;
|
||||
}
|
||||
|
||||
RTTI_IMPL(PathAttachment, VertexAttachment);
|
||||
}
|
||||
|
||||
@ -45,6 +45,8 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
RTTI_IMPL(PathConstraint, Constraint);
|
||||
|
||||
const float PathConstraint::EPSILON = 0.00001f;
|
||||
const int PathConstraint::NONE = -1;
|
||||
const int PathConstraint::BEFORE = -2;
|
||||
@ -645,6 +647,4 @@ namespace Spine
|
||||
output[o + 2] = (float)atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt));
|
||||
}
|
||||
}
|
||||
|
||||
RTTI_IMPL(PathConstraint, Constraint);
|
||||
}
|
||||
|
||||
@ -32,8 +32,14 @@
|
||||
|
||||
#include <spine/Bone.h>
|
||||
|
||||
#include <spine/MathUtil.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
RTTI_IMPL(RegionAttachment, Attachment);
|
||||
|
||||
const int RegionAttachment::BLX = 0;
|
||||
const int RegionAttachment::BLY = 1;
|
||||
const int RegionAttachment::ULX = 2;
|
||||
@ -43,6 +49,67 @@ namespace Spine
|
||||
const int RegionAttachment::BRX = 6;
|
||||
const int RegionAttachment::BRY = 7;
|
||||
|
||||
RegionAttachment::RegionAttachment(std::string name) : Attachment(name)
|
||||
{
|
||||
_offset.reserve(NUM_UVS);
|
||||
_uvs.reserve(NUM_UVS);
|
||||
}
|
||||
|
||||
void RegionAttachment::updateOffset()
|
||||
{
|
||||
float regionScaleX = _width / _regionOriginalWidth * _scaleX;
|
||||
float regionScaleY = _height / _regionOriginalHeight * _scaleY;
|
||||
float localX = -_width / 2 * _scaleX + _regionOffsetX * regionScaleX;
|
||||
float localY = -_height / 2 * _scaleY + _regionOffsetY * regionScaleY;
|
||||
float localX2 = localX + _regionWidth * regionScaleX;
|
||||
float localY2 = localY + _regionHeight * regionScaleY;
|
||||
float cos = MathUtil::cosDeg(_rotation);
|
||||
float sin = MathUtil::sinDeg(_rotation);
|
||||
float localXCos = localX * cos + _x;
|
||||
float localXSin = localX * sin;
|
||||
float localYCos = localY * cos + _y;
|
||||
float localYSin = localY * sin;
|
||||
float localX2Cos = localX2 * cos + _x;
|
||||
float localX2Sin = localX2 * sin;
|
||||
float localY2Cos = localY2 * cos + _y;
|
||||
float localY2Sin = localY2 * sin;
|
||||
|
||||
_offset[BLX] = localXCos - localYSin;
|
||||
_offset[BLY] = localYCos + localXSin;
|
||||
_offset[ULX] = localXCos - localY2Sin;
|
||||
_offset[ULY] = localY2Cos + localXSin;
|
||||
_offset[URX] = localX2Cos - localY2Sin;
|
||||
_offset[URY] = localY2Cos + localX2Sin;
|
||||
_offset[BRX] = localX2Cos - localYSin;
|
||||
_offset[BRY] = localYCos + localX2Sin;
|
||||
}
|
||||
|
||||
void RegionAttachment::setUVs(float u, float v, float u2, float v2, bool rotate)
|
||||
{
|
||||
if (rotate)
|
||||
{
|
||||
_uvs[URX] = u;
|
||||
_uvs[URY] = v2;
|
||||
_uvs[BRX] = u;
|
||||
_uvs[BRY] = v;
|
||||
_uvs[BLX] = u2;
|
||||
_uvs[BLY] = v;
|
||||
_uvs[ULX] = u2;
|
||||
_uvs[ULY] = v2;
|
||||
}
|
||||
else
|
||||
{
|
||||
_uvs[ULX] = u;
|
||||
_uvs[ULY] = v2;
|
||||
_uvs[URX] = u;
|
||||
_uvs[URY] = v;
|
||||
_uvs[BRX] = u2;
|
||||
_uvs[BRY] = v;
|
||||
_uvs[BLX] = u2;
|
||||
_uvs[BLY] = v2;
|
||||
}
|
||||
}
|
||||
|
||||
void RegionAttachment::computeWorldVertices(Bone& bone, Vector<float>& worldVertices, int offset, int stride)
|
||||
{
|
||||
assert(worldVertices.size() >= (offset + 8));
|
||||
@ -75,5 +142,203 @@ namespace Spine
|
||||
worldVertices[offset + 1] = offsetX * c + offsetY * d + bwy;
|
||||
}
|
||||
|
||||
RTTI_IMPL(RegionAttachment, Attachment);
|
||||
float RegionAttachment::getX()
|
||||
{
|
||||
return _x;
|
||||
}
|
||||
|
||||
void RegionAttachment::setX(float inValue)
|
||||
{
|
||||
_x = inValue;
|
||||
}
|
||||
|
||||
float RegionAttachment::getY()
|
||||
{
|
||||
return _y;
|
||||
}
|
||||
|
||||
void RegionAttachment::setY(float inValue)
|
||||
{
|
||||
_y = inValue;
|
||||
}
|
||||
|
||||
float RegionAttachment::getRotation()
|
||||
{
|
||||
return _rotation;
|
||||
}
|
||||
|
||||
void RegionAttachment::setRotation(float inValue)
|
||||
{
|
||||
_rotation = inValue;
|
||||
}
|
||||
|
||||
float RegionAttachment::getScaleX()
|
||||
{
|
||||
return _scaleX;
|
||||
}
|
||||
|
||||
void RegionAttachment::setScaleX(float inValue)
|
||||
{
|
||||
_scaleX = inValue;
|
||||
}
|
||||
|
||||
float RegionAttachment::getScaleY()
|
||||
{
|
||||
return _scaleY;
|
||||
}
|
||||
|
||||
void RegionAttachment::setScaleY(float inValue)
|
||||
{
|
||||
_scaleY = inValue;
|
||||
}
|
||||
|
||||
float RegionAttachment::getWidth()
|
||||
{
|
||||
return _width;
|
||||
}
|
||||
|
||||
void RegionAttachment::setWidth(float inValue)
|
||||
{
|
||||
_width = inValue;
|
||||
}
|
||||
|
||||
float RegionAttachment::getHeight()
|
||||
{
|
||||
return _height;
|
||||
}
|
||||
|
||||
void RegionAttachment::setHeight(float inValue)
|
||||
{
|
||||
_height = inValue;
|
||||
}
|
||||
|
||||
float RegionAttachment::getR()
|
||||
{
|
||||
return _r;
|
||||
}
|
||||
|
||||
void RegionAttachment::setR(float inValue)
|
||||
{
|
||||
_r = inValue;
|
||||
}
|
||||
|
||||
float RegionAttachment::getG()
|
||||
{
|
||||
return _g;
|
||||
}
|
||||
|
||||
void RegionAttachment::setG(float inValue)
|
||||
{
|
||||
_g = inValue;
|
||||
}
|
||||
|
||||
float RegionAttachment::getB()
|
||||
{
|
||||
return _b;
|
||||
}
|
||||
|
||||
void RegionAttachment::setB(float inValue)
|
||||
{
|
||||
_b = inValue;
|
||||
}
|
||||
|
||||
float RegionAttachment::getA()
|
||||
{
|
||||
return _a;
|
||||
}
|
||||
|
||||
void RegionAttachment::setA(float inValue)
|
||||
{
|
||||
_a = inValue;
|
||||
}
|
||||
|
||||
std::string RegionAttachment::getPath()
|
||||
{
|
||||
return _path;
|
||||
}
|
||||
|
||||
void RegionAttachment::setPath(std::string inValue)
|
||||
{
|
||||
_path = inValue;
|
||||
}
|
||||
|
||||
void* RegionAttachment::getRendererObject()
|
||||
{
|
||||
return _rendererObject;
|
||||
}
|
||||
|
||||
void RegionAttachment::setRendererObject(void* inValue)
|
||||
{
|
||||
_rendererObject = inValue;
|
||||
}
|
||||
|
||||
float RegionAttachment::getRegionOffsetX()
|
||||
{
|
||||
return _regionOffsetX;
|
||||
}
|
||||
|
||||
void RegionAttachment::setRegionOffsetX(float inValue)
|
||||
{
|
||||
_regionOffsetX = inValue;
|
||||
}
|
||||
|
||||
float RegionAttachment::getRegionOffsetY()
|
||||
{
|
||||
return _regionOffsetY;
|
||||
}
|
||||
|
||||
void RegionAttachment::setRegionOffsetY(float inValue)
|
||||
{
|
||||
_regionOffsetY = inValue;
|
||||
}
|
||||
|
||||
float RegionAttachment::getRegionWidth()
|
||||
{
|
||||
return _regionWidth;
|
||||
}
|
||||
|
||||
void RegionAttachment::setRegionWidth(float inValue)
|
||||
{
|
||||
_regionWidth = inValue;
|
||||
}
|
||||
|
||||
float RegionAttachment::getRegionHeight()
|
||||
{
|
||||
return _regionHeight;
|
||||
}
|
||||
|
||||
void RegionAttachment::setRegionHeight(float inValue)
|
||||
{
|
||||
_regionHeight = inValue;
|
||||
}
|
||||
|
||||
float RegionAttachment::getRegionOriginalWidth()
|
||||
{
|
||||
return _regionOriginalWidth;
|
||||
}
|
||||
|
||||
void RegionAttachment::setRegionOriginalWidth(float inValue)
|
||||
{
|
||||
_regionOriginalWidth = inValue;
|
||||
}
|
||||
|
||||
float RegionAttachment::getRegionOriginalHeight()
|
||||
{
|
||||
return _regionOriginalHeight;
|
||||
}
|
||||
|
||||
void RegionAttachment::setRegionOriginalHeight(float inValue)
|
||||
{
|
||||
_regionOriginalHeight = inValue;
|
||||
}
|
||||
|
||||
Vector<float>& RegionAttachment::getOffset()
|
||||
{
|
||||
return _offset;
|
||||
}
|
||||
|
||||
Vector<float>& RegionAttachment::getUVs()
|
||||
{
|
||||
return _uvs;
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,6 +40,8 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
RTTI_IMPL(RotateTimeline, CurveTimeline);
|
||||
|
||||
RotateTimeline::RotateTimeline(int frameCount) : CurveTimeline(frameCount), _boneIndex(0)
|
||||
{
|
||||
_frames.reserve(frameCount << 1);
|
||||
@ -147,6 +149,4 @@ namespace Spine
|
||||
{
|
||||
_frames = inValue;
|
||||
}
|
||||
|
||||
RTTI_IMPL(RotateTimeline, CurveTimeline);
|
||||
}
|
||||
|
||||
@ -35,6 +35,8 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
RTTI_IMPL_NOPARENT(Timeline);
|
||||
|
||||
Timeline::Timeline()
|
||||
{
|
||||
// Empty
|
||||
@ -44,6 +46,4 @@ namespace Spine
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
RTTI_IMPL_NOPARENT(Timeline);
|
||||
}
|
||||
|
||||
@ -39,6 +39,8 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
RTTI_IMPL(TransformConstraint, Constraint);
|
||||
|
||||
TransformConstraint::TransformConstraint(TransformConstraintData& data, Skeleton& skeleton) : Constraint(),
|
||||
_data(data),
|
||||
_target(skeleton.findBone(data.getTarget()->getName())),
|
||||
@ -445,6 +447,4 @@ namespace Spine
|
||||
bone.updateWorldTransform(x, y, rotation, scaleX, scaleY, bone._ashearX, shearY);
|
||||
}
|
||||
}
|
||||
|
||||
RTTI_IMPL(TransformConstraint, Constraint);
|
||||
}
|
||||
|
||||
@ -32,6 +32,8 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
RTTI_IMPL_NOPARENT(Updatable);
|
||||
|
||||
Updatable::Updatable()
|
||||
{
|
||||
// Empty
|
||||
@ -41,6 +43,4 @@ namespace Spine
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
RTTI_IMPL_NOPARENT(Updatable);
|
||||
}
|
||||
|
||||
@ -37,7 +37,9 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
VertexAttachment::VertexAttachment(std::string name) : Attachment(name), _id(getNextID()), _worldVerticesLength(0)
|
||||
RTTI_IMPL(VertexAttachment, Attachment);
|
||||
|
||||
VertexAttachment::VertexAttachment(std::string name) : Attachment(name), _worldVerticesLength(0), _id(getNextID())
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
@ -174,6 +176,4 @@ namespace Spine
|
||||
|
||||
return (nextID++ & 65535) << 11;
|
||||
}
|
||||
|
||||
RTTI_IMPL(VertexAttachment, Attachment);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user