• Editor
  • I'm working on a Python/Pygame runtime.

Thanks for the suggestions Nate. I realize you're super busy and I really appreciate all of your help.

I did figure some things out. 😉

I realized that the Corona runtime is actually setting skeleton.x and skeleton.y, while C++ is setting the root bone coordinates.

Both are setting these to positive values. I missed the fact that Corona is NOT actually setting the root bone coordinates, which means that when the root bone gets drawn, it is drawn at 0, 0 relative to skeleton.x, skeleton.y... doh... and since C++ uses flipped coordinates, setting the root bone to a positive value will cause it to get flipped with is The Right Thing™ for the SMFL runtime.

So... one mystery solved. :-)

I've added an x, y to my own skeleton class, and now I'm drawing things relative to its x, y.

I hate to be optimistic, but my pose looks 100% correct compared to the Corona bone points EXCEPT for the arm bone locations! :/

Image supprimée en raison de l'absence de support de HTTPS. | Afficher quand même

Is this another red herring, or does this actually help?

As for your other suggestion, I did a simple test where I created a root bone, and 4 other bones with a length of 10 and coordinates of:

(10, 10), (-10, 10), (10, -10), (-10, -10)

All of those bone points check out. I tested them one at a time. My drawing looks like:

Image supprimée en raison de l'absence de support de HTTPS. | Afficher quand même

I also plugged this into a test skeleton file and tested those one at a time... they draw correctly.

Any thoughts?

Good progress! 🙂 Do more tests with simple bones. Rotate the root, do the 4 children rotate correctly? Add more debug drawing, draw lines for the bone lengths.

These guys say they have Spine in Python, but I can't find the code:
http://ignifuga.org/

Since I'm currently only drawing the first frame of the skeleton at bone.worldX, -bone.worldY, shouldn't the arm placements be correct, or is there something that happens in the initial setup that could cause these to be off?

I'm not currently doing any rotation or anything like that... do I need to do that for these circles? I just drew them at bone.worldX, -bone.worldY.

This is what the Corona runtime seems to be doing, and the bones are all correct... so why are my arms broken?

I'll play some more, but it sounds like you're saying I'm on the right track...? 😉

Thanks for the link to the other library. I'll take a look.

I redrew the children in different colors to visualize what was happening.

When I add a positive rotation to the bones (self.bones[0].rotation += 10), they rotate counter-clockwise.

Is this the expected behavior?

It looks like children of children bones are properly rotating:

Initial state:

Image supprimée en raison de l'absence de support de HTTPS. | Afficher quand même

Rotated state:

Image supprimée en raison de l'absence de support de HTTPS. | Afficher quand même

Assuming additive rotation should cause counter-clockwise motion, this should be doing what it's supposed to?

Aha... something looks wrong with my rotation.

Starting point (looks good):

Image supprimée en raison de l'absence de support de HTTPS. | Afficher quand même

And once I start rotating:

Image supprimée en raison de l'absence de support de HTTPS. | Afficher quand même


Image supprimée en raison de l'absence de support de HTTPS. | Afficher quand même

Nate a écrit

These guys say they have Spine in Python, but I can't find the code:
http://ignifuga.org/

I don't see the code in their repo. Maybe it's unreleased.

Could be wrapping C++ maybe. Thought about doing that myself, but I like the idea of a pure Python implementation. It'll Just Work™ on Windows, Linux, OS X. :-)

Well, that is, if I can ever get it to work. 😉

HAH!

Found it.

grumble

terrymisu a écrit

HAH!

Found it.

grumble

Image supprimée en raison de l'absence de support de HTTPS. | Afficher quand même

     def setToBindPose(self):
@@ -34,7 +37,7 @@ class Bone(object):
             self.worldY = self.x * self.parent.m10 + self.y * self.parent.m11 + self.parent.worldY
             self.worldScaleX = self.parent.worldScaleX * self.scaleX
             self.worldScaleY = self.parent.worldScaleY * self.scaleY
-            self.worldRotation = self.parent.rotation + self.rotation
+            self.worldRotation = self.parent.worldRotation + self.rotation

Teehee. 😉

Hahaha... Still have a few kinks to work out:

Image supprimée en raison de l'absence de support de HTTPS. | Afficher quand même

Love those Neanderthal eyes though!

terrymisu a écrit

I don't think my timeline rotation is working... but he finally draws properly!

http://youtu.be/MiiUMWTkZzk

Got the timeline stuff working, but the rotation is obviously backwards... need to figure out where the extra minus sign is present or missing. 😉

http://youtu.be/qKBv-X3il3g

Took a little detour to figure out how to use the libgdx texture packer so I could play with an animation I made.

I used it to make the scaling code work. Unfortunately, Pygame doesn't seem to have an independent x and y scaling mode, so I took the average of x and y and I'll scale the image equally... I'm not sure if that's the best idea, but it seemed like a better idea than arbitrarily picking X or Y.

I'm still chasing some bad math, but here's a video of Spine Boy with his new sparkly sword:

http://youtu.be/Ld45-LlHxPY

Haha rotation is a little messed up, but nice sword! 😃

If your game toolkit can't draw quadrilaterals, then you should only use uniform scaling (equal x and y) in Spine. This is the case with Corona. You can actually use non-uniform scaling even if the game toolkit can't draw quads, but you have to align your images with the bone so that the images don't get squashed to a rhomboid (diamond) shape when the bone is scaled non-uniformly.

Nate a écrit

Haha rotation is a little messed up, but nice sword! 😃

If your game toolkit can't draw quadrilaterals, then you should only use uniform scaling (equal x and y) in Spine. This is the case with Corona. You can actually use non-uniform scaling even if the game toolkit can't draw quads, but you have to align your images with the bone so that the images don't get squashed to a rhomboid (diamond) shape when the bone is scaled non-uniformly.

Yeah, still chasing some pesky bugs. :/

I'm not sure I understand exactly what you're saying here. I can't blit non-rectangle shaped textures, so it sounds like I need to use uniform scaling, which is why I do my scale with (xScale + yScale) / 2 (not ideal, but...) Basically, I only have the option of passing a single float value for my "zoom" parameter.

The thing I'm confused about is that you've got scaling on your bones, and on your textures... and you could theoretically have your bones scaled differently than your textures. What happens if I scale something with different X/Y values in Spine and then try to use that in the python runtime?

If there is no rotation on the image attached to the bone you can use non-uniform scale. In the spineboy example all scale values are uniform at 1,1.
If you need to use non-uniform scaling the local-axis rotation of the image needs to be 0.

I haven't had much time to work on the Python port this week, but I'd like to wrap up the work I've done.

I'm having some trouble drawing the bones.

I don't understand what Corona is doing - it looks like the upper layer automatically takes care of drawing the line object that is created.

I can't draw lines with a rotation value in Pygame, so I need to draw the bones with specified (x, y) coordinates for the start and end point.

The origin is (bone.worldX, -bone.worldY), but where is the end point? Is it the parent's (bone.worldX, -bone.worldY)?

Afaik the end point is calculated by the rotation and length of the bone.

Yep, Shiu is right. Start by drawing your lines at the bone world x,y to bone world x+length,y. Works? Good. Now draw your lines with these coordinates:

float x1 = bone.worldX;
float y1 = bone.worldY;
float x2 = bone.worldX + cos(bone.worldRotation) * bone.length;
float y2 = bone.worldY + sin(bone.worldRotation) * bone.length;