diff --git a/spine-cpp/spine-cpp/include/spine/BoneData.h b/spine-cpp/spine-cpp/include/spine/BoneData.h new file mode 100644 index 000000000..79467a035 --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/BoneData.h @@ -0,0 +1,101 @@ +/****************************************************************************** + * 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_BoneData_h +#define Spine_BoneData_h + +#include + +#include + +namespace Spine +{ + class BoneData + { + public: + BoneData(int index, std::string name, BoneData* parent); + + /// The index of the bone in Skeleton.Bones + const int getIndex(); + + /// The name of the bone, which is unique within the skeleton. + const std::string& getName(); + + /// May be null. + const BoneData* getParent(); + + float getLength(); + void setLength(float inValue); + + /// Local X translation. + float getX(); + void setX(float inValue); + + /// Local Y translation. + float getY(); + void setY(float inValue); + + /// Local rotation. + float getRotation(); + void setRotation(float inValue); + + /// Local scaleX. + float getScaleX(); + void setScaleX(float inValue); + + /// Local scaleY. + float getScaleY(); + void setScaleY(float inValue); + + /// Local shearX. + float getShearX(); + void setShearX(float inValue); + + /// Local shearY. + float getShearY(); + void setShearY(float inValue); + + /// The transform mode for how parent world transforms affect this bone. + TransformMode getTransformMode(); + void setTransformMode(TransformMode inValue); + + private: + const int _index; + const std::string _name; + const BoneData* _parent; + float _length; + float _x, _y, _rotation, _scaleX, _scaleY, _shearX, _shearY; + TransformMode _transformMode; + + friend std::ostream& operator <<(std::ostream& os, const BoneData& ref); + }; +} + +#endif /* Spine_BoneData_h */ diff --git a/spine-cpp/spine-cpp/include/spine/IkConstraintData.h b/spine-cpp/spine-cpp/include/spine/IkConstraintData.h new file mode 100644 index 000000000..d4c089921 --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/IkConstraintData.h @@ -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_IkConstraintData_h +#define Spine_IkConstraintData_h + +#include +#include + +class BoneData; + +namespace Spine +{ + class IkConstraintData + { + public: + IkConstraintData(std::string name); + + /// The IK constraint's name, which is unique within the skeleton. + const std::string& getName(); + + int getOrder(); + void setOrder(int inValue); + + /// The bones that are constrained by this IK Constraint. + std::list& getBones(); + + /// The bone that is the IK target. + BoneData* getTarget(); + void setTarget(BoneData* inValue); + + /// Controls the bend direction of the IK bones, either 1 or -1. + int getBendDirection(); + void setBendDirection(int inValue); + + float getMix(); + void setMix(float inValue); + + private: + const std::string _name; + int _order; + std::list _bones; + BoneData* _target; + int _bendDirection; + float _mix; + + friend std::ostream& operator <<(std::ostream& os, const IkConstraintData& ref); + }; +} + +#endif /* Spine_IkConstraintData_h */ diff --git a/spine-cpp/spine-cpp/include/spine/TransformMode.h b/spine-cpp/spine-cpp/include/spine/TransformMode.h new file mode 100644 index 000000000..5af1b802f --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/TransformMode.h @@ -0,0 +1,48 @@ +/****************************************************************************** + * 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_TransformMode_h +#define Spine_TransformMode_h + +namespace Spine +{ + enum TransformMode + { + //0000 0 Flip Scale Rotation + Normal = 0, // 0000 + OnlyTranslation = 7, // 0111 + NoRotationOrReflection = 1, // 0001 + NoScale = 2, // 0010 + NoScaleOrReflection = 6, // 0110 + }; +} + +#endif /* Spine_TransformMode_h */ + diff --git a/spine-cpp/spine-cpp/src/spine/BoneData.cpp b/spine-cpp/spine-cpp/src/spine/BoneData.cpp new file mode 100644 index 000000000..f5d23e76c --- /dev/null +++ b/spine-cpp/spine-cpp/src/spine/BoneData.cpp @@ -0,0 +1,165 @@ +/****************************************************************************** +* 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 + +#include + +namespace Spine +{ + BoneData::BoneData(int index, std::string name, BoneData* parent) : + _index(index), + _name(name), + _parent(parent), + _length(0), + _x(0), + _y(0), + _rotation(0), + _scaleX(1), + _scaleY(1), + _shearX(0), + _shearY(0), + _transformMode(TransformMode::Normal) + { + assert(index < 0); + } + + const int BoneData::getIndex() + { + return _index; + } + + const std::string& BoneData::getName() + { + return _name; + } + + const BoneData* BoneData::getParent() + { + return _parent; + } + + float BoneData::getLength() + { + return _length; + } + + void BoneData::setLength(float inValue) + { + _length = inValue; + } + + float BoneData::getX() + { + return _x; + } + + void BoneData::setX(float inValue) + { + _x = inValue; + } + + float BoneData::getY() + { + return _y; + } + + void BoneData::setY(float inValue) + { + _y = inValue; + } + + float BoneData::getRotation() + { + return _rotation; + } + + void BoneData::setRotation(float inValue) + { + _rotation = inValue; + } + + float BoneData::getScaleX() + { + return _scaleX; + } + + void BoneData::setScaleX(float inValue) + { + _scaleX = inValue; + } + + float BoneData::getScaleY() + { + return _scaleY; + } + + void BoneData::setScaleY(float inValue) + { + _scaleY = inValue; + } + + float BoneData::getShearX() + { + return _shearX; + } + + void BoneData::setShearX(float inValue) + { + _shearX = inValue; + } + + float BoneData::getShearY() + { + return _shearY; + } + + void BoneData::setShearY(float inValue) + { + _shearY = inValue; + } + + TransformMode BoneData::getTransformMode() + { + return _transformMode; + } + + void BoneData::setTransformMode(TransformMode inValue) + { + _transformMode = inValue; + } + + std::ostream& operator <<(std::ostream& os, const BoneData& ref) + { + os << ref._name; + + return os; + } +} diff --git a/spine-cpp/spine-cpp/src/spine/IkConstraintData.cpp b/spine-cpp/spine-cpp/src/spine/IkConstraintData.cpp new file mode 100644 index 000000000..a241f7dec --- /dev/null +++ b/spine-cpp/spine-cpp/src/spine/IkConstraintData.cpp @@ -0,0 +1,101 @@ +/****************************************************************************** +* 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 + +namespace Spine +{ + IkConstraintData::IkConstraintData(std::string name) : + _name(name), + _order(0), + _target(nullptr), + _bendDirection(1), + _mix(1) + { + // Empty + } + + const std::string& IkConstraintData::getName() + { + return _name; + } + + int IkConstraintData::getOrder() + { + return _order; + } + + void IkConstraintData::setOrder(int inValue) + { + _order = inValue; + } + + std::list& IkConstraintData::getBones() + { + return _bones; + } + + BoneData* IkConstraintData::getTarget() + { + return _target; + } + + void IkConstraintData::setTarget(BoneData* inValue) + { + _target = inValue; + } + + int IkConstraintData::getBendDirection() + { + return _bendDirection; + } + + void IkConstraintData::setBendDirection(int inValue) + { + _bendDirection = inValue; + } + + float IkConstraintData::getMix() + { + return _mix; + } + + void IkConstraintData::setMix(float inValue) + { + _mix = inValue; + } + + std::ostream& operator <<(std::ostream& os, const IkConstraintData& ref) + { + os << ref._name; + + return os; + } +}