mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Merge branch '4.1-beta' into 4.2-beta
This commit is contained in:
commit
e34af6ccf0
@ -1,84 +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 <spine/dll.h>
|
|
||||||
#include <spine/Skeleton.h>
|
|
||||||
#include <spine/Color.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct spVertexEffect;
|
|
||||||
|
|
||||||
typedef void (*spVertexEffectBegin)(struct spVertexEffect *self, spSkeleton *skeleton);
|
|
||||||
|
|
||||||
typedef void (*spVertexEffectTransform)(struct spVertexEffect *self, float *x, float *y, float *u, float *v,
|
|
||||||
spColor *light, spColor *dark);
|
|
||||||
|
|
||||||
typedef void (*spVertexEffectEnd)(struct spVertexEffect *self);
|
|
||||||
|
|
||||||
typedef struct spVertexEffect {
|
|
||||||
spVertexEffectBegin begin;
|
|
||||||
spVertexEffectTransform transform;
|
|
||||||
spVertexEffectEnd end;
|
|
||||||
} spVertexEffect;
|
|
||||||
|
|
||||||
typedef struct spJitterVertexEffect {
|
|
||||||
spVertexEffect super;
|
|
||||||
float jitterX;
|
|
||||||
float jitterY;
|
|
||||||
} spJitterVertexEffect;
|
|
||||||
|
|
||||||
typedef struct spSwirlVertexEffect {
|
|
||||||
spVertexEffect super;
|
|
||||||
float centerX;
|
|
||||||
float centerY;
|
|
||||||
float radius;
|
|
||||||
float angle;
|
|
||||||
float worldX;
|
|
||||||
float worldY;
|
|
||||||
} spSwirlVertexEffect;
|
|
||||||
|
|
||||||
SP_API spJitterVertexEffect *spJitterVertexEffect_create(float jitterX, float jitterY);
|
|
||||||
|
|
||||||
SP_API void spJitterVertexEffect_dispose(spJitterVertexEffect *effect);
|
|
||||||
|
|
||||||
SP_API spSwirlVertexEffect *spSwirlVertexEffect_create(float radius);
|
|
||||||
|
|
||||||
SP_API void spSwirlVertexEffect_dispose(spSwirlVertexEffect *effect);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* SPINE_VERTEX_EFFECT_H_ */
|
|
||||||
@ -58,6 +58,5 @@
|
|||||||
#include <spine/SkeletonClipping.h>
|
#include <spine/SkeletonClipping.h>
|
||||||
#include <spine/Event.h>
|
#include <spine/Event.h>
|
||||||
#include <spine/EventData.h>
|
#include <spine/EventData.h>
|
||||||
#include <spine/VertexEffect.h>
|
|
||||||
|
|
||||||
#endif /* SPINE_SPINE_H_ */
|
#endif /* SPINE_SPINE_H_ */
|
||||||
|
|||||||
@ -1,112 +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 <spine/VertexEffect.h>
|
|
||||||
#include <spine/extension.h>
|
|
||||||
|
|
||||||
void _spJitterVertexEffect_begin(spVertexEffect *self, spSkeleton *skeleton) {
|
|
||||||
UNUSED(self);
|
|
||||||
UNUSED(skeleton);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _spJitterVertexEffect_transform(spVertexEffect *self, float *x, float *y, float *u, float *v, spColor *light,
|
|
||||||
spColor *dark) {
|
|
||||||
spJitterVertexEffect *internal = (spJitterVertexEffect *) self;
|
|
||||||
float jitterX = internal->jitterX;
|
|
||||||
float jitterY = internal->jitterY;
|
|
||||||
(*x) += _spMath_randomTriangular(-jitterX, jitterY);
|
|
||||||
(*y) += _spMath_randomTriangular(-jitterX, jitterY);
|
|
||||||
UNUSED(u);
|
|
||||||
UNUSED(v);
|
|
||||||
UNUSED(light);
|
|
||||||
UNUSED(dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _spJitterVertexEffect_end(spVertexEffect *self) {
|
|
||||||
UNUSED(self);
|
|
||||||
}
|
|
||||||
|
|
||||||
spJitterVertexEffect *spJitterVertexEffect_create(float jitterX, float jitterY) {
|
|
||||||
spJitterVertexEffect *effect = CALLOC(spJitterVertexEffect, 1);
|
|
||||||
effect->super.begin = _spJitterVertexEffect_begin;
|
|
||||||
effect->super.transform = _spJitterVertexEffect_transform;
|
|
||||||
effect->super.end = _spJitterVertexEffect_end;
|
|
||||||
effect->jitterX = jitterX;
|
|
||||||
effect->jitterY = jitterY;
|
|
||||||
return effect;
|
|
||||||
}
|
|
||||||
|
|
||||||
void spJitterVertexEffect_dispose(spJitterVertexEffect *effect) {
|
|
||||||
FREE(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _spSwirlVertexEffect_begin(spVertexEffect *self, spSkeleton *skeleton) {
|
|
||||||
spSwirlVertexEffect *internal = (spSwirlVertexEffect *) self;
|
|
||||||
internal->worldX = skeleton->x + internal->centerX;
|
|
||||||
internal->worldY = skeleton->y + internal->centerY;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _spSwirlVertexEffect_transform(spVertexEffect *self, float *positionX, float *positionY, float *u, float *v,
|
|
||||||
spColor *light, spColor *dark) {
|
|
||||||
spSwirlVertexEffect *internal = (spSwirlVertexEffect *) self;
|
|
||||||
float radAngle = internal->angle * DEG_RAD;
|
|
||||||
float x = *positionX - internal->worldX;
|
|
||||||
float y = *positionY - internal->worldY;
|
|
||||||
float dist = SQRT(x * x + y * y);
|
|
||||||
if (dist < internal->radius) {
|
|
||||||
float theta = _spMath_interpolate(_spMath_pow2_apply, 0, radAngle,
|
|
||||||
(internal->radius - dist) / internal->radius);
|
|
||||||
float cosine = COS(theta);
|
|
||||||
float sine = SIN(theta);
|
|
||||||
(*positionX) = cosine * x - sine * y + internal->worldX;
|
|
||||||
(*positionY) = sine * x + cosine * y + internal->worldY;
|
|
||||||
}
|
|
||||||
UNUSED(self);
|
|
||||||
UNUSED(u);
|
|
||||||
UNUSED(v);
|
|
||||||
UNUSED(light);
|
|
||||||
UNUSED(dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _spSwirlVertexEffect_end(spVertexEffect *self) {
|
|
||||||
UNUSED(self);
|
|
||||||
}
|
|
||||||
|
|
||||||
spSwirlVertexEffect *spSwirlVertexEffect_create(float radius) {
|
|
||||||
spSwirlVertexEffect *effect = CALLOC(spSwirlVertexEffect, 1);
|
|
||||||
effect->super.begin = _spSwirlVertexEffect_begin;
|
|
||||||
effect->super.transform = _spSwirlVertexEffect_transform;
|
|
||||||
effect->super.end = _spSwirlVertexEffect_end;
|
|
||||||
effect->radius = radius;
|
|
||||||
return effect;
|
|
||||||
}
|
|
||||||
|
|
||||||
void spSwirlVertexEffect_dispose(spSwirlVertexEffect *effect) {
|
|
||||||
FREE(effect);
|
|
||||||
}
|
|
||||||
@ -43,7 +43,7 @@ The Spine cocos2d-objc example works on iOS simulators and devices.
|
|||||||
3. Open a terminal and install CMake via `brew install cmake`
|
3. Open a terminal and install CMake via `brew install cmake`
|
||||||
3. Download the Spine Runtimes repository using git (`git clone https://github.com/esotericsoftware/spine-runtimes`) or download it as a zip via the download button above.
|
3. Download the Spine Runtimes repository using git (`git clone https://github.com/esotericsoftware/spine-runtimes`) or download it as a zip via the download button above.
|
||||||
4. Open a terminal, and `cd` into the `spine-runtimes/spine-cocos2d-objc` folder
|
4. Open a terminal, and `cd` into the `spine-runtimes/spine-cocos2d-objc` folder
|
||||||
5. Type `mkdir build && cd build && cmake ../..`, this will download the cocos2d-objc dependency
|
5. Type `mkdir build && cd build && cmake ..`, this will download the cocos2d-objc dependency
|
||||||
6. Open the Xcode project in `spine-runtimes/spine-cocos2d-objc/spine-cocos2d-objc.xcodeproj/`
|
6. Open the Xcode project in `spine-runtimes/spine-cocos2d-objc/spine-cocos2d-objc.xcodeproj/`
|
||||||
7. In the file `spine-runtimes/spine-cocos2d-objc/cocos2d/cocos2d/CCRendererBasicTypes.m`, change line 56 from `-(id)objectForKey:(id<NSCopying>)options` to `-(id)objectForKey:(id)options`. This will allow building cocos2d-objc with the latest Xcode version.
|
7. In the file `spine-runtimes/spine-cocos2d-objc/cocos2d/cocos2d/CCRendererBasicTypes.m`, change line 56 from `-(id)objectForKey:(id<NSCopying>)options` to `-(id)objectForKey:(id)options`. This will allow building cocos2d-objc with the latest Xcode version.
|
||||||
7. In Xcode, click the `Run` button or type `CMD+R` to run the example on the simulator
|
7. In Xcode, click the `Run` button or type `CMD+R` to run the example on the simulator
|
||||||
|
|||||||
@ -30,8 +30,6 @@
|
|||||||
#import "RaptorExample.h"
|
#import "RaptorExample.h"
|
||||||
#import "TankExample.h"
|
#import "TankExample.h"
|
||||||
|
|
||||||
spJitterVertexEffect* effect = 0;
|
|
||||||
|
|
||||||
@implementation RaptorExample
|
@implementation RaptorExample
|
||||||
|
|
||||||
+ (CCScene*) scene {
|
+ (CCScene*) scene {
|
||||||
@ -44,11 +42,8 @@ spJitterVertexEffect* effect = 0;
|
|||||||
self = [super init];
|
self = [super init];
|
||||||
if (!self) return nil;
|
if (!self) return nil;
|
||||||
|
|
||||||
if (!effect) effect = spJitterVertexEffect_create(10, 10);
|
|
||||||
|
|
||||||
skeletonNode = [SkeletonAnimation skeletonWithFile:@"raptor-pro.json" atlasFile:@"raptor.atlas" scale:0.3f];
|
skeletonNode = [SkeletonAnimation skeletonWithFile:@"raptor-pro.json" atlasFile:@"raptor.atlas" scale:0.3f];
|
||||||
[skeletonNode setAnimationForTrack:0 name:@"walk" loop:YES];
|
[skeletonNode setAnimationForTrack:0 name:@"walk" loop:YES];
|
||||||
[skeletonNode setEffect:&effect->super];
|
|
||||||
|
|
||||||
CGSize windowSize = [[CCDirector sharedDirector] viewSize];
|
CGSize windowSize = [[CCDirector sharedDirector] viewSize];
|
||||||
[skeletonNode setPosition:ccp(windowSize.width / 2, 20)];
|
[skeletonNode setPosition:ccp(windowSize.width / 2, 20)];
|
||||||
|
|||||||
@ -86,7 +86,6 @@
|
|||||||
76F5BDAD1D2BDFA2005917E5 /* TankExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 76F5BDAC1D2BDFA2005917E5 /* TankExample.m */; };
|
76F5BDAD1D2BDFA2005917E5 /* TankExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 76F5BDAC1D2BDFA2005917E5 /* TankExample.m */; };
|
||||||
76FAC1961E3FA15E001CCC8C /* Color.c in Sources */ = {isa = PBXBuildFile; fileRef = 76FAC1941E3FA15E001CCC8C /* Color.c */; };
|
76FAC1961E3FA15E001CCC8C /* Color.c in Sources */ = {isa = PBXBuildFile; fileRef = 76FAC1941E3FA15E001CCC8C /* Color.c */; };
|
||||||
76FAC1971E3FA15E001CCC8C /* PointAttachment.c in Sources */ = {isa = PBXBuildFile; fileRef = 76FAC1951E3FA15E001CCC8C /* PointAttachment.c */; };
|
76FAC1971E3FA15E001CCC8C /* PointAttachment.c in Sources */ = {isa = PBXBuildFile; fileRef = 76FAC1951E3FA15E001CCC8C /* PointAttachment.c */; };
|
||||||
76FB151A1F01413B00C5377F /* VertexEffect.c in Sources */ = {isa = PBXBuildFile; fileRef = 76FB15191F01413B00C5377F /* VertexEffect.c */; };
|
|
||||||
83F1A0EF1986955A001F6B44 /* GLKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83F1A0EE1986955A001F6B44 /* GLKit.framework */; };
|
83F1A0EF1986955A001F6B44 /* GLKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83F1A0EE1986955A001F6B44 /* GLKit.framework */; };
|
||||||
9A5D2499170A94DA0030D4DD /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A5D2498170A94DA0030D4DD /* QuartzCore.framework */; };
|
9A5D2499170A94DA0030D4DD /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A5D2498170A94DA0030D4DD /* QuartzCore.framework */; };
|
||||||
9A5D249B170A94DA0030D4DD /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A5D249A170A94DA0030D4DD /* OpenGLES.framework */; };
|
9A5D249B170A94DA0030D4DD /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A5D249A170A94DA0030D4DD /* OpenGLES.framework */; };
|
||||||
@ -202,7 +201,6 @@
|
|||||||
76F28D021DEC810300CDE54D /* IkConstraintData.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = IkConstraintData.c; path = "../spine-c/spine-c/src/spine/IkConstraintData.c"; sourceTree = "<group>"; };
|
76F28D021DEC810300CDE54D /* IkConstraintData.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = IkConstraintData.c; path = "../spine-c/spine-c/src/spine/IkConstraintData.c"; sourceTree = "<group>"; };
|
||||||
76F28D031DEC810300CDE54D /* Json.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = Json.c; path = "../spine-c/spine-c/src/spine/Json.c"; sourceTree = "<group>"; };
|
76F28D031DEC810300CDE54D /* Json.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = Json.c; path = "../spine-c/spine-c/src/spine/Json.c"; sourceTree = "<group>"; };
|
||||||
76F28D041DEC810300CDE54D /* Json.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Json.h; path = "../spine-c/spine-c/src/spine/Json.h"; sourceTree = "<group>"; };
|
76F28D041DEC810300CDE54D /* Json.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Json.h; path = "../spine-c/spine-c/src/spine/Json.h"; sourceTree = "<group>"; };
|
||||||
76F28D051DEC810300CDE54D /* kvec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = kvec.h; path = "../spine-c/spine-c/src/spine/kvec.h"; sourceTree = "<group>"; };
|
|
||||||
76F28D061DEC810300CDE54D /* MeshAttachment.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = MeshAttachment.c; path = "../spine-c/spine-c/src/spine/MeshAttachment.c"; sourceTree = "<group>"; };
|
76F28D061DEC810300CDE54D /* MeshAttachment.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = MeshAttachment.c; path = "../spine-c/spine-c/src/spine/MeshAttachment.c"; sourceTree = "<group>"; };
|
||||||
76F28D071DEC810300CDE54D /* PathAttachment.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = PathAttachment.c; path = "../spine-c/spine-c/src/spine/PathAttachment.c"; sourceTree = "<group>"; };
|
76F28D071DEC810300CDE54D /* PathAttachment.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = PathAttachment.c; path = "../spine-c/spine-c/src/spine/PathAttachment.c"; sourceTree = "<group>"; };
|
||||||
76F28D081DEC810300CDE54D /* PathConstraint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = PathConstraint.c; path = "../spine-c/spine-c/src/spine/PathConstraint.c"; sourceTree = "<group>"; };
|
76F28D081DEC810300CDE54D /* PathConstraint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = PathConstraint.c; path = "../spine-c/spine-c/src/spine/PathConstraint.c"; sourceTree = "<group>"; };
|
||||||
@ -231,7 +229,6 @@
|
|||||||
76F5BDAC1D2BDFA2005917E5 /* TankExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TankExample.m; path = example/TankExample.m; sourceTree = "<group>"; };
|
76F5BDAC1D2BDFA2005917E5 /* TankExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TankExample.m; path = example/TankExample.m; sourceTree = "<group>"; };
|
||||||
76FAC1941E3FA15E001CCC8C /* Color.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = Color.c; path = "../spine-c/spine-c/src/spine/Color.c"; sourceTree = "<group>"; };
|
76FAC1941E3FA15E001CCC8C /* Color.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = Color.c; path = "../spine-c/spine-c/src/spine/Color.c"; sourceTree = "<group>"; };
|
||||||
76FAC1951E3FA15E001CCC8C /* PointAttachment.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = PointAttachment.c; path = "../spine-c/spine-c/src/spine/PointAttachment.c"; sourceTree = "<group>"; };
|
76FAC1951E3FA15E001CCC8C /* PointAttachment.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = PointAttachment.c; path = "../spine-c/spine-c/src/spine/PointAttachment.c"; sourceTree = "<group>"; };
|
||||||
76FB15191F01413B00C5377F /* VertexEffect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = VertexEffect.c; path = "../spine-c/spine-c/src/spine/VertexEffect.c"; sourceTree = "<group>"; };
|
|
||||||
83F1A0EE1986955A001F6B44 /* GLKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLKit.framework; path = System/Library/Frameworks/GLKit.framework; sourceTree = SDKROOT; };
|
83F1A0EE1986955A001F6B44 /* GLKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLKit.framework; path = System/Library/Frameworks/GLKit.framework; sourceTree = SDKROOT; };
|
||||||
9A5D2495170A94DA0030D4DD /* SpineExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SpineExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
9A5D2495170A94DA0030D4DD /* SpineExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SpineExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
9A5D2498170A94DA0030D4DD /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
|
9A5D2498170A94DA0030D4DD /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
|
||||||
@ -309,7 +306,6 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
766ECCEA27EDFC110074EA8B /* Sequence.c */,
|
766ECCEA27EDFC110074EA8B /* Sequence.c */,
|
||||||
76FB15191F01413B00C5377F /* VertexEffect.c */,
|
|
||||||
76EE4E421EB36DE6000254F4 /* Array.c */,
|
76EE4E421EB36DE6000254F4 /* Array.c */,
|
||||||
76EE4E431EB36DE6000254F4 /* ClippingAttachment.c */,
|
76EE4E431EB36DE6000254F4 /* ClippingAttachment.c */,
|
||||||
76EE4E441EB36DE6000254F4 /* SkeletonClipping.c */,
|
76EE4E441EB36DE6000254F4 /* SkeletonClipping.c */,
|
||||||
@ -333,7 +329,6 @@
|
|||||||
76F28D021DEC810300CDE54D /* IkConstraintData.c */,
|
76F28D021DEC810300CDE54D /* IkConstraintData.c */,
|
||||||
76F28D031DEC810300CDE54D /* Json.c */,
|
76F28D031DEC810300CDE54D /* Json.c */,
|
||||||
76F28D041DEC810300CDE54D /* Json.h */,
|
76F28D041DEC810300CDE54D /* Json.h */,
|
||||||
76F28D051DEC810300CDE54D /* kvec.h */,
|
|
||||||
76F28D061DEC810300CDE54D /* MeshAttachment.c */,
|
76F28D061DEC810300CDE54D /* MeshAttachment.c */,
|
||||||
76F28D071DEC810300CDE54D /* PathAttachment.c */,
|
76F28D071DEC810300CDE54D /* PathAttachment.c */,
|
||||||
76F28D081DEC810300CDE54D /* PathConstraint.c */,
|
76F28D081DEC810300CDE54D /* PathConstraint.c */,
|
||||||
@ -610,7 +605,6 @@
|
|||||||
76BF7E071E66ED9C00485998 /* GLUtils.c in Sources */,
|
76BF7E071E66ED9C00485998 /* GLUtils.c in Sources */,
|
||||||
76EE4E481EB36DE6000254F4 /* SkeletonClipping.c in Sources */,
|
76EE4E481EB36DE6000254F4 /* SkeletonClipping.c in Sources */,
|
||||||
43C3282F170B0C19004A9460 /* spine-cocos2d-objc.m in Sources */,
|
43C3282F170B0C19004A9460 /* spine-cocos2d-objc.m in Sources */,
|
||||||
76FB151A1F01413B00C5377F /* VertexEffect.c in Sources */,
|
|
||||||
76F28D1F1DEC810300CDE54D /* BoundingBoxAttachment.c in Sources */,
|
76F28D1F1DEC810300CDE54D /* BoundingBoxAttachment.c in Sources */,
|
||||||
76F28D281DEC810300CDE54D /* PathConstraint.c in Sources */,
|
76F28D281DEC810300CDE54D /* PathConstraint.c in Sources */,
|
||||||
76F28D2F1DEC810300CDE54D /* SkeletonJson.c in Sources */,
|
76F28D2F1DEC810300CDE54D /* SkeletonJson.c in Sources */,
|
||||||
|
|||||||
@ -46,7 +46,6 @@
|
|||||||
float* _worldVertices;
|
float* _worldVertices;
|
||||||
CCBlendMode* screenMode;
|
CCBlendMode* screenMode;
|
||||||
spSkeletonClipping* _clipper;
|
spSkeletonClipping* _clipper;
|
||||||
spVertexEffect* _effect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id) skeletonWithData:(spSkeletonData*)skeletonData ownsSkeletonData:(bool)ownsSkeletonData;
|
+ (id) skeletonWithData:(spSkeletonData*)skeletonData ownsSkeletonData:(bool)ownsSkeletonData;
|
||||||
@ -90,6 +89,5 @@
|
|||||||
@property (nonatomic) bool debugBones;
|
@property (nonatomic) bool debugBones;
|
||||||
@property (nonatomic) bool skipVisibilityCheck;
|
@property (nonatomic) bool skipVisibilityCheck;
|
||||||
@property (nonatomic) spBone* rootBone;
|
@property (nonatomic) spBone* rootBone;
|
||||||
@property (nonatomic) spVertexEffect* effect;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -49,7 +49,6 @@ static bool handlerQueued = false;
|
|||||||
@synthesize twoColorTint = _twoColorTint;
|
@synthesize twoColorTint = _twoColorTint;
|
||||||
@synthesize debugSlots = _debugSlots;
|
@synthesize debugSlots = _debugSlots;
|
||||||
@synthesize debugBones = _debugBones;
|
@synthesize debugBones = _debugBones;
|
||||||
@synthesize effect = _effect;
|
|
||||||
|
|
||||||
+ (id) skeletonWithData:(spSkeletonData*)skeletonData ownsSkeletonData:(bool)ownsSkeletonData {
|
+ (id) skeletonWithData:(spSkeletonData*)skeletonData ownsSkeletonData:(bool)ownsSkeletonData {
|
||||||
return [[[self alloc] initWithData:skeletonData ownsSkeletonData:ownsSkeletonData] autorelease];
|
return [[[self alloc] initWithData:skeletonData ownsSkeletonData:ownsSkeletonData] autorelease];
|
||||||
@ -91,7 +90,6 @@ static bool handlerQueued = false;
|
|||||||
];
|
];
|
||||||
|
|
||||||
_clipper = spSkeletonClipping_create();
|
_clipper = spSkeletonClipping_create();
|
||||||
_effect = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithData:(spSkeletonData*)skeletonData ownsSkeletonData:(bool)ownsSkeletonData {
|
- (id) initWithData:(spSkeletonData*)skeletonData ownsSkeletonData:(bool)ownsSkeletonData {
|
||||||
@ -174,8 +172,6 @@ static bool handlerQueued = false;
|
|||||||
handlerQueued = true;
|
handlerQueued = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_effect) _effect->begin(_effect, _skeleton);
|
|
||||||
|
|
||||||
CCColor* nodeColor = self.color;
|
CCColor* nodeColor = self.color;
|
||||||
_skeleton->color.r = nodeColor.red;
|
_skeleton->color.r = nodeColor.red;
|
||||||
_skeleton->color.g = nodeColor.green;
|
_skeleton->color.g = nodeColor.green;
|
||||||
@ -303,20 +299,6 @@ static bool handlerQueued = false;
|
|||||||
vertex.position = GLKVector4Make(vertices[i * 2], vertices[i * 2 + 1], 0.0, 1.0);
|
vertex.position = GLKVector4Make(vertices[i * 2], vertices[i * 2 + 1], 0.0, 1.0);
|
||||||
vertex.color = GLKVector4Make(r, g, b, a);
|
vertex.color = GLKVector4Make(r, g, b, a);
|
||||||
vertex.texCoord1 = GLKVector2Make(uvs[i * 2], 1 - uvs[i * 2 + 1]);
|
vertex.texCoord1 = GLKVector2Make(uvs[i * 2], 1 - uvs[i * 2 + 1]);
|
||||||
if (_effect) {
|
|
||||||
spColor light;
|
|
||||||
spColor dark;
|
|
||||||
light.r = r;
|
|
||||||
light.g = g;
|
|
||||||
light.b = b;
|
|
||||||
light.a = a;
|
|
||||||
dark.r = dark.g = dark.b = dark.a = 0;
|
|
||||||
_effect->transform(_effect, &vertex.position.x, &vertex.position.y, &vertex.texCoord1.s, &vertex.texCoord1.t, &light, &dark);
|
|
||||||
vertex.color.r = light.r;
|
|
||||||
vertex.color.g = light.g;
|
|
||||||
vertex.color.b = light.b;
|
|
||||||
vertex.color.a = light.a;
|
|
||||||
}
|
|
||||||
CCRenderBufferSetVertex(buffer, i, CCVertexApplyTransform(vertex, transform));
|
CCRenderBufferSetVertex(buffer, i, CCVertexApplyTransform(vertex, transform));
|
||||||
}
|
}
|
||||||
for (int j = 0; j * 3 < trianglesCount; ++j) {
|
for (int j = 0; j * 3 < trianglesCount; ++j) {
|
||||||
@ -337,51 +319,19 @@ static bool handlerQueued = false;
|
|||||||
spVertex* verts = &meshPart.mesh->vertices[meshPart.startVertex];
|
spVertex* verts = &meshPart.mesh->vertices[meshPart.startVertex];
|
||||||
unsigned short* indices = &meshPart.mesh->indices[meshPart.startIndex];
|
unsigned short* indices = &meshPart.mesh->indices[meshPart.startIndex];
|
||||||
|
|
||||||
if (_effect) {
|
for (int i = 0; i * 2 < verticesCount; i++, verts++) {
|
||||||
spColor light;
|
CCVertex vertex;
|
||||||
light.r = r;
|
vertex.position = GLKVector4Make(vertices[i * 2], vertices[i * 2 + 1], 0.0, 1.0);
|
||||||
light.g = g;
|
vertex = CCVertexApplyTransform(vertex, transform);
|
||||||
light.b = b;
|
verts->x = vertex.position.x;
|
||||||
light.a = a;
|
verts->y = vertex.position.y;
|
||||||
spColor dark;
|
verts->z = vertex.position.z;
|
||||||
dark.r = dr;
|
verts->w = vertex.position.w;
|
||||||
dark.g = dg;
|
verts->color = ((unsigned short)(r * 255))| ((unsigned short)(g * 255)) << 8 | ((unsigned short)(b * 255)) <<16 | ((unsigned short)(a * 255)) << 24;
|
||||||
dark.b = db;
|
verts->color2 = ((unsigned short)(dr * 255)) | ((unsigned short)(dg * 255)) << 8 | ((unsigned short)(db * 255)) << 16 | ((unsigned short)(da * 255)) << 24;
|
||||||
dark.a = da;
|
verts->u = uvs[i * 2];
|
||||||
for (int i = 0; i * 2 < verticesCount; i++, verts++) {
|
verts->v = 1 - uvs[i * 2 + 1];
|
||||||
spColor lightCopy = light;
|
}
|
||||||
spColor darkCopy = dark;
|
|
||||||
|
|
||||||
CCVertex vertex;
|
|
||||||
vertex.position = GLKVector4Make(vertices[i * 2], vertices[i * 2 + 1], 0.0, 1.0);
|
|
||||||
verts->u = uvs[i * 2];
|
|
||||||
verts->v = 1 - uvs[i * 2 + 1];
|
|
||||||
_effect->transform(_effect, &vertex.position.x, &vertex.position.y, &verts->u, &verts->v, &lightCopy, &darkCopy);
|
|
||||||
|
|
||||||
vertex = CCVertexApplyTransform(vertex, transform);
|
|
||||||
verts->x = vertex.position.x;
|
|
||||||
verts->y = vertex.position.y;
|
|
||||||
verts->z = vertex.position.z;
|
|
||||||
verts->w = vertex.position.w;
|
|
||||||
verts->color = ((unsigned short)(lightCopy.r * 255))| ((unsigned short)(lightCopy.g * 255)) << 8 | ((unsigned short)(lightCopy.b * 255)) <<16 | ((unsigned short)(lightCopy.a * 255)) << 24;
|
|
||||||
verts->color2 = ((unsigned short)(darkCopy.r * 255)) | ((unsigned short)(darkCopy.g * 255)) << 8 | ((unsigned short)(darkCopy.b * 255)) << 16 | ((unsigned short)(darkCopy.a * 255)) << 24;
|
|
||||||
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (int i = 0; i * 2 < verticesCount; i++, verts++) {
|
|
||||||
CCVertex vertex;
|
|
||||||
vertex.position = GLKVector4Make(vertices[i * 2], vertices[i * 2 + 1], 0.0, 1.0);
|
|
||||||
vertex = CCVertexApplyTransform(vertex, transform);
|
|
||||||
verts->x = vertex.position.x;
|
|
||||||
verts->y = vertex.position.y;
|
|
||||||
verts->z = vertex.position.z;
|
|
||||||
verts->w = vertex.position.w;
|
|
||||||
verts->color = ((unsigned short)(r * 255))| ((unsigned short)(g * 255)) << 8 | ((unsigned short)(b * 255)) <<16 | ((unsigned short)(a * 255)) << 24;
|
|
||||||
verts->color2 = ((unsigned short)(dr * 255)) | ((unsigned short)(dg * 255)) << 8 | ((unsigned short)(db * 255)) << 16 | ((unsigned short)(da * 255)) << 24;
|
|
||||||
verts->u = uvs[i * 2];
|
|
||||||
verts->v = 1 - uvs[i * 2 + 1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j = 0; j < trianglesCount; j++, indices++) {
|
for (int j = 0; j < trianglesCount; j++, indices++) {
|
||||||
*indices = triangles[j];
|
*indices = triangles[j];
|
||||||
@ -439,8 +389,6 @@ static bool handlerQueued = false;
|
|||||||
if (i == 0) [_drawNode drawDot:ccp(bone->worldX, bone->worldY) radius:4 color:[CCColor blueColor]];
|
if (i == 0) [_drawNode drawDot:ccp(bone->worldX, bone->worldY) radius:4 color:[CCColor blueColor]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_effect) _effect->end(_effect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CCTexture*) getTextureForRegion:(spRegionAttachment*)attachment {
|
- (CCTexture*) getTextureForRegion:(spRegionAttachment*)attachment {
|
||||||
|
|||||||
@ -36,7 +36,6 @@ using namespace spine;
|
|||||||
|
|
||||||
PowInterpolation pow2(2);
|
PowInterpolation pow2(2);
|
||||||
PowOutInterpolation powOut2(2);
|
PowOutInterpolation powOut2(2);
|
||||||
SwirlVertexEffect effect(400, powOut2);
|
|
||||||
|
|
||||||
Scene *RaptorExample::scene() {
|
Scene *RaptorExample::scene() {
|
||||||
Scene *scene = Scene::create();
|
Scene *scene = Scene::create();
|
||||||
@ -52,10 +51,6 @@ bool RaptorExample::init() {
|
|||||||
skeletonNode->addAnimation(1, "gun-grab", false, 2);
|
skeletonNode->addAnimation(1, "gun-grab", false, 2);
|
||||||
skeletonNode->setTwoColorTint(true);
|
skeletonNode->setTwoColorTint(true);
|
||||||
|
|
||||||
effect.setCenterY(200);
|
|
||||||
swirlTime = 0;
|
|
||||||
|
|
||||||
skeletonNode->setVertexEffect(&effect);
|
|
||||||
|
|
||||||
skeletonNode->setPosition(Vec2(_contentSize.width / 2, 20));
|
skeletonNode->setPosition(Vec2(_contentSize.width / 2, 20));
|
||||||
addChild(skeletonNode);
|
addChild(skeletonNode);
|
||||||
@ -77,10 +72,3 @@ bool RaptorExample::init() {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RaptorExample::update(float fDelta) {
|
|
||||||
swirlTime += fDelta;
|
|
||||||
float percent = spine::MathUtil::fmod(swirlTime, 2);
|
|
||||||
if (percent > 1) percent = 1 - (percent - 1);
|
|
||||||
effect.setAngle(pow2.interpolate(-60.0f, 60.0f, percent));
|
|
||||||
}
|
|
||||||
|
|||||||
@ -41,8 +41,6 @@ public:
|
|||||||
|
|
||||||
virtual bool init();
|
virtual bool init();
|
||||||
|
|
||||||
virtual void update(float fDelta);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
spine::SkeletonAnimation *skeletonNode;
|
spine::SkeletonAnimation *skeletonNode;
|
||||||
float swirlTime;
|
float swirlTime;
|
||||||
|
|||||||
@ -137,26 +137,26 @@ namespace spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkeletonRenderer::SkeletonRenderer()
|
SkeletonRenderer::SkeletonRenderer()
|
||||||
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _effect(nullptr), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SkeletonRenderer::SkeletonRenderer(Skeleton *skeleton, bool ownsSkeleton, bool ownsSkeletonData, bool ownsAtlas)
|
SkeletonRenderer::SkeletonRenderer(Skeleton *skeleton, bool ownsSkeleton, bool ownsSkeletonData, bool ownsAtlas)
|
||||||
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _effect(nullptr), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
||||||
initWithSkeleton(skeleton, ownsSkeleton, ownsSkeletonData, ownsAtlas);
|
initWithSkeleton(skeleton, ownsSkeleton, ownsSkeletonData, ownsAtlas);
|
||||||
}
|
}
|
||||||
|
|
||||||
SkeletonRenderer::SkeletonRenderer(SkeletonData *skeletonData, bool ownsSkeletonData)
|
SkeletonRenderer::SkeletonRenderer(SkeletonData *skeletonData, bool ownsSkeletonData)
|
||||||
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _effect(nullptr), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
||||||
initWithData(skeletonData, ownsSkeletonData);
|
initWithData(skeletonData, ownsSkeletonData);
|
||||||
}
|
}
|
||||||
|
|
||||||
SkeletonRenderer::SkeletonRenderer(const std::string &skeletonDataFile, Atlas *atlas, float scale)
|
SkeletonRenderer::SkeletonRenderer(const std::string &skeletonDataFile, Atlas *atlas, float scale)
|
||||||
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _effect(nullptr), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
||||||
initWithJsonFile(skeletonDataFile, atlas, scale);
|
initWithJsonFile(skeletonDataFile, atlas, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
SkeletonRenderer::SkeletonRenderer(const std::string &skeletonDataFile, const std::string &atlasFile, float scale)
|
SkeletonRenderer::SkeletonRenderer(const std::string &skeletonDataFile, const std::string &atlasFile, float scale)
|
||||||
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _effect(nullptr), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
: _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
||||||
initWithJsonFile(skeletonDataFile, atlasFile, scale);
|
initWithJsonFile(skeletonDataFile, atlasFile, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,10 +280,6 @@ namespace spine {
|
|||||||
SkeletonTwoColorBatch *twoColorBatch = SkeletonTwoColorBatch::getInstance();
|
SkeletonTwoColorBatch *twoColorBatch = SkeletonTwoColorBatch::getInstance();
|
||||||
const bool hasSingleTint = (isTwoColorTint() == false);
|
const bool hasSingleTint = (isTwoColorTint() == false);
|
||||||
|
|
||||||
if (_effect) {
|
|
||||||
_effect->begin(*_skeleton);
|
|
||||||
}
|
|
||||||
|
|
||||||
const Color3B displayedColor = getDisplayedColor();
|
const Color3B displayedColor = getDisplayedColor();
|
||||||
Color nodeColor;
|
Color nodeColor;
|
||||||
nodeColor.r = displayedColor.r / 255.f;
|
nodeColor.r = displayedColor.r / 255.f;
|
||||||
@ -437,28 +433,14 @@ namespace spine {
|
|||||||
|
|
||||||
const float *verts = _clipper->getClippedVertices().buffer();
|
const float *verts = _clipper->getClippedVertices().buffer();
|
||||||
const float *uvs = _clipper->getClippedUVs().buffer();
|
const float *uvs = _clipper->getClippedUVs().buffer();
|
||||||
if (_effect) {
|
V3F_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
||||||
V3F_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2, ++vertex) {
|
||||||
Color darkTmp;
|
vertex->vertices.x = verts[vv];
|
||||||
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2, ++vertex) {
|
vertex->vertices.y = verts[vv + 1];
|
||||||
Color lightCopy = color;
|
vertex->texCoords.u = uvs[vv];
|
||||||
vertex->vertices.x = verts[vv];
|
vertex->texCoords.v = uvs[vv + 1];
|
||||||
vertex->vertices.y = verts[vv + 1];
|
vertex->colors = color4B;
|
||||||
vertex->texCoords.u = uvs[vv];
|
}
|
||||||
vertex->texCoords.v = uvs[vv + 1];
|
|
||||||
_effect->transform(vertex->vertices.x, vertex->vertices.y, vertex->texCoords.u, vertex->texCoords.v, lightCopy, darkTmp);
|
|
||||||
vertex->colors = ColorToColor4B(lightCopy);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
V3F_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
||||||
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2, ++vertex) {
|
|
||||||
vertex->vertices.x = verts[vv];
|
|
||||||
vertex->vertices.y = verts[vv + 1];
|
|
||||||
vertex->texCoords.u = uvs[vv];
|
|
||||||
vertex->texCoords.v = uvs[vv + 1];
|
|
||||||
vertex->colors = color4B;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Not clipping.
|
// Not clipping.
|
||||||
#if COCOS2D_VERSION < 0x00040000
|
#if COCOS2D_VERSION < 0x00040000
|
||||||
@ -466,21 +448,10 @@ namespace spine {
|
|||||||
#else
|
#else
|
||||||
cocos2d::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _programState, blendFunc, triangles, transform, transformFlags);
|
cocos2d::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _programState, blendFunc, triangles, transform, transformFlags);
|
||||||
#endif
|
#endif
|
||||||
|
V3F_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
||||||
if (_effect) {
|
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v, ++vertex) {
|
||||||
V3F_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
vertex->colors = color4B;
|
||||||
Color darkTmp;
|
}
|
||||||
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v, ++vertex) {
|
|
||||||
Color lightCopy = color;
|
|
||||||
_effect->transform(vertex->vertices.x, vertex->vertices.y, vertex->texCoords.u, vertex->texCoords.v, lightCopy, darkTmp);
|
|
||||||
vertex->colors = ColorToColor4B(lightCopy);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
V3F_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
||||||
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v, ++vertex) {
|
|
||||||
vertex->colors = color4B;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Two color tinting.
|
// Two color tinting.
|
||||||
@ -509,30 +480,15 @@ namespace spine {
|
|||||||
const float *verts = _clipper->getClippedVertices().buffer();
|
const float *verts = _clipper->getClippedVertices().buffer();
|
||||||
const float *uvs = _clipper->getClippedUVs().buffer();
|
const float *uvs = _clipper->getClippedUVs().buffer();
|
||||||
|
|
||||||
if (_effect) {
|
V3F_C4B_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
||||||
V3F_C4B_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2, ++vertex) {
|
||||||
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2, ++vertex) {
|
vertex->position.x = verts[vv];
|
||||||
Color lightCopy = color;
|
vertex->position.y = verts[vv + 1];
|
||||||
Color darkCopy = darkColor;
|
vertex->texCoords.u = uvs[vv];
|
||||||
vertex->position.x = verts[vv];
|
vertex->texCoords.v = uvs[vv + 1];
|
||||||
vertex->position.y = verts[vv + 1];
|
vertex->color = color4B;
|
||||||
vertex->texCoords.u = uvs[vv];
|
vertex->color2 = darkColor4B;
|
||||||
vertex->texCoords.v = uvs[vv + 1];
|
}
|
||||||
_effect->transform(vertex->position.x, vertex->position.y, vertex->texCoords.u, vertex->texCoords.v, lightCopy, darkCopy);
|
|
||||||
vertex->color = ColorToColor4B(lightCopy);
|
|
||||||
vertex->color2 = ColorToColor4B(darkCopy);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
V3F_C4B_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
||||||
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2, ++vertex) {
|
|
||||||
vertex->position.x = verts[vv];
|
|
||||||
vertex->position.y = verts[vv + 1];
|
|
||||||
vertex->texCoords.u = uvs[vv];
|
|
||||||
vertex->texCoords.v = uvs[vv + 1];
|
|
||||||
vertex->color = color4B;
|
|
||||||
vertex->color2 = darkColor4B;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
#if COCOS2D_VERSION < 0x00040000
|
#if COCOS2D_VERSION < 0x00040000
|
||||||
@ -541,22 +497,11 @@ namespace spine {
|
|||||||
TwoColorTrianglesCommand *batchedTriangles = lastTwoColorTrianglesCommand = twoColorBatch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _programState, blendFunc, trianglesTwoColor, transform, transformFlags);
|
TwoColorTrianglesCommand *batchedTriangles = lastTwoColorTrianglesCommand = twoColorBatch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _programState, blendFunc, trianglesTwoColor, transform, transformFlags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (_effect) {
|
V3F_C4B_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
||||||
V3F_C4B_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v, ++vertex) {
|
||||||
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v, ++vertex) {
|
vertex->color = color4B;
|
||||||
Color lightCopy = color;
|
vertex->color2 = darkColor4B;
|
||||||
Color darkCopy = darkColor;
|
}
|
||||||
_effect->transform(vertex->position.x, vertex->position.y, vertex->texCoords.u, vertex->texCoords.v, lightCopy, darkCopy);
|
|
||||||
vertex->color = ColorToColor4B(lightCopy);
|
|
||||||
vertex->color2 = ColorToColor4B(darkCopy);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
V3F_C4B_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
||||||
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v, ++vertex) {
|
|
||||||
vertex->color = color4B;
|
|
||||||
vertex->color2 = darkColor4B;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_clipper->clipEnd(*slot);
|
_clipper->clipEnd(*slot);
|
||||||
@ -597,8 +542,6 @@ namespace spine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_effect) _effect->end();
|
|
||||||
|
|
||||||
if (_debugBoundingRect || _debugSlots || _debugBones || _debugMeshes) {
|
if (_debugBoundingRect || _debugSlots || _debugBones || _debugMeshes) {
|
||||||
drawDebug(renderer, transform, transformFlags);
|
drawDebug(renderer, transform, transformFlags);
|
||||||
}
|
}
|
||||||
@ -797,10 +740,6 @@ namespace spine {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonRenderer::setVertexEffect(VertexEffect *effect) {
|
|
||||||
this->_effect = effect;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SkeletonRenderer::setSlotsRange(int startSlotIndex, int endSlotIndex) {
|
void SkeletonRenderer::setSlotsRange(int startSlotIndex, int endSlotIndex) {
|
||||||
_startSlotIndex = startSlotIndex == -1 ? 0 : startSlotIndex;
|
_startSlotIndex = startSlotIndex == -1 ? 0 : startSlotIndex;
|
||||||
_endSlotIndex = endSlotIndex == -1 ? std::numeric_limits<int>::max() : endSlotIndex;
|
_endSlotIndex = endSlotIndex == -1 ? std::numeric_limits<int>::max() : endSlotIndex;
|
||||||
|
|||||||
@ -102,9 +102,6 @@ namespace spine {
|
|||||||
/* Whether two color tinting is enabled */
|
/* Whether two color tinting is enabled */
|
||||||
bool isTwoColorTint();
|
bool isTwoColorTint();
|
||||||
|
|
||||||
/* Sets the vertex effect to be used, set to 0 to disable vertex effects */
|
|
||||||
void setVertexEffect(VertexEffect *effect);
|
|
||||||
|
|
||||||
/* Sets the range of slots that should be rendered. Use -1, -1 to clear the range */
|
/* Sets the range of slots that should be rendered. Use -1, -1 to clear the range */
|
||||||
void setSlotsRange(int startSlotIndex, int endSlotIndex);
|
void setSlotsRange(int startSlotIndex, int endSlotIndex);
|
||||||
|
|
||||||
@ -151,7 +148,6 @@ namespace spine {
|
|||||||
bool _debugMeshes;
|
bool _debugMeshes;
|
||||||
bool _debugBoundingRect;
|
bool _debugBoundingRect;
|
||||||
SkeletonClipping *_clipper;
|
SkeletonClipping *_clipper;
|
||||||
VertexEffect *_effect;
|
|
||||||
cocos2d::Rect _boundingRect;
|
cocos2d::Rect _boundingRect;
|
||||||
|
|
||||||
int _startSlotIndex;
|
int _startSlotIndex;
|
||||||
|
|||||||
@ -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 <spine/SpineObject.h>
|
|
||||||
#include <spine/MathUtil.h>
|
|
||||||
|
|
||||||
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 */
|
|
||||||
@ -105,7 +105,6 @@
|
|||||||
#include <spine/Updatable.h>
|
#include <spine/Updatable.h>
|
||||||
#include <spine/Vector.h>
|
#include <spine/Vector.h>
|
||||||
#include <spine/VertexAttachment.h>
|
#include <spine/VertexAttachment.h>
|
||||||
#include <spine/VertexEffect.h>
|
|
||||||
#include <spine/Vertices.h>
|
#include <spine/Vertices.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -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 <spine/VertexEffect.h>
|
|
||||||
#include <spine/MathUtil.h>
|
|
||||||
#include <spine/Skeleton.h>
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
@ -279,10 +279,6 @@ void raptor(spSkeletonData *skeletonData, spAtlas *atlas) {
|
|||||||
drawable->timeScale = 1;
|
drawable->timeScale = 1;
|
||||||
drawable->setUsePremultipliedAlpha(true);
|
drawable->setUsePremultipliedAlpha(true);
|
||||||
|
|
||||||
spSwirlVertexEffect *effect = spSwirlVertexEffect_create(400);
|
|
||||||
effect->centerY = -200;
|
|
||||||
drawable->vertexEffect = &effect->super;
|
|
||||||
|
|
||||||
spSkeleton *skeleton = drawable->skeleton;
|
spSkeleton *skeleton = drawable->skeleton;
|
||||||
skeleton->x = 320;
|
skeleton->x = 320;
|
||||||
skeleton->y = 590;
|
skeleton->y = 590;
|
||||||
@ -295,7 +291,6 @@ void raptor(spSkeletonData *skeletonData, spAtlas *atlas) {
|
|||||||
window.setFramerateLimit(60);
|
window.setFramerateLimit(60);
|
||||||
sf::Event event;
|
sf::Event event;
|
||||||
sf::Clock deltaClock;
|
sf::Clock deltaClock;
|
||||||
float swirlTime = 0;
|
|
||||||
while (window.isOpen()) {
|
while (window.isOpen()) {
|
||||||
while (window.pollEvent(event))
|
while (window.pollEvent(event))
|
||||||
if (event.type == sf::Event::Closed) window.close();
|
if (event.type == sf::Event::Closed) window.close();
|
||||||
@ -303,18 +298,12 @@ void raptor(spSkeletonData *skeletonData, spAtlas *atlas) {
|
|||||||
float delta = deltaClock.getElapsedTime().asSeconds();
|
float delta = deltaClock.getElapsedTime().asSeconds();
|
||||||
deltaClock.restart();
|
deltaClock.restart();
|
||||||
|
|
||||||
swirlTime += delta;
|
|
||||||
float percent = (float) fmod(swirlTime, 2);
|
|
||||||
if (percent > 1) percent = 1 - (percent - 1);
|
|
||||||
effect->angle = _spMath_interpolate(_spMath_pow2_apply, -60, 60, percent);
|
|
||||||
|
|
||||||
drawable->update(delta);
|
drawable->update(delta);
|
||||||
|
|
||||||
window.clear();
|
window.clear();
|
||||||
window.draw(*drawable);
|
window.draw(*drawable);
|
||||||
window.display();
|
window.display();
|
||||||
}
|
}
|
||||||
spSwirlVertexEffect_dispose(effect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tank(spSkeletonData *skeletonData, spAtlas *atlas) {
|
void tank(spSkeletonData *skeletonData, spAtlas *atlas) {
|
||||||
|
|||||||
@ -123,7 +123,6 @@ namespace spine {
|
|||||||
|
|
||||||
SkeletonDrawable::SkeletonDrawable(spSkeletonData *skeletonData, spAnimationStateData *stateData) : timeScale(1),
|
SkeletonDrawable::SkeletonDrawable(spSkeletonData *skeletonData, spAnimationStateData *stateData) : timeScale(1),
|
||||||
vertexArray(new VertexArray(Triangles, skeletonData->bonesCount * 4)),
|
vertexArray(new VertexArray(Triangles, skeletonData->bonesCount * 4)),
|
||||||
vertexEffect(0),
|
|
||||||
worldVertices(0), clipper(0) {
|
worldVertices(0), clipper(0) {
|
||||||
spBone_setYDown(true);
|
spBone_setYDown(true);
|
||||||
worldVertices = MALLOC(float, SPINE_MESH_VERTEX_COUNT_MAX);
|
worldVertices = MALLOC(float, SPINE_MESH_VERTEX_COUNT_MAX);
|
||||||
@ -164,8 +163,6 @@ namespace spine {
|
|||||||
// Early out if skeleton is invisible
|
// Early out if skeleton is invisible
|
||||||
if (skeleton->color.a == 0) return;
|
if (skeleton->color.a == 0) return;
|
||||||
|
|
||||||
if (vertexEffect != 0) vertexEffect->begin(vertexEffect, skeleton);
|
|
||||||
|
|
||||||
sf::Vertex vertex;
|
sf::Vertex vertex;
|
||||||
Texture *texture = 0;
|
Texture *texture = 0;
|
||||||
for (int i = 0; i < skeleton->slotsCount; ++i) {
|
for (int i = 0; i < skeleton->slotsCount; ++i) {
|
||||||
@ -300,56 +297,19 @@ namespace spine {
|
|||||||
|
|
||||||
Vector2u size = texture->getSize();
|
Vector2u size = texture->getSize();
|
||||||
|
|
||||||
if (vertexEffect != 0) {
|
for (int j = 0; j < indicesCount; ++j) {
|
||||||
spFloatArray_clear(tempUvs);
|
int index = indices[j] << 1;
|
||||||
spColorArray_clear(tempColors);
|
vertex.position.x = vertices[index];
|
||||||
for (int j = 0; j < verticesCount; j++) {
|
vertex.position.y = vertices[index + 1];
|
||||||
spColor vertexColor = light;
|
vertex.texCoords.x = uvs[index] * size.x;
|
||||||
spColor dark;
|
vertex.texCoords.y = uvs[index + 1] * size.y;
|
||||||
dark.r = dark.g = dark.b = dark.a = 0;
|
vertexArray->append(vertex);
|
||||||
int index = j << 1;
|
|
||||||
float x = vertices[index];
|
|
||||||
float y = vertices[index + 1];
|
|
||||||
float u = uvs[index];
|
|
||||||
float v = uvs[index + 1];
|
|
||||||
vertexEffect->transform(vertexEffect, &x, &y, &u, &v, &vertexColor, &dark);
|
|
||||||
vertices[index] = x;
|
|
||||||
vertices[index + 1] = y;
|
|
||||||
spFloatArray_add(tempUvs, u);
|
|
||||||
spFloatArray_add(tempUvs, v);
|
|
||||||
spColorArray_add(tempColors, vertexColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j = 0; j < indicesCount; ++j) {
|
|
||||||
int index = indices[j] << 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;
|
|
||||||
spColor vertexColor = tempColors->items[index >> 1];
|
|
||||||
vertex.color.r = static_cast<Uint8>(vertexColor.r * 255);
|
|
||||||
vertex.color.g = static_cast<Uint8>(vertexColor.g * 255);
|
|
||||||
vertex.color.b = static_cast<Uint8>(vertexColor.b * 255);
|
|
||||||
vertex.color.a = static_cast<Uint8>(vertexColor.a * 255);
|
|
||||||
vertexArray->append(vertex);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (int j = 0; j < indicesCount; ++j) {
|
|
||||||
int index = indices[j] << 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spSkeletonClipping_clipEnd(clipper, slot);
|
spSkeletonClipping_clipEnd(clipper, slot);
|
||||||
}
|
}
|
||||||
target.draw(*vertexArray, states);
|
target.draw(*vertexArray, states);
|
||||||
spSkeletonClipping_clipEnd2(clipper);
|
spSkeletonClipping_clipEnd2(clipper);
|
||||||
|
|
||||||
if (vertexEffect != 0) vertexEffect->end(vertexEffect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace spine */
|
} /* namespace spine */
|
||||||
|
|||||||
@ -48,7 +48,6 @@ namespace spine {
|
|||||||
spAnimationState *state;
|
spAnimationState *state;
|
||||||
float timeScale;
|
float timeScale;
|
||||||
sf::VertexArray *vertexArray;
|
sf::VertexArray *vertexArray;
|
||||||
spVertexEffect *vertexEffect;
|
|
||||||
|
|
||||||
SkeletonDrawable(spSkeletonData *skeleton, spAnimationStateData *stateData = 0);
|
SkeletonDrawable(spSkeletonData *skeleton, spAnimationStateData *stateData = 0);
|
||||||
~SkeletonDrawable();
|
~SkeletonDrawable();
|
||||||
|
|||||||
@ -278,9 +278,6 @@ void raptor(SkeletonData *skeletonData, Atlas *atlas) {
|
|||||||
|
|
||||||
PowInterpolation pow2(2);
|
PowInterpolation pow2(2);
|
||||||
PowOutInterpolation powOut2(2);
|
PowOutInterpolation powOut2(2);
|
||||||
SwirlVertexEffect effect(400, powOut2);
|
|
||||||
effect.setCenterY(-200);
|
|
||||||
drawable.vertexEffect = &effect;
|
|
||||||
|
|
||||||
Skeleton *skeleton = drawable.skeleton;
|
Skeleton *skeleton = drawable.skeleton;
|
||||||
skeleton->setPosition(320, 590);
|
skeleton->setPosition(320, 590);
|
||||||
@ -293,7 +290,6 @@ void raptor(SkeletonData *skeletonData, Atlas *atlas) {
|
|||||||
window.setFramerateLimit(60);
|
window.setFramerateLimit(60);
|
||||||
sf::Event event;
|
sf::Event event;
|
||||||
sf::Clock deltaClock;
|
sf::Clock deltaClock;
|
||||||
float swirlTime = 0;
|
|
||||||
while (window.isOpen()) {
|
while (window.isOpen()) {
|
||||||
while (window.pollEvent(event))
|
while (window.pollEvent(event))
|
||||||
if (event.type == sf::Event::Closed) window.close();
|
if (event.type == sf::Event::Closed) window.close();
|
||||||
@ -301,11 +297,6 @@ void raptor(SkeletonData *skeletonData, Atlas *atlas) {
|
|||||||
float delta = deltaClock.getElapsedTime().asSeconds();
|
float delta = deltaClock.getElapsedTime().asSeconds();
|
||||||
deltaClock.restart();
|
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);
|
drawable.update(delta);
|
||||||
|
|
||||||
window.clear();
|
window.clear();
|
||||||
|
|||||||
@ -49,7 +49,7 @@ namespace spine {
|
|||||||
|
|
||||||
SkeletonDrawable::SkeletonDrawable(SkeletonData *skeletonData, AnimationStateData *stateData) : timeScale(1),
|
SkeletonDrawable::SkeletonDrawable(SkeletonData *skeletonData, AnimationStateData *stateData) : timeScale(1),
|
||||||
vertexArray(new VertexArray(Triangles, skeletonData->getBones().size() * 4)),
|
vertexArray(new VertexArray(Triangles, skeletonData->getBones().size() * 4)),
|
||||||
vertexEffect(NULL), worldVertices(), clipper() {
|
worldVertices(), clipper() {
|
||||||
Bone::setYDown(true);
|
Bone::setYDown(true);
|
||||||
worldVertices.ensureCapacity(SPINE_MESH_VERTEX_COUNT_MAX);
|
worldVertices.ensureCapacity(SPINE_MESH_VERTEX_COUNT_MAX);
|
||||||
skeleton = new (__FILE__, __LINE__) Skeleton(skeletonData);
|
skeleton = new (__FILE__, __LINE__) Skeleton(skeletonData);
|
||||||
@ -89,8 +89,6 @@ namespace spine {
|
|||||||
// Early out if skeleton is invisible
|
// Early out if skeleton is invisible
|
||||||
if (skeleton->getColor().a == 0) return;
|
if (skeleton->getColor().a == 0) return;
|
||||||
|
|
||||||
if (vertexEffect != NULL) vertexEffect->begin(*skeleton);
|
|
||||||
|
|
||||||
sf::Vertex vertex;
|
sf::Vertex vertex;
|
||||||
Texture *texture = NULL;
|
Texture *texture = NULL;
|
||||||
for (unsigned i = 0; i < skeleton->getSlots().size(); ++i) {
|
for (unsigned i = 0; i < skeleton->getSlots().size(); ++i) {
|
||||||
@ -226,55 +224,18 @@ namespace spine {
|
|||||||
|
|
||||||
Vector2u size = texture->getSize();
|
Vector2u size = texture->getSize();
|
||||||
|
|
||||||
if (vertexEffect != 0) {
|
for (int ii = 0; ii < indicesCount; ++ii) {
|
||||||
tempUvs.clear();
|
int index = (*indices)[ii] << 1;
|
||||||
tempColors.clear();
|
vertex.position.x = (*vertices)[index];
|
||||||
for (int ii = 0; ii < verticesCount; ii++) {
|
vertex.position.y = (*vertices)[index + 1];
|
||||||
Color vertexColor = light;
|
vertex.texCoords.x = (*uvs)[index] * size.x;
|
||||||
Color dark;
|
vertex.texCoords.y = (*uvs)[index + 1] * size.y;
|
||||||
dark.r = dark.g = dark.b = dark.a = 0;
|
vertexArray->append(vertex);
|
||||||
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<Uint8>(vertexColor.r * 255);
|
|
||||||
vertex.color.g = static_cast<Uint8>(vertexColor.g * 255);
|
|
||||||
vertex.color.b = static_cast<Uint8>(vertexColor.b * 255);
|
|
||||||
vertex.color.a = static_cast<Uint8>(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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
clipper.clipEnd(slot);
|
clipper.clipEnd(slot);
|
||||||
}
|
}
|
||||||
target.draw(*vertexArray, states);
|
target.draw(*vertexArray, states);
|
||||||
clipper.clipEnd();
|
clipper.clipEnd();
|
||||||
|
|
||||||
if (vertexEffect != 0) vertexEffect->end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SFMLTextureLoader::load(AtlasPage &page, const String &path) {
|
void SFMLTextureLoader::load(AtlasPage &page, const String &path) {
|
||||||
|
|||||||
@ -46,10 +46,10 @@ namespace spine {
|
|||||||
AnimationState *state;
|
AnimationState *state;
|
||||||
float timeScale;
|
float timeScale;
|
||||||
sf::VertexArray *vertexArray;
|
sf::VertexArray *vertexArray;
|
||||||
VertexEffect *vertexEffect;
|
|
||||||
|
|
||||||
SkeletonDrawable(SkeletonData *skeleton, AnimationStateData *stateData = 0);
|
SkeletonDrawable(SkeletonData *skeleton, AnimationStateData *stateData = 0);
|
||||||
|
|
||||||
|
|
||||||
~SkeletonDrawable();
|
~SkeletonDrawable();
|
||||||
|
|
||||||
void update(float deltaTime);
|
void update(float deltaTime);
|
||||||
|
|||||||
@ -1,37 +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.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
import { Skeleton } from "./Skeleton";
|
|
||||||
import { Vector2, Color } from "./Utils";
|
|
||||||
|
|
||||||
export interface VertexEffect {
|
|
||||||
begin (skeleton: Skeleton): void;
|
|
||||||
transform (position: Vector2, uv: Vector2, light: Color, dark: Color): void;
|
|
||||||
end (): void;
|
|
||||||
}
|
|
||||||
@ -28,7 +28,6 @@ export * from './TransformConstraintData';
|
|||||||
export * from './Triangulator';
|
export * from './Triangulator';
|
||||||
export * from './Updatable';
|
export * from './Updatable';
|
||||||
export * from './Utils';
|
export * from './Utils';
|
||||||
export * from './VertexEffect';
|
|
||||||
export * from './polyfills';
|
export * from './polyfills';
|
||||||
export * from './attachments/Attachment';
|
export * from './attachments/Attachment';
|
||||||
export * from './attachments/AttachmentLoader';
|
export * from './attachments/AttachmentLoader';
|
||||||
@ -38,5 +37,3 @@ export * from './attachments/MeshAttachment';
|
|||||||
export * from './attachments/PathAttachment';
|
export * from './attachments/PathAttachment';
|
||||||
export * from './attachments/PointAttachment';
|
export * from './attachments/PointAttachment';
|
||||||
export * from './attachments/RegionAttachment';
|
export * from './attachments/RegionAttachment';
|
||||||
export * from './vertexeffects/JitterEffect';
|
|
||||||
export * from './vertexeffects/SwirlEffect';
|
|
||||||
|
|||||||
@ -1,53 +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.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
import { Skeleton } from "../Skeleton";
|
|
||||||
import { Vector2, Color, MathUtils } from "../Utils";
|
|
||||||
import { VertexEffect } from "../VertexEffect";
|
|
||||||
|
|
||||||
export class JitterEffect implements VertexEffect {
|
|
||||||
jitterX = 0;
|
|
||||||
jitterY = 0;
|
|
||||||
|
|
||||||
constructor (jitterX: number, jitterY: number) {
|
|
||||||
this.jitterX = jitterX;
|
|
||||||
this.jitterY = jitterY;
|
|
||||||
}
|
|
||||||
|
|
||||||
begin (skeleton: Skeleton): void {
|
|
||||||
}
|
|
||||||
|
|
||||||
transform (position: Vector2, uv: Vector2, light: Color, dark: Color): void {
|
|
||||||
position.x += MathUtils.randomTriangular(-this.jitterX, this.jitterY);
|
|
||||||
position.y += MathUtils.randomTriangular(-this.jitterX, this.jitterY);
|
|
||||||
}
|
|
||||||
|
|
||||||
end (): void {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,68 +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.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
import { Skeleton } from "../Skeleton";
|
|
||||||
import { PowOut, Vector2, Color, MathUtils } from "../Utils";
|
|
||||||
import { VertexEffect } from "../VertexEffect";
|
|
||||||
|
|
||||||
export class SwirlEffect implements VertexEffect {
|
|
||||||
static interpolation = new PowOut(2);
|
|
||||||
centerX = 0;
|
|
||||||
centerY = 0;
|
|
||||||
radius = 0;
|
|
||||||
angle = 0;
|
|
||||||
private worldX = 0;
|
|
||||||
private worldY = 0;
|
|
||||||
|
|
||||||
constructor (radius: number) {
|
|
||||||
this.radius = radius;
|
|
||||||
}
|
|
||||||
|
|
||||||
begin (skeleton: Skeleton): void {
|
|
||||||
this.worldX = skeleton.x + this.centerX;
|
|
||||||
this.worldY = skeleton.y + this.centerY;
|
|
||||||
}
|
|
||||||
|
|
||||||
transform (position: Vector2, uv: Vector2, light: Color, dark: Color): void {
|
|
||||||
let radAngle = this.angle * MathUtils.degreesToRadians;
|
|
||||||
let x = position.x - this.worldX;
|
|
||||||
let y = position.y - this.worldY;
|
|
||||||
let dist = Math.sqrt(x * x + y * y);
|
|
||||||
if (dist < this.radius) {
|
|
||||||
let theta = SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius);
|
|
||||||
let cos = Math.cos(theta);
|
|
||||||
let sin = Math.sin(theta);
|
|
||||||
position.x = cos * x - sin * y + this.worldX;
|
|
||||||
position.y = sin * x + cos * y + this.worldY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
end (): void {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -27,7 +27,7 @@
|
|||||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
import { AnimationState, AnimationStateData, BlendMode, ClippingAttachment, Color, MeshAttachment, NumberArrayLike, RegionAttachment, Skeleton, SkeletonClipping, SkeletonData, TextureAtlasRegion, Utils, Vector2, VertexEffect } from "@esotericsoftware/spine-core";
|
import { AnimationState, AnimationStateData, BlendMode, ClippingAttachment, Color, MeshAttachment, NumberArrayLike, RegionAttachment, Skeleton, SkeletonClipping, SkeletonData, TextureAtlasRegion, Utils, Vector2 } from "@esotericsoftware/spine-core";
|
||||||
import { MeshBatcher } from "./MeshBatcher";
|
import { MeshBatcher } from "./MeshBatcher";
|
||||||
import * as THREE from "three";
|
import * as THREE from "three";
|
||||||
import { ThreeJsTexture } from "./ThreeJsTexture";
|
import { ThreeJsTexture } from "./ThreeJsTexture";
|
||||||
@ -90,7 +90,6 @@ export class SkeletonMesh extends THREE.Object3D {
|
|||||||
skeleton: Skeleton;
|
skeleton: Skeleton;
|
||||||
state: AnimationState;
|
state: AnimationState;
|
||||||
zOffset: number = 0.1;
|
zOffset: number = 0.1;
|
||||||
vertexEffect: VertexEffect | null = null;
|
|
||||||
|
|
||||||
private batches = new Array<MeshBatcher>();
|
private batches = new Array<MeshBatcher>();
|
||||||
private nextBatchIndex = 0;
|
private nextBatchIndex = 0;
|
||||||
@ -224,61 +223,19 @@ export class SkeletonMesh extends THREE.Object3D {
|
|||||||
clipper.clipTriangles(vertices, numFloats, triangles, triangles.length, uvs, color, tempLight, false);
|
clipper.clipTriangles(vertices, numFloats, triangles, triangles.length, uvs, color, tempLight, false);
|
||||||
let clippedVertices = clipper.clippedVertices;
|
let clippedVertices = clipper.clippedVertices;
|
||||||
let clippedTriangles = clipper.clippedTriangles;
|
let clippedTriangles = clipper.clippedTriangles;
|
||||||
if (this.vertexEffect != null) {
|
|
||||||
let vertexEffect = this.vertexEffect;
|
|
||||||
let verts = clippedVertices;
|
|
||||||
for (let v = 0, n = clippedVertices.length; v < n; v += vertexSize) {
|
|
||||||
tempPos.x = verts[v];
|
|
||||||
tempPos.y = verts[v + 1];
|
|
||||||
tempLight.setFromColor(color);
|
|
||||||
tempDark.set(0, 0, 0, 0);
|
|
||||||
tempUv.x = verts[v + 6];
|
|
||||||
tempUv.y = verts[v + 7];
|
|
||||||
vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
|
|
||||||
verts[v] = tempPos.x;
|
|
||||||
verts[v + 1] = tempPos.y;
|
|
||||||
verts[v + 2] = tempLight.r;
|
|
||||||
verts[v + 3] = tempLight.g;
|
|
||||||
verts[v + 4] = tempLight.b;
|
|
||||||
verts[v + 5] = tempLight.a;
|
|
||||||
verts[v + 6] = tempUv.x;
|
|
||||||
verts[v + 7] = tempUv.y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finalVertices = clippedVertices;
|
finalVertices = clippedVertices;
|
||||||
finalVerticesLength = clippedVertices.length;
|
finalVerticesLength = clippedVertices.length;
|
||||||
finalIndices = clippedTriangles;
|
finalIndices = clippedTriangles;
|
||||||
finalIndicesLength = clippedTriangles.length;
|
finalIndicesLength = clippedTriangles.length;
|
||||||
} else {
|
} else {
|
||||||
let verts = vertices;
|
let verts = vertices;
|
||||||
if (this.vertexEffect != null) {
|
for (let v = 2, u = 0, n = numFloats; v < n; v += vertexSize, u += 2) {
|
||||||
let vertexEffect = this.vertexEffect;
|
verts[v] = color.r;
|
||||||
for (let v = 0, u = 0, n = numFloats; v < n; v += vertexSize, u += 2) {
|
verts[v + 1] = color.g;
|
||||||
tempPos.x = verts[v];
|
verts[v + 2] = color.b;
|
||||||
tempPos.y = verts[v + 1];
|
verts[v + 3] = color.a;
|
||||||
tempLight.setFromColor(color);
|
verts[v + 4] = uvs[u];
|
||||||
tempDark.set(0, 0, 0, 0);
|
verts[v + 5] = uvs[u + 1];
|
||||||
tempUv.x = uvs[u];
|
|
||||||
tempUv.y = uvs[u + 1];
|
|
||||||
vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
|
|
||||||
verts[v] = tempPos.x;
|
|
||||||
verts[v + 1] = tempPos.y;
|
|
||||||
verts[v + 2] = tempLight.r;
|
|
||||||
verts[v + 3] = tempLight.g;
|
|
||||||
verts[v + 4] = tempLight.b;
|
|
||||||
verts[v + 5] = tempLight.a;
|
|
||||||
verts[v + 6] = tempUv.x;
|
|
||||||
verts[v + 7] = tempUv.y;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (let v = 2, u = 0, n = numFloats; v < n; v += vertexSize, u += 2) {
|
|
||||||
verts[v] = color.r;
|
|
||||||
verts[v + 1] = color.g;
|
|
||||||
verts[v + 2] = color.b;
|
|
||||||
verts[v + 3] = color.a;
|
|
||||||
verts[v + 4] = uvs[u];
|
|
||||||
verts[v + 5] = uvs[u + 1];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finalVertices = vertices;
|
finalVertices = vertices;
|
||||||
finalVerticesLength = numFloats;
|
finalVerticesLength = numFloats;
|
||||||
|
|||||||
@ -27,7 +27,6 @@
|
|||||||
<span>Skeleton:</span><select id="skeletonList"></select>
|
<span>Skeleton:</span><select id="skeletonList"></select>
|
||||||
<span>Animation:</span><select id="animationList"></select>
|
<span>Animation:</span><select id="animationList"></select>
|
||||||
<span>Skin:</span><select id="skinList"></select>
|
<span>Skin:</span><select id="skinList"></select>
|
||||||
<span>Vertex Effect:</span><select id="effectList"></select>
|
|
||||||
<span>Debug:</span><input type="checkbox" id="debug">
|
<span>Debug:</span><input type="checkbox" id="debug">
|
||||||
</div>
|
</div>
|
||||||
</center>
|
</center>
|
||||||
@ -48,10 +47,6 @@
|
|||||||
let skeletons = {};
|
let skeletons = {};
|
||||||
let format = "JSON";
|
let format = "JSON";
|
||||||
let activeSkeleton = "spineboy";
|
let activeSkeleton = "spineboy";
|
||||||
let pow2 = new spine.Pow(2);
|
|
||||||
let swirlEffect = new spine.SwirlEffect(0);
|
|
||||||
let jitterEffect = new spine.JitterEffect(20, 20);
|
|
||||||
let swirlTime = 0;
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
// Create the managed WebGL context. Managed contexts will restore resources like shaders
|
// Create the managed WebGL context. Managed contexts will restore resources like shaders
|
||||||
@ -242,14 +237,6 @@
|
|||||||
if (skeletonName === activeSkeleton) option.attr("selected", "selected");
|
if (skeletonName === activeSkeleton) option.attr("selected", "selected");
|
||||||
skeletonList.append(option);
|
skeletonList.append(option);
|
||||||
}
|
}
|
||||||
let effectList = $("#effectList");
|
|
||||||
let effects = ["None", "Swirl", "Jitter"];
|
|
||||||
for (let effect in effects) {
|
|
||||||
let effectName = effects[effect];
|
|
||||||
let option = $("<option></option>");
|
|
||||||
option.attr("value", effectName).text(effectName);
|
|
||||||
effectList.append(option);
|
|
||||||
}
|
|
||||||
let setupAnimationUI = function () {
|
let setupAnimationUI = function () {
|
||||||
let animationList = $("#animationList");
|
let animationList = $("#animationList");
|
||||||
animationList.empty();
|
animationList.empty();
|
||||||
@ -339,21 +326,6 @@
|
|||||||
// Start the batch and tell the SkeletonRenderer to render the active skeleton.
|
// Start the batch and tell the SkeletonRenderer to render the active skeleton.
|
||||||
batcher.begin(shader);
|
batcher.begin(shader);
|
||||||
|
|
||||||
let effect = $("#effectList option:selected").text();
|
|
||||||
if (effect == "None") {
|
|
||||||
skeletonRenderer.vertexEffect = null;
|
|
||||||
} else if (effect == "Swirl") {
|
|
||||||
swirlTime += delta;
|
|
||||||
let percent = swirlTime % 2;
|
|
||||||
if (percent > 1) percent = 1 - (percent - 1);
|
|
||||||
swirlEffect.angle = pow2.apply(-60, 60, percent);
|
|
||||||
swirlEffect.centerX = bounds.offset.x + bounds.size.x / 2;
|
|
||||||
swirlEffect.centerY = bounds.offset.y + bounds.size.y / 2;
|
|
||||||
swirlEffect.radius = Math.sqrt(bounds.size.x * bounds.size.x + bounds.size.y * bounds.size.y) * 0.75;
|
|
||||||
skeletonRenderer.vertexEffect = swirlEffect;
|
|
||||||
} else if (effect == "Jitter")
|
|
||||||
skeletonRenderer.vertexEffect = jitterEffect;
|
|
||||||
|
|
||||||
skeletonRenderer.premultipliedAlpha = premultipliedAlpha;
|
skeletonRenderer.premultipliedAlpha = premultipliedAlpha;
|
||||||
skeletonRenderer.draw(batcher, skeleton);
|
skeletonRenderer.draw(batcher, skeleton);
|
||||||
batcher.end();
|
batcher.end();
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
import { NumberArrayLike, VertexEffect, Color, SkeletonClipping, Vector2, Utils, Skeleton, BlendMode, RegionAttachment, TextureAtlasRegion, MeshAttachment, ClippingAttachment } from "@esotericsoftware/spine-core";
|
import { NumberArrayLike, Color, SkeletonClipping, Vector2, Utils, Skeleton, BlendMode, RegionAttachment, TextureAtlasRegion, MeshAttachment, ClippingAttachment } from "@esotericsoftware/spine-core";
|
||||||
import { GLTexture } from "./GLTexture";
|
import { GLTexture } from "./GLTexture";
|
||||||
import { PolygonBatcher } from "./PolygonBatcher";
|
import { PolygonBatcher } from "./PolygonBatcher";
|
||||||
import { ManagedWebGLRenderingContext, WebGLBlendModeConverter } from "./WebGL";
|
import { ManagedWebGLRenderingContext, WebGLBlendModeConverter } from "./WebGL";
|
||||||
@ -41,7 +41,6 @@ export class SkeletonRenderer {
|
|||||||
static QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
|
static QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
|
||||||
|
|
||||||
premultipliedAlpha = false;
|
premultipliedAlpha = false;
|
||||||
vertexEffect: VertexEffect | null = null;
|
|
||||||
private tempColor = new Color();
|
private tempColor = new Color();
|
||||||
private tempColor2 = new Color();
|
private tempColor2 = new Color();
|
||||||
private vertices: NumberArrayLike;
|
private vertices: NumberArrayLike;
|
||||||
@ -175,120 +174,30 @@ export class SkeletonRenderer {
|
|||||||
clipper.clipTriangles(renderable.vertices, renderable.numFloats, triangles, triangles.length, uvs, finalColor, darkColor, twoColorTint);
|
clipper.clipTriangles(renderable.vertices, renderable.numFloats, triangles, triangles.length, uvs, finalColor, darkColor, twoColorTint);
|
||||||
let clippedVertices = new Float32Array(clipper.clippedVertices);
|
let clippedVertices = new Float32Array(clipper.clippedVertices);
|
||||||
let clippedTriangles = clipper.clippedTriangles;
|
let clippedTriangles = clipper.clippedTriangles;
|
||||||
if (this.vertexEffect) {
|
|
||||||
let vertexEffect = this.vertexEffect;
|
|
||||||
let verts = clippedVertices;
|
|
||||||
if (!twoColorTint) {
|
|
||||||
for (let v = 0, n = clippedVertices.length; v < n; v += vertexSize) {
|
|
||||||
tempPos.x = verts[v];
|
|
||||||
tempPos.y = verts[v + 1];
|
|
||||||
tempLight.set(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]);
|
|
||||||
tempUv.x = verts[v + 6];
|
|
||||||
tempUv.y = verts[v + 7];
|
|
||||||
tempDark.set(0, 0, 0, 0);
|
|
||||||
vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
|
|
||||||
verts[v] = tempPos.x;
|
|
||||||
verts[v + 1] = tempPos.y;
|
|
||||||
verts[v + 2] = tempLight.r;
|
|
||||||
verts[v + 3] = tempLight.g;
|
|
||||||
verts[v + 4] = tempLight.b;
|
|
||||||
verts[v + 5] = tempLight.a;
|
|
||||||
verts[v + 6] = tempUv.x;
|
|
||||||
verts[v + 7] = tempUv.y
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (let v = 0, n = clippedVertices.length; v < n; v += vertexSize) {
|
|
||||||
tempPos.x = verts[v];
|
|
||||||
tempPos.y = verts[v + 1];
|
|
||||||
tempLight.set(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]);
|
|
||||||
tempUv.x = verts[v + 6];
|
|
||||||
tempUv.y = verts[v + 7];
|
|
||||||
tempDark.set(verts[v + 8], verts[v + 9], verts[v + 10], verts[v + 11]);
|
|
||||||
vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
|
|
||||||
verts[v] = tempPos.x;
|
|
||||||
verts[v + 1] = tempPos.y;
|
|
||||||
verts[v + 2] = tempLight.r;
|
|
||||||
verts[v + 3] = tempLight.g;
|
|
||||||
verts[v + 4] = tempLight.b;
|
|
||||||
verts[v + 5] = tempLight.a;
|
|
||||||
verts[v + 6] = tempUv.x;
|
|
||||||
verts[v + 7] = tempUv.y
|
|
||||||
verts[v + 8] = tempDark.r;
|
|
||||||
verts[v + 9] = tempDark.g;
|
|
||||||
verts[v + 10] = tempDark.b;
|
|
||||||
verts[v + 11] = tempDark.a;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
batcher.draw(texture, clippedVertices, clippedTriangles);
|
batcher.draw(texture, clippedVertices, clippedTriangles);
|
||||||
} else {
|
} else {
|
||||||
let verts = renderable.vertices;
|
let verts = renderable.vertices;
|
||||||
if (this.vertexEffect) {
|
if (!twoColorTint) {
|
||||||
let vertexEffect = this.vertexEffect;
|
for (let v = 2, u = 0, n = renderable.numFloats; v < n; v += vertexSize, u += 2) {
|
||||||
if (!twoColorTint) {
|
verts[v] = finalColor.r;
|
||||||
for (let v = 0, u = 0, n = renderable.numFloats; v < n; v += vertexSize, u += 2) {
|
verts[v + 1] = finalColor.g;
|
||||||
tempPos.x = verts[v];
|
verts[v + 2] = finalColor.b;
|
||||||
tempPos.y = verts[v + 1];
|
verts[v + 3] = finalColor.a;
|
||||||
tempUv.x = uvs[u];
|
verts[v + 4] = uvs[u];
|
||||||
tempUv.y = uvs[u + 1]
|
verts[v + 5] = uvs[u + 1];
|
||||||
tempLight.setFromColor(finalColor);
|
|
||||||
tempDark.set(0, 0, 0, 0);
|
|
||||||
vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
|
|
||||||
verts[v] = tempPos.x;
|
|
||||||
verts[v + 1] = tempPos.y;
|
|
||||||
verts[v + 2] = tempLight.r;
|
|
||||||
verts[v + 3] = tempLight.g;
|
|
||||||
verts[v + 4] = tempLight.b;
|
|
||||||
verts[v + 5] = tempLight.a;
|
|
||||||
verts[v + 6] = tempUv.x;
|
|
||||||
verts[v + 7] = tempUv.y
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (let v = 0, u = 0, n = renderable.numFloats; v < n; v += vertexSize, u += 2) {
|
|
||||||
tempPos.x = verts[v];
|
|
||||||
tempPos.y = verts[v + 1];
|
|
||||||
tempUv.x = uvs[u];
|
|
||||||
tempUv.y = uvs[u + 1]
|
|
||||||
tempLight.setFromColor(finalColor);
|
|
||||||
tempDark.setFromColor(darkColor);
|
|
||||||
vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
|
|
||||||
verts[v] = tempPos.x;
|
|
||||||
verts[v + 1] = tempPos.y;
|
|
||||||
verts[v + 2] = tempLight.r;
|
|
||||||
verts[v + 3] = tempLight.g;
|
|
||||||
verts[v + 4] = tempLight.b;
|
|
||||||
verts[v + 5] = tempLight.a;
|
|
||||||
verts[v + 6] = tempUv.x;
|
|
||||||
verts[v + 7] = tempUv.y
|
|
||||||
verts[v + 8] = tempDark.r;
|
|
||||||
verts[v + 9] = tempDark.g;
|
|
||||||
verts[v + 10] = tempDark.b;
|
|
||||||
verts[v + 11] = tempDark.a;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!twoColorTint) {
|
for (let v = 2, u = 0, n = renderable.numFloats; v < n; v += vertexSize, u += 2) {
|
||||||
for (let v = 2, u = 0, n = renderable.numFloats; v < n; v += vertexSize, u += 2) {
|
verts[v] = finalColor.r;
|
||||||
verts[v] = finalColor.r;
|
verts[v + 1] = finalColor.g;
|
||||||
verts[v + 1] = finalColor.g;
|
verts[v + 2] = finalColor.b;
|
||||||
verts[v + 2] = finalColor.b;
|
verts[v + 3] = finalColor.a;
|
||||||
verts[v + 3] = finalColor.a;
|
verts[v + 4] = uvs[u];
|
||||||
verts[v + 4] = uvs[u];
|
verts[v + 5] = uvs[u + 1];
|
||||||
verts[v + 5] = uvs[u + 1];
|
verts[v + 6] = darkColor.r;
|
||||||
}
|
verts[v + 7] = darkColor.g;
|
||||||
} else {
|
verts[v + 8] = darkColor.b;
|
||||||
for (let v = 2, u = 0, n = renderable.numFloats; v < n; v += vertexSize, u += 2) {
|
verts[v + 9] = darkColor.a;
|
||||||
verts[v] = finalColor.r;
|
|
||||||
verts[v + 1] = finalColor.g;
|
|
||||||
verts[v + 2] = finalColor.b;
|
|
||||||
verts[v + 3] = finalColor.a;
|
|
||||||
verts[v + 4] = uvs[u];
|
|
||||||
verts[v + 5] = uvs[u + 1];
|
|
||||||
verts[v + 6] = darkColor.r;
|
|
||||||
verts[v + 7] = darkColor.g;
|
|
||||||
verts[v + 8] = darkColor.b;
|
|
||||||
verts[v + 9] = darkColor.a;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let view = (renderable.vertices as Float32Array).subarray(0, renderable.numFloats);
|
let view = (renderable.vertices as Float32Array).subarray(0, renderable.numFloats);
|
||||||
|
|||||||
@ -36,8 +36,6 @@
|
|||||||
var label = document.getElementById("label");
|
var label = document.getElementById("label");
|
||||||
var updateMean = new spine.WindowedMean();
|
var updateMean = new spine.WindowedMean();
|
||||||
var renderMean = new spine.WindowedMean();
|
var renderMean = new spine.WindowedMean();
|
||||||
var swirlEffect = new spine.SwirlEffect();
|
|
||||||
var swirlTime = 0;
|
|
||||||
var interpolation = new spine.Pow(2);
|
var interpolation = new spine.Pow(2);
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
@ -52,11 +50,6 @@
|
|||||||
renderer.skeletonDebugRenderer.drawMeshHull = false;
|
renderer.skeletonDebugRenderer.drawMeshHull = false;
|
||||||
renderer.skeletonDebugRenderer.drawRegionAttachments = false;
|
renderer.skeletonDebugRenderer.drawRegionAttachments = false;
|
||||||
renderer.skeletonDebugRenderer.drawBoundingBoxes = false;
|
renderer.skeletonDebugRenderer.drawBoundingBoxes = false;
|
||||||
renderer.skeletonRenderer.vertexEffect = swirlEffect;
|
|
||||||
|
|
||||||
swirlEffect.centerX = 0;
|
|
||||||
swirlEffect.centerY = 200;
|
|
||||||
swirlEffect.radius = 500;
|
|
||||||
|
|
||||||
assetManager = new spine.AssetManager(context, "../example/assets/");
|
assetManager = new spine.AssetManager(context, "../example/assets/");
|
||||||
input = new spine.Input(canvas);
|
input = new spine.Input(canvas);
|
||||||
@ -106,11 +99,6 @@
|
|||||||
var delta = timeKeeper.delta;
|
var delta = timeKeeper.delta;
|
||||||
delta = 0.016;
|
delta = 0.016;
|
||||||
|
|
||||||
swirlTime += delta;
|
|
||||||
var percent = swirlTime % 2;
|
|
||||||
if (percent > 1) percent = 1 - (percent - 1);
|
|
||||||
swirlEffect.angle = interpolation.apply(-60, 60, percent);
|
|
||||||
|
|
||||||
for (var i = 0; i < skeletons.length; i++) {
|
for (var i = 0; i < skeletons.length; i++) {
|
||||||
var state = skeletons[i].state;
|
var state = skeletons[i].state;
|
||||||
var skeleton = skeletons[i].skeleton;
|
var skeleton = skeletons[i].skeleton;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user