I am trying to extract the position of each image on each frame, so that I can store, position,rotation scale draw level etc. and convert it to a simple set of drawing instructions that require no calculations.
I dont understand how to work with vertices etc, so I am trying to get it to work in a format that I understand well, I also think that the skeletons are slow as in my speed tests there was a performace hit drawing 100 spine boys and unplayable drawing 1000 spineboys. however just drawing a character in layers barely phased it drawing 1000.
Also it would be much easier for me to switch out graphics this way, and just use the same positions, for example, if a character has 10 different weapons, to change weapon, all i need to do is change the pointer to the graphic.
I found a nice piece of code to load and draw spine boy using spine-c and allegro spine.
it looks like this for drawing the spine figure
for(i=0; i < sd->skeleton->slotsCount; ++i) {
spSlot *slot = sd->skeleton->slots[i];
attachment = slot->attachment;
if(!attachment || attachment->type != SP_ATTACHMENT_REGION) continue;
regionAttachment = (spRegionAttachment*)attachment;
spRegionAttachment_computeWorldVertices(regionAttachment, slot->bone, vertexPositions);
r = sd->skeleton->r * slot->r * 255;
g = sd->skeleton->g * slot->g * 255;
b = sd->skeleton->b * slot->b * 255;
a = sd->skeleton->a * slot->a * 255;
vertices[0].color = al_map_rgba(r, g, b, a);
vertices[1].color = al_map_rgba(r, g, b, a);
vertices[2].color = al_map_rgba(r, g, b, a);
vertices[3].color = al_map_rgba(r, g, b, a);
vertices[0].x = vertexPositions[SP_VERTEX_X1];
vertices[0].y = vertexPositions[SP_VERTEX_Y1];
vertices[1].x = vertexPositions[SP_VERTEX_X2];
vertices[1].y = vertexPositions[SP_VERTEX_Y2];
vertices[2].x = vertexPositions[SP_VERTEX_X3];
vertices[2].y = vertexPositions[SP_VERTEX_Y3];
vertices[3].x = vertexPositions[SP_VERTEX_X4];
vertices[3].y = vertexPositions[SP_VERTEX_Y4];
vertices[0].z = vertices[1].z = vertices[2].z = vertices[3].z = 0.0;
texture = (ALLEGRO_BITMAP[i])((spAtlasRegion[/i])regionAttachment->rendererObject)->page->rendererObject;
size_y = al_get_bitmap_height(texture);
size_x = al_get_bitmap_width (texture);
vertices[0].u = regionAttachment->uvs[SP_VERTEX_X1] * size_x;//br
vertices[0].v = regionAttachment->uvs[SP_VERTEX_Y1] * size_y;
vertices[1].u = regionAttachment->uvs[SP_VERTEX_X2] * size_x;//bl
vertices[1].v = regionAttachment->uvs[SP_VERTEX_Y2] * size_y;
vertices[2].u = regionAttachment->uvs[SP_VERTEX_X3] * size_x;//tl
vertices[2].v = regionAttachment->uvs[SP_VERTEX_Y3] * size_y;
vertices[3].u = regionAttachment->uvs[SP_VERTEX_X4] * size_x;//tr
vertices[3].v = regionAttachment->uvs[SP_VERTEX_Y4] * size_y;
al_draw_indexed_prim(vertices, NULL, texture, indices1, 3, ALLEGRO_PRIM_TRIANGLE_LIST);
al_draw_indexed_prim(vertices, NULL, texture, indices2, 3, ALLEGRO_PRIM_TRIANGLE_LIST);
and that works just fine.
But what I want to do is draw the picture using point, rotations and scales.
So I have worked out how to extract the image source data.
But now I have to work out how to calculate the graphics position on screen.
al_draw_tinted_scaled_rotated_bitmap_region(texture,area.left,area.top,area.right-area.left,area.bottom-area.top,al_map_rgb(0,255,0),
(area.right-area.left)/2,(area.bottom-area.top)/2,dest.right,dest.bottom
,slot->bone->scaleX,slot->bone->scaleY,DEGTORAD(regionAttachment->rotation),0);
this is where it all goes nuts as the pieces are not in the right position.
I need to be able to get the center (rotation) point of the image, the scale, and the rotation. but im am unsure how to extract the required data from the vertices/bones/attchments etc.
Never mind, I just stored the vertices and it all works fine now....