2020-10-17 16:32:16 +08:00
|
|
|
/******************************************************************************
|
|
|
|
* Spine Runtimes License Agreement
|
2022-11-07 15:48:19 +08:00
|
|
|
* Last updated September 24, 2021. Replaces all prior versions.
|
2020-10-17 16:32:16 +08:00
|
|
|
*
|
2022-11-07 15:48:19 +08:00
|
|
|
* Copyright (c) 2013-2021, Esoteric Software LLC
|
2020-10-17 16:32:16 +08:00
|
|
|
*
|
|
|
|
* Integration of the Spine Runtimes into software or otherwise creating
|
|
|
|
* derivative works of the Spine Runtimes is permitted under the terms and
|
|
|
|
* conditions of Section 2 of the Spine Editor License Agreement:
|
|
|
|
* http://esotericsoftware.com/spine-editor-license
|
|
|
|
*
|
|
|
|
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
|
|
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
|
|
|
* "Products"), provided that each user of the Products must obtain their own
|
|
|
|
* Spine Editor license and redistribution of the Products in any form must
|
|
|
|
* include this license and copyright notice.
|
|
|
|
*
|
|
|
|
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "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 LLC 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
|
|
|
|
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef Spine_Bone_h
|
|
|
|
#define Spine_Bone_h
|
|
|
|
|
|
|
|
#include <spine/Updatable.h>
|
|
|
|
#include <spine/SpineObject.h>
|
|
|
|
#include <spine/Vector.h>
|
|
|
|
|
|
|
|
namespace spine {
|
2022-11-07 15:48:19 +08:00
|
|
|
class BoneData;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
class Skeleton;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
|
|
|
/// 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.
|
2022-11-07 15:48:19 +08:00
|
|
|
class SP_API Bone : public Updatable {
|
|
|
|
friend class AnimationState;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class RotateTimeline;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class IkConstraint;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class TransformConstraint;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class VertexAttachment;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class PathConstraint;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class Skeleton;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class RegionAttachment;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class PointAttachment;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class AttachmentTimeline;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class RGBATimeline;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class RGBTimeline;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class AlphaTimeline;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class RGBA2Timeline;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class RGB2Timeline;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class ScaleTimeline;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class ScaleXTimeline;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class ScaleYTimeline;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class ShearTimeline;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class ShearXTimeline;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class ShearYTimeline;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class TranslateTimeline;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class TranslateXTimeline;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
friend class TranslateYTimeline;
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
RTTI_DECL
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
public:
|
|
|
|
static void setYDown(bool inValue);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
static bool isYDown();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
/// @param parent May be NULL.
|
|
|
|
Bone(BoneData &data, Skeleton &skeleton, Bone *parent = NULL);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
/// Same as updateWorldTransform. This method exists for Bone to implement Spine::Updatable.
|
|
|
|
virtual void update();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
/// Computes the world transform using the parent bone and this bone's local transform.
|
|
|
|
void updateWorldTransform();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
/// Computes the world transform using the parent bone and the specified local transform.
|
|
|
|
void
|
|
|
|
updateWorldTransform(float x, float y, float rotation, float scaleX, float scaleY, float shearX, float shearY);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2023-05-07 21:15:56 +08:00
|
|
|
/// 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.
|
|
|
|
void updateAppliedTransform();
|
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setToSetupPose();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void worldToLocal(float worldX, float worldY, float &outLocalX, float &outLocalY);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void localToWorld(float localX, float localY, float &outWorldX, float &outWorldY);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
float worldToLocalRotation(float worldRotation);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
float localToWorldRotation(float localRotation);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
/// Rotates the world transform the specified amount and sets isAppliedValid to false.
|
|
|
|
/// @param degrees Degrees.
|
|
|
|
void rotateWorld(float degrees);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
float getWorldToLocalRotationX();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
float getWorldToLocalRotationY();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
BoneData &getData();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
Skeleton &getSkeleton();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
Bone *getParent();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
Vector<Bone *> &getChildren();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
/// The local X translation.
|
|
|
|
float getX();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setX(float inValue);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
/// The local Y translation.
|
|
|
|
float getY();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setY(float inValue);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
/// The local rotation.
|
|
|
|
float getRotation();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setRotation(float inValue);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
/// The local scaleX.
|
|
|
|
float getScaleX();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setScaleX(float inValue);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
/// The local scaleY.
|
|
|
|
float getScaleY();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setScaleY(float inValue);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
/// The local shearX.
|
|
|
|
float getShearX();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setShearX(float inValue);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
/// The local shearY.
|
|
|
|
float getShearY();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setShearY(float inValue);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
/// The rotation, as calculated by any constraints.
|
|
|
|
float getAppliedRotation();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setAppliedRotation(float inValue);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
/// The applied local x translation.
|
|
|
|
float getAX();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setAX(float inValue);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
/// The applied local y translation.
|
|
|
|
float getAY();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setAY(float inValue);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
/// The applied local scaleX.
|
|
|
|
float getAScaleX();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setAScaleX(float inValue);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
/// The applied local scaleY.
|
|
|
|
float getAScaleY();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setAScaleY(float inValue);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
/// The applied local shearX.
|
|
|
|
float getAShearX();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setAShearX(float inValue);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
/// The applied local shearY.
|
|
|
|
float getAShearY();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setAShearY(float inValue);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
float getA();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setA(float inValue);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
float getB();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setB(float inValue);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
float getC();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setC(float inValue);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
float getD();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setD(float inValue);
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
float getWorldX();
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2022-11-07 15:48:19 +08:00
|
|
|
void setWorldX(float inValue);
|
|
|
|
|
|
|
|
float getWorldY();
|
|
|
|
|
|
|
|
void setWorldY(float inValue);
|
|
|
|
|
|
|
|
float getWorldRotationX();
|
|
|
|
|
|
|
|
float getWorldRotationY();
|
|
|
|
|
|
|
|
/// Returns the magnitide (always positive) of the world scale X.
|
|
|
|
float getWorldScaleX();
|
|
|
|
|
|
|
|
/// Returns the magnitide (always positive) of the world scale Y.
|
|
|
|
float getWorldScaleY();
|
|
|
|
|
|
|
|
bool isActive();
|
|
|
|
|
|
|
|
void setActive(bool inValue);
|
|
|
|
|
|
|
|
private:
|
|
|
|
static bool yDown;
|
|
|
|
|
|
|
|
BoneData &_data;
|
|
|
|
Skeleton &_skeleton;
|
|
|
|
Bone *_parent;
|
|
|
|
Vector<Bone *> _children;
|
|
|
|
float _x, _y, _rotation, _scaleX, _scaleY, _shearX, _shearY;
|
|
|
|
float _ax, _ay, _arotation, _ascaleX, _ascaleY, _ashearX, _ashearY;
|
|
|
|
float _a, _b, _worldX;
|
|
|
|
float _c, _d, _worldY;
|
|
|
|
bool _sorted;
|
|
|
|
bool _active;
|
|
|
|
};
|
2020-10-17 16:32:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* Spine_Bone_h */
|