mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[cocos2d-objc] Ported to 3.6, no two color batching yet
This commit is contained in:
parent
6d948697cf
commit
5565f00135
@ -73,6 +73,8 @@
|
|||||||
76F5BDA71D2BDE1C005917E5 /* tank.png in Resources */ = {isa = PBXBuildFile; fileRef = 76F5BDA11D2BDE1C005917E5 /* tank.png */; };
|
76F5BDA71D2BDE1C005917E5 /* tank.png in Resources */ = {isa = PBXBuildFile; fileRef = 76F5BDA11D2BDE1C005917E5 /* tank.png */; };
|
||||||
76F5BDAA1D2BDE67005917E5 /* RaptorExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 76F5BDA91D2BDE67005917E5 /* RaptorExample.m */; };
|
76F5BDAA1D2BDE67005917E5 /* RaptorExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 76F5BDA91D2BDE67005917E5 /* RaptorExample.m */; };
|
||||||
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 */; };
|
||||||
|
76FAC1971E3FA15E001CCC8C /* PointAttachment.c in Sources */ = {isa = PBXBuildFile; fileRef = 76FAC1951E3FA15E001CCC8C /* PointAttachment.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 */; };
|
||||||
@ -201,6 +203,8 @@
|
|||||||
76F5BDA91D2BDE67005917E5 /* RaptorExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RaptorExample.m; path = example/RaptorExample.m; sourceTree = "<group>"; };
|
76F5BDA91D2BDE67005917E5 /* RaptorExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RaptorExample.m; path = example/RaptorExample.m; sourceTree = "<group>"; };
|
||||||
76F5BDAB1D2BDFA2005917E5 /* TankExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TankExample.h; path = example/TankExample.h; sourceTree = "<group>"; };
|
76F5BDAB1D2BDFA2005917E5 /* TankExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TankExample.h; path = example/TankExample.h; sourceTree = "<group>"; };
|
||||||
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>"; };
|
||||||
|
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>"; };
|
||||||
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; };
|
||||||
@ -273,6 +277,8 @@
|
|||||||
43C32822170B0BC2004A9460 /* spine-c */ = {
|
43C32822170B0BC2004A9460 /* spine-c */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
76FAC1941E3FA15E001CCC8C /* Color.c */,
|
||||||
|
76FAC1951E3FA15E001CCC8C /* PointAttachment.c */,
|
||||||
76F28CF41DEC810200CDE54D /* Animation.c */,
|
76F28CF41DEC810200CDE54D /* Animation.c */,
|
||||||
76F28CF51DEC810300CDE54D /* AnimationState.c */,
|
76F28CF51DEC810300CDE54D /* AnimationState.c */,
|
||||||
76F28CF61DEC810300CDE54D /* AnimationStateData.c */,
|
76F28CF61DEC810300CDE54D /* AnimationStateData.c */,
|
||||||
@ -558,8 +564,10 @@
|
|||||||
76F28D311DEC810300CDE54D /* Slot.c in Sources */,
|
76F28D311DEC810300CDE54D /* Slot.c in Sources */,
|
||||||
43C32A06170B0F93004A9460 /* main.m in Sources */,
|
43C32A06170B0F93004A9460 /* main.m in Sources */,
|
||||||
76F28D351DEC810300CDE54D /* VertexAttachment.c in Sources */,
|
76F28D351DEC810300CDE54D /* VertexAttachment.c in Sources */,
|
||||||
|
76FAC1961E3FA15E001CCC8C /* Color.c in Sources */,
|
||||||
76F28D331DEC810300CDE54D /* TransformConstraint.c in Sources */,
|
76F28D331DEC810300CDE54D /* TransformConstraint.c in Sources */,
|
||||||
43C32A09170B10FF004A9460 /* AppDelegate.m in Sources */,
|
43C32A09170B10FF004A9460 /* AppDelegate.m in Sources */,
|
||||||
|
76FAC1971E3FA15E001CCC8C /* PointAttachment.c in Sources */,
|
||||||
43F7FF881927F94800CA4038 /* SkeletonAnimation.m in Sources */,
|
43F7FF881927F94800CA4038 /* SkeletonAnimation.m in Sources */,
|
||||||
76F28D271DEC810300CDE54D /* PathAttachment.c in Sources */,
|
76F28D271DEC810300CDE54D /* PathAttachment.c in Sources */,
|
||||||
76F28D2B1DEC810300CDE54D /* Skeleton.c in Sources */,
|
76F28D2B1DEC810300CDE54D /* Skeleton.c in Sources */,
|
||||||
|
|||||||
@ -148,10 +148,10 @@ static const unsigned short quadTriangles[6] = {0, 1, 2, 2, 3, 0};
|
|||||||
|
|
||||||
-(void)draw:(CCRenderer *)renderer transform:(const GLKMatrix4 *)transform {
|
-(void)draw:(CCRenderer *)renderer transform:(const GLKMatrix4 *)transform {
|
||||||
CCColor* nodeColor = self.color;
|
CCColor* nodeColor = self.color;
|
||||||
_skeleton->r = nodeColor.red;
|
_skeleton->color.r = nodeColor.red;
|
||||||
_skeleton->g = nodeColor.green;
|
_skeleton->color.g = nodeColor.green;
|
||||||
_skeleton->b = nodeColor.blue;
|
_skeleton->color.b = nodeColor.blue;
|
||||||
_skeleton->a = self.displayedOpacity;
|
_skeleton->color.a = self.displayedOpacity;
|
||||||
|
|
||||||
int blendMode = -1;
|
int blendMode = -1;
|
||||||
const float* uvs = 0;
|
const float* uvs = 0;
|
||||||
@ -166,30 +166,30 @@ static const unsigned short quadTriangles[6] = {0, 1, 2, 2, 3, 0};
|
|||||||
switch (slot->attachment->type) {
|
switch (slot->attachment->type) {
|
||||||
case SP_ATTACHMENT_REGION: {
|
case SP_ATTACHMENT_REGION: {
|
||||||
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
|
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
|
||||||
spRegionAttachment_computeWorldVertices(attachment, slot->bone, _worldVertices);
|
spRegionAttachment_computeWorldVertices(attachment, slot->bone, _worldVertices, 0, 2);
|
||||||
texture = [self getTextureForRegion:attachment];
|
texture = [self getTextureForRegion:attachment];
|
||||||
uvs = attachment->uvs;
|
uvs = attachment->uvs;
|
||||||
verticesCount = 8;
|
verticesCount = 8;
|
||||||
triangles = quadTriangles;
|
triangles = quadTriangles;
|
||||||
trianglesCount = 6;
|
trianglesCount = 6;
|
||||||
r = attachment->r;
|
r = attachment->color.r;
|
||||||
g = attachment->g;
|
g = attachment->color.g;
|
||||||
b = attachment->b;
|
b = attachment->color.b;
|
||||||
a = attachment->a;
|
a = attachment->color.a;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SP_ATTACHMENT_MESH: {
|
case SP_ATTACHMENT_MESH: {
|
||||||
spMeshAttachment* attachment = (spMeshAttachment*)slot->attachment;
|
spMeshAttachment* attachment = (spMeshAttachment*)slot->attachment;
|
||||||
spMeshAttachment_computeWorldVertices(attachment, slot, _worldVertices);
|
spVertexAttachment_computeWorldVertices(SUPER(attachment), slot, 0, attachment->super.worldVerticesLength, _worldVertices, 0, 2);
|
||||||
texture = [self getTextureForMesh:attachment];
|
texture = [self getTextureForMesh:attachment];
|
||||||
uvs = attachment->uvs;
|
uvs = attachment->uvs;
|
||||||
verticesCount = attachment->super.worldVerticesLength;
|
verticesCount = attachment->super.worldVerticesLength;
|
||||||
triangles = attachment->triangles;
|
triangles = attachment->triangles;
|
||||||
trianglesCount = attachment->trianglesCount;
|
trianglesCount = attachment->trianglesCount;
|
||||||
r = attachment->r;
|
r = attachment->color.r;
|
||||||
g = attachment->g;
|
g = attachment->color.g;
|
||||||
b = attachment->b;
|
b = attachment->color.b;
|
||||||
a = attachment->a;
|
a = attachment->color.a;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: ;
|
default: ;
|
||||||
@ -212,15 +212,15 @@ static const unsigned short quadTriangles[6] = {0, 1, 2, 2, 3, 0};
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_premultipliedAlpha) {
|
if (_premultipliedAlpha) {
|
||||||
a *= _skeleton->a * slot->a;
|
a *= _skeleton->color.a * slot->color.a;
|
||||||
r *= _skeleton->r * slot->r * a;
|
r *= _skeleton->color.r * slot->color.r * a;
|
||||||
g *= _skeleton->g * slot->g * a;
|
g *= _skeleton->color.g * slot->color.g * a;
|
||||||
b *= _skeleton->b * slot->b * a;
|
b *= _skeleton->color.b * slot->color.b * a;
|
||||||
} else {
|
} else {
|
||||||
a *= _skeleton->a * slot->a;
|
a *= _skeleton->color.a * slot->color.a;
|
||||||
r *= _skeleton->r * slot->r;
|
r *= _skeleton->color.r * slot->color.r;
|
||||||
g *= _skeleton->g * slot->g;
|
g *= _skeleton->color.g * slot->color.g;
|
||||||
b *= _skeleton->b * slot->b;
|
b *= _skeleton->color.b * slot->color.b;
|
||||||
}
|
}
|
||||||
self.texture = texture;
|
self.texture = texture;
|
||||||
CGSize size = texture.contentSize;
|
CGSize size = texture.contentSize;
|
||||||
@ -249,7 +249,7 @@ static const unsigned short quadTriangles[6] = {0, 1, 2, 2, 3, 0};
|
|||||||
spSlot* slot = _skeleton->drawOrder[i];
|
spSlot* slot = _skeleton->drawOrder[i];
|
||||||
if (!slot->attachment || slot->attachment->type != SP_ATTACHMENT_REGION) continue;
|
if (!slot->attachment || slot->attachment->type != SP_ATTACHMENT_REGION) continue;
|
||||||
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
|
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
|
||||||
spRegionAttachment_computeWorldVertices(attachment, slot->bone, _worldVertices);
|
spRegionAttachment_computeWorldVertices(attachment, slot->bone, _worldVertices, 0, 2);
|
||||||
points[0] = ccp(_worldVertices[0], _worldVertices[1]);
|
points[0] = ccp(_worldVertices[0], _worldVertices[1]);
|
||||||
points[1] = ccp(_worldVertices[2], _worldVertices[3]);
|
points[1] = ccp(_worldVertices[2], _worldVertices[3]);
|
||||||
points[2] = ccp(_worldVertices[4], _worldVertices[5]);
|
points[2] = ccp(_worldVertices[4], _worldVertices[5]);
|
||||||
@ -292,11 +292,12 @@ static const unsigned short quadTriangles[6] = {0, 1, 2, 2, 3, 0};
|
|||||||
int verticesCount;
|
int verticesCount;
|
||||||
if (slot->attachment->type == SP_ATTACHMENT_REGION) {
|
if (slot->attachment->type == SP_ATTACHMENT_REGION) {
|
||||||
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
|
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
|
||||||
spRegionAttachment_computeWorldVertices(attachment, slot->bone, _worldVertices);
|
spRegionAttachment_computeWorldVertices(attachment, slot->bone, _worldVertices, 0, 2);
|
||||||
verticesCount = 8;
|
verticesCount = 8;
|
||||||
} else if (slot->attachment->type == SP_ATTACHMENT_MESH) {
|
} else if (slot->attachment->type == SP_ATTACHMENT_MESH) {
|
||||||
spMeshAttachment* mesh = (spMeshAttachment*)slot->attachment;
|
spMeshAttachment* mesh = (spMeshAttachment*)slot->attachment;
|
||||||
spMeshAttachment_computeWorldVertices(mesh, slot, _worldVertices);
|
spVertexAttachment_computeWorldVertices(SUPER(mesh), slot, 0, mesh->super.worldVerticesLength, _worldVertices, 0, 2);
|
||||||
|
|
||||||
verticesCount = mesh->super.worldVerticesLength;
|
verticesCount = mesh->super.worldVerticesLength;
|
||||||
} else
|
} else
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user