Hi,
how should I do to rotate a skeleton in a different orgin of root bone?
best
Cristian
-
Cristian Zerbinati - Eprime eprime
• Posts: 104

Not sure exactly what you are asking. Maybe it is sufficient to set the rotation on the root bone? Nate • Posts: 11859

Hi Nate,
I upload a video to explain. First I show the rotation on origin at center, next I move the center pivot in another point and I rotate from here.
How can I do this?
http://somup.com/cYXTjRISL3
-
Cristian Zerbinati - Eprime eprime
• Posts: 104

You can solve this via the XNA API by setting a model matrix for the skeleton. Please search the web for "XNA rotate around pivot" for examples.

If you want to solve this using Spine, you have to introduce a bone parented to the root bone, to which all other things are parented. Here's an example using Spineboy.

Screenshot 2020-11-25 at 10.46.22.png

The root bone has a child bone called pivot-child. The rest of the skeleton is parented to pivot-child.

The root bone thus becomes the pivot. You can adjust the x/y position of the pivot-child, which is relative to the root bone. Then you can rotate the root bone.
You do not have the required permissions to view the files attached to this post. Mario • Posts: 3033

Solved :-)
Thank you Mario, I prefer do not touch Spine root bone. I can archive with this, (vbnet sorry)
I found RotateAround function in Nez engine that is a very good engine for 2D game https://github.com/prime31/Nez
Dim t As Vector2
Dim angle as single = 1.0f
Dim origin as Vector2= New Vector2(-1, 0)
t = RotateAround(New Vector2(Skeleton.X, Skeleton.Y), origin, angle)
Skeleton.X = t.X
Skeleton.Y = t.Y
Skeleton.RootBone.Rotation = -angle
Skeleton.UpdateWorldTransform()

....
Function RotateAround(ByVal point As Vector2, ByVal center As Vector2, ByVal angleInDegrees As Single) As Vector2
Dim cos = Math.Cos(angleInDegrees)
Dim sin = Math.Sin(angleInDegrees)
Dim rotatedX = cos * (point.X - center.X) - sin * (point.Y - center.Y) + center.X
Dim rotatedY = sin * (point.X - center.X) + cos * (point.Y - center.Y) + center.Y
Return New Vector2(rotatedX, rotatedY)
End Function
-
Cristian Zerbinati - Eprime eprime
• Posts: 104