mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[cocos2d-objc] Removed VertexEffect, see #2076
This commit is contained in:
parent
ee1c698197
commit
276737f1fd
@ -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. 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
|
||||
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/`
|
||||
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
|
||||
|
||||
@ -30,8 +30,6 @@
|
||||
#import "RaptorExample.h"
|
||||
#import "TankExample.h"
|
||||
|
||||
spJitterVertexEffect* effect = 0;
|
||||
|
||||
@implementation RaptorExample
|
||||
|
||||
+ (CCScene*) scene {
|
||||
@ -44,11 +42,8 @@ spJitterVertexEffect* effect = 0;
|
||||
self = [super init];
|
||||
if (!self) return nil;
|
||||
|
||||
if (!effect) effect = spJitterVertexEffect_create(10, 10);
|
||||
|
||||
skeletonNode = [SkeletonAnimation skeletonWithFile:@"raptor-pro.json" atlasFile:@"raptor.atlas" scale:0.3f];
|
||||
[skeletonNode setAnimationForTrack:0 name:@"walk" loop:YES];
|
||||
[skeletonNode setEffect:&effect->super];
|
||||
|
||||
CGSize windowSize = [[CCDirector sharedDirector] viewSize];
|
||||
[skeletonNode setPosition:ccp(windowSize.width / 2, 20)];
|
||||
|
||||
@ -86,7 +86,6 @@
|
||||
76F5BDAD1D2BDFA2005917E5 /* TankExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 76F5BDAC1D2BDFA2005917E5 /* TankExample.m */; };
|
||||
76FAC1961E3FA15E001CCC8C /* Color.c in Sources */ = {isa = PBXBuildFile; fileRef = 76FAC1941E3FA15E001CCC8C /* Color.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 */; };
|
||||
9A5D2499170A94DA0030D4DD /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A5D2498170A94DA0030D4DD /* QuartzCore.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>"; };
|
||||
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>"; };
|
||||
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>"; };
|
||||
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>"; };
|
||||
@ -231,7 +229,6 @@
|
||||
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>"; };
|
||||
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; };
|
||||
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; };
|
||||
@ -309,7 +306,6 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
766ECCEA27EDFC110074EA8B /* Sequence.c */,
|
||||
76FB15191F01413B00C5377F /* VertexEffect.c */,
|
||||
76EE4E421EB36DE6000254F4 /* Array.c */,
|
||||
76EE4E431EB36DE6000254F4 /* ClippingAttachment.c */,
|
||||
76EE4E441EB36DE6000254F4 /* SkeletonClipping.c */,
|
||||
@ -333,7 +329,6 @@
|
||||
76F28D021DEC810300CDE54D /* IkConstraintData.c */,
|
||||
76F28D031DEC810300CDE54D /* Json.c */,
|
||||
76F28D041DEC810300CDE54D /* Json.h */,
|
||||
76F28D051DEC810300CDE54D /* kvec.h */,
|
||||
76F28D061DEC810300CDE54D /* MeshAttachment.c */,
|
||||
76F28D071DEC810300CDE54D /* PathAttachment.c */,
|
||||
76F28D081DEC810300CDE54D /* PathConstraint.c */,
|
||||
@ -610,7 +605,6 @@
|
||||
76BF7E071E66ED9C00485998 /* GLUtils.c in Sources */,
|
||||
76EE4E481EB36DE6000254F4 /* SkeletonClipping.c in Sources */,
|
||||
43C3282F170B0C19004A9460 /* spine-cocos2d-objc.m in Sources */,
|
||||
76FB151A1F01413B00C5377F /* VertexEffect.c in Sources */,
|
||||
76F28D1F1DEC810300CDE54D /* BoundingBoxAttachment.c in Sources */,
|
||||
76F28D281DEC810300CDE54D /* PathConstraint.c in Sources */,
|
||||
76F28D2F1DEC810300CDE54D /* SkeletonJson.c in Sources */,
|
||||
|
||||
@ -46,7 +46,6 @@
|
||||
float* _worldVertices;
|
||||
CCBlendMode* screenMode;
|
||||
spSkeletonClipping* _clipper;
|
||||
spVertexEffect* _effect;
|
||||
}
|
||||
|
||||
+ (id) skeletonWithData:(spSkeletonData*)skeletonData ownsSkeletonData:(bool)ownsSkeletonData;
|
||||
@ -90,6 +89,5 @@
|
||||
@property (nonatomic) bool debugBones;
|
||||
@property (nonatomic) bool skipVisibilityCheck;
|
||||
@property (nonatomic) spBone* rootBone;
|
||||
@property (nonatomic) spVertexEffect* effect;
|
||||
|
||||
@end
|
||||
|
||||
@ -49,7 +49,6 @@ static bool handlerQueued = false;
|
||||
@synthesize twoColorTint = _twoColorTint;
|
||||
@synthesize debugSlots = _debugSlots;
|
||||
@synthesize debugBones = _debugBones;
|
||||
@synthesize effect = _effect;
|
||||
|
||||
+ (id) skeletonWithData:(spSkeletonData*)skeletonData ownsSkeletonData:(bool)ownsSkeletonData {
|
||||
return [[[self alloc] initWithData:skeletonData ownsSkeletonData:ownsSkeletonData] autorelease];
|
||||
@ -91,7 +90,6 @@ static bool handlerQueued = false;
|
||||
];
|
||||
|
||||
_clipper = spSkeletonClipping_create();
|
||||
_effect = 0;
|
||||
}
|
||||
|
||||
- (id) initWithData:(spSkeletonData*)skeletonData ownsSkeletonData:(bool)ownsSkeletonData {
|
||||
@ -174,8 +172,6 @@ static bool handlerQueued = false;
|
||||
handlerQueued = true;
|
||||
}
|
||||
|
||||
if (_effect) _effect->begin(_effect, _skeleton);
|
||||
|
||||
CCColor* nodeColor = self.color;
|
||||
_skeleton->color.r = nodeColor.red;
|
||||
_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.color = GLKVector4Make(r, g, b, a);
|
||||
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));
|
||||
}
|
||||
for (int j = 0; j * 3 < trianglesCount; ++j) {
|
||||
@ -337,51 +319,19 @@ static bool handlerQueued = false;
|
||||
spVertex* verts = &meshPart.mesh->vertices[meshPart.startVertex];
|
||||
unsigned short* indices = &meshPart.mesh->indices[meshPart.startIndex];
|
||||
|
||||
if (_effect) {
|
||||
spColor light;
|
||||
light.r = r;
|
||||
light.g = g;
|
||||
light.b = b;
|
||||
light.a = a;
|
||||
spColor dark;
|
||||
dark.r = dr;
|
||||
dark.g = dg;
|
||||
dark.b = db;
|
||||
dark.a = da;
|
||||
for (int i = 0; i * 2 < verticesCount; i++, verts++) {
|
||||
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 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++) {
|
||||
*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 (_effect) _effect->end(_effect);
|
||||
}
|
||||
|
||||
- (CCTexture*) getTextureForRegion:(spRegionAttachment*)attachment {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user