diff --git a/spine-cpp/spine-cpp/include/spine/VertexEffect.h b/spine-cpp/spine-cpp/include/spine/VertexEffect.h deleted file mode 100644 index 50b9888e9..000000000 --- a/spine-cpp/spine-cpp/include/spine/VertexEffect.h +++ /dev/null @@ -1,120 +0,0 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * 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_VertexEffect_h -#define Spine_VertexEffect_h - -#include -#include - -namespace spine { - - class Skeleton; - - class Color; - - class SP_API VertexEffect : public SpineObject { - public: - virtual void begin(Skeleton &skeleton) = 0; - - virtual void transform(float &x, float &y, float &u, float &v, Color &light, Color &dark) = 0; - - virtual void end() = 0; - }; - - class SP_API JitterVertexEffect : public VertexEffect { - public: - JitterVertexEffect(float jitterX, float jitterY); - - void begin(Skeleton &skeleton); - - void transform(float &x, float &y, float &u, float &v, Color &light, Color &dark); - - void end(); - - void setJitterX(float jitterX); - - float getJitterX(); - - void setJitterY(float jitterY); - - float getJitterY(); - - protected: - float _jitterX; - float _jitterY; - }; - - class SP_API SwirlVertexEffect : public VertexEffect { - public: - SwirlVertexEffect(float radius, Interpolation &interpolation); - - void begin(Skeleton &skeleton); - - void transform(float &x, float &y, float &u, float &v, Color &light, Color &dark); - - void end(); - - void setCenterX(float centerX); - - float getCenterX(); - - void setCenterY(float centerY); - - float getCenterY(); - - void setRadius(float radius); - - float getRadius(); - - void setAngle(float angle); - - float getAngle(); - - void setWorldX(float worldX); - - float getWorldX(); - - void setWorldY(float worldY); - - float getWorldY(); - - protected: - float _centerX; - float _centerY; - float _radius; - float _angle; - float _worldX; - float _worldY; - - Interpolation &_interpolation; - }; -} - -#endif /* Spine_VertexEffect_h */ diff --git a/spine-cpp/spine-cpp/include/spine/spine.h b/spine-cpp/spine-cpp/include/spine/spine.h index b51826788..958114034 100644 --- a/spine-cpp/spine-cpp/include/spine/spine.h +++ b/spine-cpp/spine-cpp/include/spine/spine.h @@ -105,7 +105,6 @@ #include #include #include -#include #include #endif diff --git a/spine-cpp/spine-cpp/src/spine/VertexEffect.cpp b/spine-cpp/spine-cpp/src/spine/VertexEffect.cpp deleted file mode 100644 index b2c589516..000000000 --- a/spine-cpp/spine-cpp/src/spine/VertexEffect.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * 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. - *****************************************************************************/ - -#include -#include -#include - -using namespace spine; - -JitterVertexEffect::JitterVertexEffect(float jitterX, float jitterY) : _jitterX(jitterX), _jitterY(jitterY) { -} - -void JitterVertexEffect::begin(Skeleton &skeleton) { - SP_UNUSED(skeleton); -} - -void JitterVertexEffect::transform(float &x, float &y, float &u, float &v, Color &light, Color &dark) { - SP_UNUSED(u); - SP_UNUSED(v); - SP_UNUSED(light); - SP_UNUSED(dark); - float jitterX = _jitterX; - float jitterY = _jitterY; - x += MathUtil::randomTriangular(-jitterX, jitterX); - y += MathUtil::randomTriangular(-jitterX, jitterY); -} - -void JitterVertexEffect::end() { -} - -void JitterVertexEffect::setJitterX(float jitterX) { - _jitterX = jitterX; -} - -float JitterVertexEffect::getJitterX() { - return _jitterX; -} - -void JitterVertexEffect::setJitterY(float jitterY) { - _jitterY = jitterY; -} - -float JitterVertexEffect::getJitterY() { - return _jitterY; -} - -SwirlVertexEffect::SwirlVertexEffect(float radius, Interpolation &interpolation) : _centerX(0), - _centerY(0), - _radius(radius), - _angle(0), - _worldX(0), - _worldY(0), - _interpolation(interpolation) { -} - -void SwirlVertexEffect::begin(Skeleton &skeleton) { - _worldX = skeleton.getX() + _centerX; - _worldY = skeleton.getY() + _centerY; -} - -void SwirlVertexEffect::transform(float &positionX, float &positionY, float &u, float &v, Color &light, Color &dark) { - SP_UNUSED(u); - SP_UNUSED(v); - SP_UNUSED(light); - SP_UNUSED(dark); - - float x = positionX - _worldX; - float y = positionY - _worldY; - float dist = (float) MathUtil::sqrt(x * x + y * y); - if (dist < _radius) { - float theta = _interpolation.interpolate(0, _angle, (_radius - dist) / _radius); - float cos = MathUtil::cos(theta), sin = MathUtil::sin(theta); - positionX = cos * x - sin * y + _worldX; - positionY = sin * x + cos * y + _worldY; - } -} - -void SwirlVertexEffect::end() { -} - -void SwirlVertexEffect::setCenterX(float centerX) { - _centerX = centerX; -} - -float SwirlVertexEffect::getCenterX() { - return _centerX; -} - -void SwirlVertexEffect::setCenterY(float centerY) { - _centerY = centerY; -} - -float SwirlVertexEffect::getCenterY() { - return _centerY; -} - -void SwirlVertexEffect::setRadius(float radius) { - _radius = radius; -} - -float SwirlVertexEffect::getRadius() { - return _radius; -} - -void SwirlVertexEffect::setAngle(float angle) { - _angle = angle * MathUtil::Deg_Rad; -} - -float SwirlVertexEffect::getAngle() { - return _angle; -} - -void SwirlVertexEffect::setWorldX(float worldX) { - _worldX = worldX; -} - -float SwirlVertexEffect::getWorldX() { - return _worldX; -} - -void SwirlVertexEffect::setWorldY(float worldY) { - _worldY = worldY; -} - -float SwirlVertexEffect::getWorldY() { - return _worldY; -} diff --git a/spine-sfml/cpp/example/main.cpp b/spine-sfml/cpp/example/main.cpp index c3fb5a4c7..7733c5790 100644 --- a/spine-sfml/cpp/example/main.cpp +++ b/spine-sfml/cpp/example/main.cpp @@ -278,9 +278,6 @@ void raptor(SkeletonData *skeletonData, Atlas *atlas) { PowInterpolation pow2(2); PowOutInterpolation powOut2(2); - SwirlVertexEffect effect(400, powOut2); - effect.setCenterY(-200); - drawable.vertexEffect = &effect; Skeleton *skeleton = drawable.skeleton; skeleton->setPosition(320, 590); @@ -293,7 +290,6 @@ void raptor(SkeletonData *skeletonData, Atlas *atlas) { window.setFramerateLimit(60); sf::Event event; sf::Clock deltaClock; - float swirlTime = 0; while (window.isOpen()) { while (window.pollEvent(event)) if (event.type == sf::Event::Closed) window.close(); @@ -301,11 +297,6 @@ void raptor(SkeletonData *skeletonData, Atlas *atlas) { float delta = deltaClock.getElapsedTime().asSeconds(); deltaClock.restart(); - swirlTime += delta; - float percent = MathUtil::fmod(swirlTime, 2); - if (percent > 1) percent = 1 - (percent - 1); - effect.setAngle(pow2.interpolate(-60.0f, 60.0f, percent)); - drawable.update(delta); window.clear(); diff --git a/spine-sfml/cpp/src/spine/spine-sfml.cpp b/spine-sfml/cpp/src/spine/spine-sfml.cpp index 4c6ca494b..98962be00 100644 --- a/spine-sfml/cpp/src/spine/spine-sfml.cpp +++ b/spine-sfml/cpp/src/spine/spine-sfml.cpp @@ -49,7 +49,7 @@ namespace spine { SkeletonDrawable::SkeletonDrawable(SkeletonData *skeletonData, AnimationStateData *stateData) : timeScale(1), vertexArray(new VertexArray(Triangles, skeletonData->getBones().size() * 4)), - vertexEffect(NULL), worldVertices(), clipper() { + worldVertices(), clipper() { Bone::setYDown(true); worldVertices.ensureCapacity(SPINE_MESH_VERTEX_COUNT_MAX); skeleton = new (__FILE__, __LINE__) Skeleton(skeletonData); @@ -89,8 +89,6 @@ namespace spine { // Early out if skeleton is invisible if (skeleton->getColor().a == 0) return; - if (vertexEffect != NULL) vertexEffect->begin(*skeleton); - sf::Vertex vertex; Texture *texture = NULL; for (unsigned i = 0; i < skeleton->getSlots().size(); ++i) { @@ -226,55 +224,18 @@ namespace spine { Vector2u size = texture->getSize(); - if (vertexEffect != 0) { - tempUvs.clear(); - tempColors.clear(); - for (int ii = 0; ii < verticesCount; ii++) { - Color vertexColor = light; - Color dark; - dark.r = dark.g = dark.b = dark.a = 0; - int index = ii << 1; - float x = (*vertices)[index]; - float y = (*vertices)[index + 1]; - float u = (*uvs)[index]; - float v = (*uvs)[index + 1]; - vertexEffect->transform(x, y, u, v, vertexColor, dark); - (*vertices)[index] = x; - (*vertices)[index + 1] = y; - tempUvs.add(u); - tempUvs.add(v); - tempColors.add(vertexColor); - } - - for (int ii = 0; ii < indicesCount; ++ii) { - int index = (*indices)[ii] << 1; - vertex.position.x = (*vertices)[index]; - vertex.position.y = (*vertices)[index + 1]; - vertex.texCoords.x = (*uvs)[index] * size.x; - vertex.texCoords.y = (*uvs)[index + 1] * size.y; - Color vertexColor = tempColors[index >> 1]; - vertex.color.r = static_cast(vertexColor.r * 255); - vertex.color.g = static_cast(vertexColor.g * 255); - vertex.color.b = static_cast(vertexColor.b * 255); - vertex.color.a = static_cast(vertexColor.a * 255); - vertexArray->append(vertex); - } - } else { - for (int ii = 0; ii < indicesCount; ++ii) { - int index = (*indices)[ii] << 1; - vertex.position.x = (*vertices)[index]; - vertex.position.y = (*vertices)[index + 1]; - vertex.texCoords.x = (*uvs)[index] * size.x; - vertex.texCoords.y = (*uvs)[index + 1] * size.y; - vertexArray->append(vertex); - } + for (int ii = 0; ii < indicesCount; ++ii) { + int index = (*indices)[ii] << 1; + vertex.position.x = (*vertices)[index]; + vertex.position.y = (*vertices)[index + 1]; + vertex.texCoords.x = (*uvs)[index] * size.x; + vertex.texCoords.y = (*uvs)[index + 1] * size.y; + vertexArray->append(vertex); } clipper.clipEnd(slot); } target.draw(*vertexArray, states); clipper.clipEnd(); - - if (vertexEffect != 0) vertexEffect->end(); } void SFMLTextureLoader::load(AtlasPage &page, const String &path) { diff --git a/spine-sfml/cpp/src/spine/spine-sfml.h b/spine-sfml/cpp/src/spine/spine-sfml.h index d207d8b4a..829f91215 100644 --- a/spine-sfml/cpp/src/spine/spine-sfml.h +++ b/spine-sfml/cpp/src/spine/spine-sfml.h @@ -46,10 +46,10 @@ namespace spine { AnimationState *state; float timeScale; sf::VertexArray *vertexArray; - VertexEffect *vertexEffect; SkeletonDrawable(SkeletonData *skeleton, AnimationStateData *stateData = 0); + ~SkeletonDrawable(); void update(float deltaTime);