Hey guys! After playing around with the sdl2 runtime for spine, I went ahead and developed my own 2d game engine with sdl2(even though I said I wouldn't). After successfully implementing spine in my engine, I like to rotate a bone within the x axis like when the player is shooting a enemy for example. after looking at the c++ runtimes, I noticed that you need to apply updateworldtransform to your bone in order to rotate, but so far, no luck. I can rotate the root bone just fine, just not a bone I like to rotate, like the head bone for example. Does anyone have any ideas on how I can do this? Let me know if I need to place any code
Bone rotating in c++
To rotate a specific bone, such as the head bone, in your custom SDL2 game engine using the Spine C++ runtime, you need to follow a specific sequence of operations. First, apply any animations to the skeleton, which will set the initial pose of the bones. Then, adjust the local rotation of the specific bone you want to rotate, such as the head bone. After making this adjustment, you must call skeleton->updateWorldTransform()
to update the world transforms of all bones based on their local transforms. This sequence ensures that your manual rotation is applied on top of any animation-driven transformations. If the animation also affects the head bone's rotation, it might overwrite your changes, so ensure your manual rotation is applied after the animation.
Is your runtime based on our generic spine-cpp runtime?
If you change the local transform, you'll need to update the world transform. Alternatively, you can change the world transform directly:
EsotericSoftware/spine-runtimesblob/4.2/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Bone.java#L629-L641
This will only change the one bone. Child bones that have already calculated their world transforms won't rotate. For that you'd need to recalculate the child world transforms.
Constraints do that for you, so often an IK constraint is used to make a bone point to a specific place, then you just move the IK target bone.
Sorry for not getting back to this, but yes, it uses the runtime provided from github for c++. The engine isn't much, but I was able to implement spine with it along with throwing box2d physics in there and finally finishing the camera, which wasn't fun, alot of frustration but I did manage to get it complete and figured out. The only thing left is to do is to do the bone rotation. I'll try this way to see if I can get something