@[삭제됨]
Are your graphics anchor points set to the centre in Python?
I ask because when I ported the Corona Lua to Gideros my graphics were out
of kilter (and bobbing) until I set the anchor points correctly
cheers
evs
@[삭제됨]
Are your graphics anchor points set to the centre in Python?
I ask because when I ported the Corona Lua to Gideros my graphics were out
of kilter (and bobbing) until I set the anchor points correctly
cheers
evs
I think you would find things a little easier to debug if you added a debug method to draw the bones, just indicate where the pivot is with a circle and the bone with a line. Then you'll know if it's the bones or the images that are causing the problem.
evs wrote@[삭제됨]
Are your graphics anchor points set to the centre in Python?
I ask because when I ported the Corona Lua to Gideros my graphics were out
of kilter (and bobbing) until I set the anchor points correctlycheers
evs
No, they're not. Pygame draws surfaces at (0, 0) by default.
Sounds like that may be the culprit... I'll give it a shot. Thanks!
What exactly did you have to do to fix this for Gideros?
Shiu wroteI think you would find things a little easier to debug if you added a debug method to draw the bones, just indicate where the pivot is with a circle and the bone with a line. Then you'll know if it's the bones or the images that are causing the problem.
Does my debug look correct? I can't quite tell, but it looks as though the images are off?
The top most circles look like the proper head/eye placement?
Thoughts?
Image removed due to the lack of support for HTTPS. | Show Anyway
Let's try this again... the previous image was with flipX = False, flipY = False, and the root bone at 0, -300.
Here's one with flipY = True and the root bone at 0, 0:
Image removed due to the lack of support for HTTPS. | Show Anyway
Hmmm... Looking at the Corona runtime some more, I think that I'm completely missing some steps.
I'm not rotating or scaling in pygame. I guess I got confused about that because the corona runtime apparently handles it internally with the image.x, image.y, image.scaleX, image.scaleY, and image.rotation variables on the texture?
Also, do I need to skeleton.flipY, or skeleton.flipX, considering that pygame is rendering from 0, 0 as the top-left corner? Seems like I need to set flipY?
Here's my debug code, which I'm not sure is correct:
debug = True
if debug:
for bone in self.bones:
lineX = bone.worldX
lineY = bone.worldY
lineRotation = -bone.worldRotation
if self.flipX:
lineXScale = -1
lineRotation = -lineRotation
else:
boneXScale = 1
if self.flipY:
lineYScale = -1
lineRotation = -lineRotation
else:
boneYScale = 1
lineColor = pygame.Color(255, 0, 0, 0)
pygame.draw.line(screen, lineColor, (0, 0), (x, y), 1)
circleX = int(bone.worldX)
circleY = int(-bone.worldY)
circleColor = (0, 255, 0, 0)
pygame.draw.circle(screen, circleColor, (circleX, circleY), 5, 1)
Your lines should not all come from 0,0. The lines show where the bones are. It should look like this: Image removed due to the lack of support for HTTPS. | Show Anyway
I think it makes sense to draw your lines before working about the images.
@[삭제됨]
In Gideros it was just:
image:setAnchorPoint(0.5, 0.5)
I suppose in Python would be something like:
anchorX = slot.attachment.u2 - slot.attachment.width / 2
anchorY = slot.attachment.v2 - slot.attachment.height / 2
screen.blit(slot.attachment.texture, (anchorX, anchorY))
cheers
evs
So, I got a little frustrated with the bone/slot/rotation stuff, and I went ahead and got the color processing working. I had a few things that I missed, and I wasn't properly extracting the colors from the animation file.
Now I'm back to working on Shiu's suggestion of getting the slot/bone stuff working first, however, I think I've got everything right but the rotation (could be wrong, but it's worth asking, right?).
So, two questions:
Does this skeleton look right, sans rotation? I noticed that his eyes and head are actually properly textured... and when the eyes blink, they're in the correct spot. Everything else also looks like it's in the proper location, including the root bone, legs, arms, etc... they're just not rotated properly?
Any ideas why the hair is pink instead of orange, or whatever? Thoughts on debugging this?
His torso is missing here, but it shows up sometimes. I think someone else mentioned both the hair color and the torso issue in a previous post.
Image removed due to the lack of support for HTTPS. | Show Anyway
[edit]
Here's an image with the torso, for posterity:
Image removed due to the lack of support for HTTPS. | Show Anyway
The root bone is at 320x240.
It's quite a pain eh? :bang: Note the bone for the eyes is the same as for the head. Here's a screenshot for the un-animated Spineboy skeleton showing where you should expect the bones to be drawn.
Image removed due to the lack of support for HTTPS. | Show Anyway
I'd forget about images for now and just draw lines for the bones. Start by just drawing a circle for each bone world position. If your bone transforms are correct (and taking into account y-up/down) then you'll get positions like in the screenshot. Next try drawing the bone lines. When you get the rotation right, it'll look like the screenshot. This should help a lot when rotating the images.
Nate wroteIt's quite a pain eh? :bang: Note the bone for the eyes is the same as for the head. Here's a screenshot for the un-animated Spineboy skeleton showing where you should expect the bones to be drawn.
Image removed due to the lack of support for HTTPS. | Show Anyway
I'd forget about images for now and just draw lines for the bones. Start by just drawing a circle for each bone world position. If your bone transforms are correct (and taking into account y-up/down) then you'll get positions like in the screenshot. Next try drawing the bone lines. When you get the rotation right, it'll look like the screenshot. This should help a lot when rotating the images.
Haha, yes, it is a pain, but it feels so close...
Thanks for the still image. That will help.
Nope, bones don't look right.
I guess I'll need to start looking in the BoneData class? [Edit] Errr... Bone class.
Image removed due to the lack of support for HTTPS. | Show Anyway
I can't get my root bone to draw properly. My Y is set to -240, which is obviously wrong. I can't see anything different between my Bone class and Corona's, and Corona isn't using FlipY, so I don't think I should use that either, correct?
What else might be causing the root bone's location to be flipped, if not something in the Bone class? Hrm.
:-O
'm01': -0.0,
Seriously? I didn't know Python had a concept of a negative 0. That's problematic.
Does pygame work in radians or degrees? The numbers from Spine are in degrees, which I overlooked at first.
Another thing that took me awhile, was to figure out how to calculate the attachment rotation. (I'm working in C++, but in quads, not vertices, so I had to reference the corona runtime to figure it out.)
My final rotation looks like this: (Note the negation at the front.)
-(slot->bone->worldRotation + rotation) * 3.14159f / 180.0f
Does anyone know whether Corpna's. image rotation functions rotate clockwise or counter-clockwise?
Chounard wroteDoes pygame work in radians or degrees? The numbers from Spine are in degrees, which I overlooked at first.
Another thing that took me awhile, was to figure out how to calculate the attachment rotation. (I'm working in C++, but in quads, not vertices, so I had to reference the corona runtime to figure it out.)
My final rotation looks like this: (Note the negation at the front.)
-(slot->bone->worldRotation + rotation) * 3.14159f / 180.0f
Hmmmm
I'm using math.radians() and I've quadruple checked my code against both Corona and C++ in terms of the mathematics.
But Pygame rotates counter-clockwise so I am wondering if that is different than other graphics libraries?
It looks like I've got an inversion happening on my Y-axis somewhere, so I'm trying to track that down. My root bone isn't in the right spot.
I've set my system up with x = 320, y = 240 but when the drawing code gets ahold of things the bone is at 320, -240.
Pygame uses degrees to rotate, so I think this is fine.
Still struggling with my root bone.
I've been combing through the code trying to figure out what's going on.
Here's the main initialization code and loop:
skeleton.flipX = False
skeleton.flipY = False
skeleton.setToBindPose()
rootBone = skeleton.getRootBone()
rootBone.x = 320
rootBone.y = 240
skeleton.setRootBone(rootBone)
skeleton.updateWorldTransform()
clock = pygame.time.Clock()
animationTime = 0.0
done = False
while not done:
clock.tick(60)
animationTime += clock.get_time() / 1000.0
animation.apply(skeleton=skeleton,
time=animationTime,
loop=True)
screen.fill((0, 0, 0))
skeleton.draw(screen, 0)
pygame.display.flip()
pygame.quit()
Here's my debug code for drawing the bone circles:
if self.debug:
for bone in self.bones:
if not bone.circle:
bone.circle = Circle(0, 0, 3)
bone.circle.x = int(bone.worldX)
bone.circle.y = -int(bone.worldY)
bone.circle.color = (0, 255, 0)
pygame.draw.circle(screen,
bone.circle.color,
(bone.circle.x, bone.circle.y),
bone.circle.r,
3)
When this debug code gets used, the bone.worldY is 240, so it gets flipped to -240 and my circle draws off screen.
This is exactly how Corona does it, so I can only assume that I've got something messed up somewhere that is supposed to be making bone.worldY negative before this drawing routine, but it's not happening.
Any ideas? I can't seem to figure out what's going on.
You don't need skeleton.setRootBone(rootBone). Doesn't help your problem though. I would not apply the animation until your are drawing the skeleton correctly.
Is 0,0 in the lower left corner of the screen? If so, then you have a y-up coordinate system like the libgdx runtime. Is 0,0 in the upper left corner of the screen? If so, then you have a y-down coordinate system like the Corona runtime.
If the negation is wrong, take it out. You might try not loading the bones from the file. Create a second bone parented to the root. Get those two bones to draw correctly with just translation, without any rotation and with scale at 1,1. Then add some rotation and make sure the two bones are in the correct place. Then go back to loading the skeleton from a file.
I would jump in the code and help out, but I'm swamped with other stuff at the moment. I've had a lot of non-coding stuff to get done and it's stressing me out, both that those tasks aren't finished and that I haven't been coding so I'm not making progress on the Kickstarter goals. :doh: