diff --git a/spine-sfml/example/main.cpp b/spine-sfml/example/main.cpp index ef5c4a5ba..6953ac0ca 100644 --- a/spine-sfml/example/main.cpp +++ b/spine-sfml/example/main.cpp @@ -138,7 +138,6 @@ void goblins () { // Load atlas, skeleton, and animations. Atlas* atlas = Atlas_readAtlasFile("../data/goblins-ffd.atlas"); SkeletonJson* json = SkeletonJson_create(atlas); - json->scale = 2; SkeletonData *skeletonData = SkeletonJson_readSkeletonDataFile(json, "../data/goblins-ffd.json"); if (!skeletonData) { printf("Error: %s\n", json->error); diff --git a/spine-sfml/src/spine/spine-sfml.cpp b/spine-sfml/src/spine/spine-sfml.cpp index 17dc0ed90..cfd54e8a4 100644 --- a/spine-sfml/src/spine/spine-sfml.cpp +++ b/spine-sfml/src/spine/spine-sfml.cpp @@ -154,6 +154,7 @@ void SkeletonDrawable::draw (RenderTarget& target, RenderStates states) const { } else if (attachment->type == ATTACHMENT_MESH) { MeshAttachment* mesh = (MeshAttachment*)attachment; + if (mesh->uvsCount > SPINE_MESH_VERTEX_COUNT_MAX) continue; texture = (Texture*)((AtlasRegion*)mesh->rendererObject)->page->rendererObject; MeshAttachment_computeWorldVertices(mesh, slot->skeleton->x, slot->skeleton->y, slot, worldVertices); @@ -166,6 +167,31 @@ void SkeletonDrawable::draw (RenderTarget& target, RenderStates states) const { vertex.color.b = b; vertex.color.a = a; + Vector2u size = texture->getSize(); + for (int i = 0; i < mesh->trianglesCount; ++i) { + int index = mesh->triangles[i] << 1; + vertex.position.x = worldVertices[index]; + vertex.position.y = worldVertices[index + 1]; + vertex.texCoords.x = mesh->uvs[index] * size.x; + vertex.texCoords.y = mesh->uvs[index + 1] * size.y; + vertexArray->append(vertex); + } + + } else if (attachment->type == ATTACHMENT_SKINNED_MESH) { + SkinnedMeshAttachment* mesh = (SkinnedMeshAttachment*)attachment; + if (mesh->uvsCount > SPINE_MESH_VERTEX_COUNT_MAX) continue; + texture = (Texture*)((AtlasRegion*)mesh->rendererObject)->page->rendererObject; + SkinnedMeshAttachment_computeWorldVertices(mesh, slot->skeleton->x, slot->skeleton->y, slot, worldVertices); + + Uint8 r = skeleton->r * slot->r * 255; + Uint8 g = skeleton->g * slot->g * 255; + Uint8 b = skeleton->b * slot->b * 255; + Uint8 a = skeleton->a * slot->a * 255; + vertex.color.r = r; + vertex.color.g = g; + vertex.color.b = b; + vertex.color.a = a; + Vector2u size = texture->getSize(); for (int i = 0; i < mesh->trianglesCount; ++i) { int index = mesh->triangles[i] << 1;