ilusha

Hello,

I have a couple of questions about bounding boxes.

1. What does the World coordinates mean? Is it related to the Spine editor or to the Starling runtime? Because after world verticies computation an Y coordinate becomes below zero.
2. Skeleton.scale doesn't affect to bounding box verticies. Is it ok?

Thanks
Аватара пользователя
ilusha
Сообщения: 53

badlogic

1. The world coordinates are relative to the coordinate system in which the root bone of the skeleton is defined. The y-coordinates should not be flipped, this looks like a bug!
2. There's no Skeleton.scale. Could you tell me what you mean?
Аватара пользователя
badlogic

Mario
Сообщения: 1472

ilusha

1. Do you need a test project from my side?
2. Yes, it is my fault. I told about Starling DisplayObject properties and thought that they are from Spine)
Аватара пользователя
ilusha
Сообщения: 53

badlogic

A test project is always good :)
Аватара пользователя
badlogic

Mario
Сообщения: 1472

ilusha

I have sent the file to the Esoteric email (BoundingBoxQuestion.zip).
Several notes:
1. Animation contains blue square under the bone with 64-64 position. Size of the box is 64 px.
1. When I get bounds I expect points like in a json related to the parent bone (e.g. [ -30, -32, -30, 30, 33, 30, 33, -31 ]). I remember that in the work project I saw correct points but maybe I miss some initialization. But here they are: x=33.9 y=-32, x=34.0 y=-94, x=97 y=-94, x=97 y=-33.
2. World verticies have the same numbers like local points and y is below zero (x=33.9 y=-32, x=34.0 y=-94, x=97 y=-94, x=97 y=-33).

The archive contains as3 and spine projects. The all logic about world verticies I do in "WorldVerticiesTest.showWorldVerticiesInfo" method.
Аватара пользователя
ilusha
Сообщения: 53

badlogic

I've extended our SpineboyExample to show how the bounding box world coordinates can be used.


private function onUpdate() : void {
var slot:Slot = skeleton.skeleton.findSlot("head-bb");
var bb:BoundingBoxAttachment = skeleton.skeleton.getAttachmentForSlotIndex(slot.data.index, "head") as BoundingBoxAttachment;
var worldVertices:Vector.<Number> = new Vector.<Number>(bb.worldVerticesLength);
bb.computeWorldVertices(slot, 0, bb.worldVerticesLength, worldVertices, 0, 2);
for (var i:int = 0; i < worldVertices.length; i+=2) {
worldVertices[i] = worldVertices[i] * skeleton.scale + skeleton.x;
worldVertices[i + 1] = worldVertices[i + 1] * skeleton.scale + skeleton.y;
}
shape.setVertices(worldVertices);
}
The world vertices are relative to skeleton.x/y and do not take into account the DisplayObject scale. As you can see above, it's quite easy to factor that into the world vertices.
Аватара пользователя
badlogic

Mario
Сообщения: 1472

ilusha

Yes, I did the same code. I just wanted to know is it a bug or not. Now I see that it is relative to starling x,y not to spine.

Also does BoundingBoxAttachement always contain world verticies not the local coordinates relative to a parent bone?

Made out:
SkeletonBounds.getPolygon returns world verticies, BoundingBoxAttachement contains local verticies.

Thanks for help)
Аватара пользователя
ilusha
Сообщения: 53


Вернуться в Runtimes