terrymisu

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

http://youtu.be/MiiUMWTkZzk
Аватара пользователя
terrymisu

Kickstarter Backer
  • Сообщения: 136

terrymisu

terrymisu писал(а):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
Аватара пользователя
terrymisu

Kickstarter Backer
  • Сообщения: 136

terrymisu

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
Аватара пользователя
terrymisu

Kickstarter Backer
  • Сообщения: 136

Nate

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

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

Nate
  • Сообщения: 9845

terrymisu

Nate писал(а):Haha rotation is a little messed up, but nice sword! :D

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?
Аватара пользователя
terrymisu

Kickstarter Backer
  • Сообщения: 136

Søren

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.
Аватара пользователя
Søren

Shiu
  • Сообщения: 2396

terrymisu

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)?
Аватара пользователя
terrymisu

Kickstarter Backer
  • Сообщения: 136

Søren

Afaik the end point is calculated by the rotation and length of the bone.
Аватара пользователя
Søren

Shiu
  • Сообщения: 2396

Nate

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;
Аватара пользователя
Nate

Nate
  • Сообщения: 9845

terrymisu

Ok, I think I have my bones drawing properly now.

There's something fundamentally wrong with the pose @ frame 0, though... he's got the wrong posture... any ideas?

Аватара пользователя
terrymisu

Kickstarter Backer
  • Сообщения: 136

terrymisu

Interesting... something to do with setToBindPose()

Check this out!

Аватара пользователя
terrymisu

Kickstarter Backer
  • Сообщения: 136

terrymisu

terrymisu писал(а):Interesting... something to do with setToBindPose()

Check this out!

Ok, but now it's not animating... grrr so close! ;)
Аватара пользователя
terrymisu

Kickstarter Backer
  • Сообщения: 136

terrymisu

If I call skeleton.updateWorldTransform() once outside of my while loop but not inside the while loop, the skeleton draws properly. This works even if I don't call skeleton.setToBindPose() anywhere.

If I call skeleton.updateWorldTransform() inside my while loop, things don't draw properly.

Any thoughts as to what might be causing this? A timeline issue perhaps?

Here's the code that draws the initial pose correctly:
#!/usr/bin/env python

import os

import pygame

import pyguts as spine

if __name__ == '__main__':
pygame.init()

width, height = (640, 480)

screen = pygame.display.set_mode((width, height))
screen.fill((0,0,0))
caption = 'PyGuts - A Pygame front-end based on the python-spine Runtime'
pygame.display.set_caption(caption, 'Spine Runtime')

atlasFile = os.path.realpath('./data/spineboy.atlas')
atlas = spine.Atlas(file=atlasFile)

skeletonJson = spine.SkeletonJson(spine.AtlasAttachmentLoader(atlas))

skeletonFile = os.path.realpath('./data/spineboy-skeleton.json')
skeletonData = skeletonJson.readSkeletonData(skeletonFile)

animationFile = os.path.realpath('./data/spineboy-walk.json')
animation = skeletonJson.readAnimation(file=animationFile,
skeletonData=skeletonData)

skeleton = spine.Skeleton(skeletonData=skeletonData)
skeleton.debug = True

skeleton.x = 320
skeleton.y = 400
skeleton.flipX = False
skeleton.flipY = False
skeleton.updateWorldTransform()

clock = pygame.time.Clock()
animationTime = 0.0

done = False

while not done:
clock.tick(0)
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.set_caption('%s %.2f' % (caption, clock.get_fps()), 'Spine Runtime')
pygame.display.flip()
pygame.quit()
Аватара пользователя
terrymisu

Kickstarter Backer
  • Сообщения: 136

Lazrhog

you have the same aliasing issue I had to start with too.
Аватара пользователя
Lazrhog

Kickstarter Backer
  • Сообщения: 70

terrymisu

Lazrhog писал(а):you have the same aliasing issue I had to start with too.
I'm not sure what that means.
Аватара пользователя
terrymisu

