mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Formatting.
This commit is contained in:
parent
6f0343d183
commit
5874b5d276
@ -66,14 +66,14 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0};
|
|||||||
|
|
||||||
_skeleton = spSkeleton_create(skeletonData);
|
_skeleton = spSkeleton_create(skeletonData);
|
||||||
_rootBone = _skeleton->bones[0];
|
_rootBone = _skeleton->bones[0];
|
||||||
|
|
||||||
_blendFunc.src = GL_ONE;
|
_blendFunc.src = GL_ONE;
|
||||||
_blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
|
_blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||||
_drawNode = [[CCDrawNode alloc] init];
|
_drawNode = [[CCDrawNode alloc] init];
|
||||||
[_drawNode setBlendMode: [CCBlendMode premultipliedAlphaMode]];
|
[_drawNode setBlendMode: [CCBlendMode premultipliedAlphaMode]];
|
||||||
[self addChild:_drawNode];
|
[self addChild:_drawNode];
|
||||||
|
|
||||||
[self setShader:[CCShader positionTextureColorShader]];
|
[self setShader:[CCShader positionTextureColorShader]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithData:(spSkeletonData*)skeletonData ownsSkeletonData:(bool)ownsSkeletonData {
|
- (id) initWithData:(spSkeletonData*)skeletonData ownsSkeletonData:(bool)ownsSkeletonData {
|
||||||
@ -124,7 +124,6 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0};
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc {
|
- (void) dealloc {
|
||||||
|
|
||||||
if (_ownsSkeletonData) spSkeletonData_dispose(_skeleton->data);
|
if (_ownsSkeletonData) spSkeletonData_dispose(_skeleton->data);
|
||||||
if (_atlas) spAtlas_dispose(_atlas);
|
if (_atlas) spAtlas_dispose(_atlas);
|
||||||
spSkeleton_dispose(_skeleton);
|
spSkeleton_dispose(_skeleton);
|
||||||
@ -133,7 +132,6 @@ static const int 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->r = nodeColor.red;
|
||||||
_skeleton->g = nodeColor.green;
|
_skeleton->g = nodeColor.green;
|
||||||
@ -148,7 +146,6 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0};
|
|||||||
int trianglesCount = 0;
|
int trianglesCount = 0;
|
||||||
float r = 0, g = 0, b = 0, a = 0;
|
float r = 0, g = 0, b = 0, a = 0;
|
||||||
for (int i = 0, n = _skeleton->slotsCount; i < n; i++) {
|
for (int i = 0, n = _skeleton->slotsCount; i < n; i++) {
|
||||||
|
|
||||||
spSlot* slot = _skeleton->drawOrder[i];
|
spSlot* slot = _skeleton->drawOrder[i];
|
||||||
if (!slot->attachment) continue;
|
if (!slot->attachment) continue;
|
||||||
CCTexture *texture = 0;
|
CCTexture *texture = 0;
|
||||||
@ -168,7 +165,6 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0};
|
|||||||
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);
|
spMeshAttachment_computeWorldVertices(attachment, slot, worldVertices);
|
||||||
texture = [self getTextureForMesh:attachment];
|
texture = [self getTextureForMesh:attachment];
|
||||||
@ -183,7 +179,6 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0};
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SP_ATTACHMENT_SKINNED_MESH: {
|
case SP_ATTACHMENT_SKINNED_MESH: {
|
||||||
|
|
||||||
spSkinnedMeshAttachment* attachment = (spSkinnedMeshAttachment*)slot->attachment;
|
spSkinnedMeshAttachment* attachment = (spSkinnedMeshAttachment*)slot->attachment;
|
||||||
spSkinnedMeshAttachment_computeWorldVertices(attachment, slot, worldVertices);
|
spSkinnedMeshAttachment_computeWorldVertices(attachment, slot, worldVertices);
|
||||||
texture = [self getTextureForSkinnedMesh:attachment];
|
texture = [self getTextureForSkinnedMesh:attachment];
|
||||||
@ -201,7 +196,7 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0};
|
|||||||
}
|
}
|
||||||
if (texture) {
|
if (texture) {
|
||||||
if (slot->data->additiveBlending != additive) {
|
if (slot->data->additiveBlending != additive) {
|
||||||
[self setBlendMode:[CCBlendMode blendModeWithOptions:@{CCBlendFuncSrcColor: @(_blendFunc.src),CCBlendFuncDstColor: @(slot->data->additiveBlending ? GL_ONE : _blendFunc.dst)}]];
|
[self setBlendMode:[CCBlendMode blendModeWithOptions:@{CCBlendFuncSrcColor: @(_blendFunc.src),CCBlendFuncDstColor: @(slot->data->additiveBlending ? GL_ONE : _blendFunc.dst)}]];
|
||||||
additive = slot->data->additiveBlending;
|
additive = slot->data->additiveBlending;
|
||||||
}
|
}
|
||||||
color.a = _skeleton->a * slot->a * a * 255;
|
color.a = _skeleton->a * slot->a * a * 255;
|
||||||
@ -209,27 +204,26 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0};
|
|||||||
color.r = _skeleton->r * slot->r * r * multiplier;
|
color.r = _skeleton->r * slot->r * r * multiplier;
|
||||||
color.g = _skeleton->g * slot->g * g * multiplier;
|
color.g = _skeleton->g * slot->g * g * multiplier;
|
||||||
color.b = _skeleton->b * slot->b * b * multiplier;
|
color.b = _skeleton->b * slot->b * b * multiplier;
|
||||||
self.texture = texture;
|
self.texture = texture;
|
||||||
CGSize size = texture.contentSize;
|
CGSize size = texture.contentSize;
|
||||||
GLKVector2 center = GLKVector2Make(size.width/2.0, size.height/2.0);
|
GLKVector2 center = GLKVector2Make(size.width / 2.0, size.height / 2.0);
|
||||||
GLKVector2 extents = GLKVector2Make(size.width/2.0, size.height/2.0);
|
GLKVector2 extents = GLKVector2Make(size.width / 2.0, size.height / 2.0);
|
||||||
if(CCRenderCheckVisbility(transform, center, extents)){
|
if (CCRenderCheckVisbility(transform, center, extents)) {
|
||||||
CCRenderBuffer buffer = [renderer enqueueTriangles:trianglesCount/3 andVertexes:verticesCount withState:self.renderState globalSortOrder:0];
|
CCRenderBuffer buffer = [renderer enqueueTriangles:(trianglesCount / 3) andVertexes:verticesCount withState:self.renderState globalSortOrder:0];
|
||||||
for(int i = 0; (i*2) < verticesCount; ++i) {
|
for (int i = 0; i * 2 < verticesCount; ++i) {
|
||||||
CCVertex vertex;
|
CCVertex vertex;
|
||||||
vertex.position = GLKVector4Make(worldVertices[i*2], worldVertices[i*2 + 1], 0.0, 1.0);
|
vertex.position = GLKVector4Make(worldVertices[i * 2], worldVertices[i * 2 + 1], 0.0, 1.0);
|
||||||
vertex.color = GLKVector4Make(color.r, color.g, color.b, color.a);
|
vertex.color = GLKVector4Make(color.r, color.g, color.b, color.a);
|
||||||
vertex.texCoord1 = GLKVector2Make(uvs[i*2], 1 - uvs[(i*2) +1]);
|
vertex.texCoord1 = GLKVector2Make(uvs[i * 2], 1 - uvs[i * 2 + 1]);
|
||||||
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) {
|
||||||
CCRenderBufferSetTriangle(buffer, j, triangles[j*3], triangles[(j*3) + 1], triangles[(j*3) + 2]);
|
CCRenderBufferSetTriangle(buffer, j, triangles[j * 3], triangles[j * 3 + 1], triangles[j * 3 + 2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
[_drawNode clear];
|
[_drawNode clear];
|
||||||
if (_debugSlots) {
|
if (_debugSlots) {
|
||||||
// Slots.
|
// Slots.
|
||||||
CGPoint points[4];
|
CGPoint points[4];
|
||||||
@ -242,8 +236,7 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0};
|
|||||||
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]);
|
||||||
points[3] = ccp(worldVertices[6], worldVertices[7]);
|
points[3] = ccp(worldVertices[6], worldVertices[7]);
|
||||||
[_drawNode drawPolyWithVerts:points count:4 fillColor:[CCColor clearColor] borderWidth:1 borderColor:[CCColor blueColor]];
|
[_drawNode drawPolyWithVerts:points count:4 fillColor:[CCColor clearColor] borderWidth:1 borderColor:[CCColor blueColor]];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_debugBones) {
|
if (_debugBones) {
|
||||||
@ -252,14 +245,14 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0};
|
|||||||
spBone *bone = _skeleton->bones[i];
|
spBone *bone = _skeleton->bones[i];
|
||||||
float x = bone->data->length * bone->m00 + bone->worldX;
|
float x = bone->data->length * bone->m00 + bone->worldX;
|
||||||
float y = bone->data->length * bone->m10 + bone->worldY;
|
float y = bone->data->length * bone->m10 + bone->worldY;
|
||||||
[_drawNode drawSegmentFrom:ccp(bone->worldX, bone->worldY) to: ccp(x, y)radius:2 color:[CCColor redColor]];
|
[_drawNode drawSegmentFrom:ccp(bone->worldX, bone->worldY) to: ccp(x, y)radius:2 color:[CCColor redColor]];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bone origins.
|
// Bone origins.
|
||||||
for (int i = 0, n = _skeleton->bonesCount; i < n; i++) {
|
for (int i = 0, n = _skeleton->bonesCount; i < n; i++) {
|
||||||
spBone *bone = _skeleton->bones[i];
|
spBone *bone = _skeleton->bones[i];
|
||||||
[_drawNode drawDot:ccp(bone->worldX, bone->worldY) radius:4 color:[CCColor greenColor]];
|
[_drawNode drawDot:ccp(bone->worldX, bone->worldY) radius:4 color:[CCColor greenColor]];
|
||||||
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]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user