Kickstarter Backer
  • Сообщения: 136

Lazrhog

You have slightly dark lines around all your sprites, where the alpha blending is not working. When you make your Texture Atlas, you need to have pre-multiplied alpha and use the correct blending mode

(see my other thread for a before and after image where I had to correct it)
Аватара пользователя
Lazrhog

Kickstarter Backer
  • Сообщения: 70

terrymisu

Lazrhog писал(а):You have slightly dark lines around all your sprites, where the alpha blending is not working. When you make your Texture Atlas, you need to have pre-multiplied alpha and use the correct blending mode

(see my other thread for a before and after image where I had to correct it)
Ahh.... Yeah, I don't think Pygame supports all of the necessary blending modes, but I'll look at that stuff once I have my animation working properly. :) Thanks for the heads up.
Аватара пользователя
terrymisu

Kickstarter Backer
  • Сообщения: 136

terrymisu

The Python animation bugs I've been chasing have finally been squashed.

http://youtu.be/On242LJ0Olo

The issue was that when you apply a rotation to an image in Pygame (maybe this is true always?) the image's width and height change, so for a system where the x, y of the image is the top-left corner, you have to subtract (width / 2, height / 2) *AFTER* performing the transformation.

I was applying those prior to transforming, so the images were off by a bit, and what a pain to track down!
Аватара пользователя
terrymisu

Kickstarter Backer
  • Сообщения: 136

terrymisu

I have the dragon example running. There were some Atlas loading problems that would prevent atlases with more than 1 sprite sheet to fail to load.

I also fixed some bugs related to importing skeleton data and animation when certain keys were missing from the JSON files.

The latest code is up on github, and pypi.python.org.
Аватара пользователя
terrymisu

Kickstarter Backer
  • Сообщения: 136

terrymisu

Nate писал(а):Haha rotation is a little messed up, but nice sword! :D

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.
Ok, I'm ready to tackle this.

I can scale by integer values for both x, and y, but I can't scale the x and y separately with floats.

I can scale equal x and y with floats.

What's the best way to implement this? The images have float-value scaleX/scaleY, so it isn't apparent to me how to make this work, given the APIs I have available to me.

Here's the pygame documentation on transformations, for reference... maybe there's something in there that I'm not seeing.

http://www.pygame.org/docs/ref/transform.html

rotozoom will take a single scale value (float).

scale, and smoothscale will take an integer for the width/height of the new image, but not float.
Аватара пользователя
terrymisu

Kickstarter Backer
  • Сообщения: 136

terrymisu

Ahhh... duh.

Since scale and smoothscale take width, height I can multiply the scale by those... ;)

Looks like I got it working.
Аватара пользователя
terrymisu

Kickstarter Backer
  • Сообщения: 136

terrymisu

Hrm... any idea why my spineboy is so stiff looking?

I exported these straight from Spine, so it's the latest example.

http://www.youtube.com/watch?v=4S3wCtJ711o
Аватара пользователя
terrymisu

Kickstarter Backer
  • Сообщения: 136

Lazrhog

Instead of using the correct time difference for the animation. Put a really small number in so you can see where it is going wrong in more detail
Аватара пользователя
Lazrhog

Kickstarter Backer
  • Сообщения: 70

terrymisu

Yeah, I did that...

I stepped through with spacebar incrementing the animation time by 1 each time, and it sort of looks like his arm gets to key frame 20, and then snaps back to key frame 0 (or 32?), but that doesn't make sense to me.
Аватара пользователя
terrymisu

Kickstarter Backer
  • Сообщения: 136

terrymisu

I got mixing working:

There are still a couple of bugs... but the major features are present! :love: :beer: :party:

http://www.youtube.com/watch?v=nHHDglon6jk
Аватара пользователя
terrymisu

Kickstarter Backer
  • Сообщения: 136


Вернуться в Editor