2D sprite rotations help?

support for the powerpc toolchain
Post Reply
psycorpse
Posts: 9
Joined: Sun Sep 13, 2009 6:37 pm
Location: St Louis, MO USA
Contact:

2D sprite rotations help?

Post by psycorpse » Sun Apr 28, 2013 4:43 pm

I have looked through a couple of the libraries (grrlib and libsprite) to see how they apply rotations however I must not be understanding of what they are doing.

This code below is the closest to what I want however it is rotating on what I can only assume is 0, 0. I am trying to rotate it from the center of the quad.

Code: Select all

  guMtxIdentity(model);
  guMtxRotDeg(tmp, 'z', angle);
  guMtxTransApply(model, model, x + (w/2), y + (h/2), 0.0f);
  guMtxConcat(model, tmp, model);

  GX_LoadPosMtxImm(model, GX_PNMTX0);
I then tried to use the rotation code from lesson4.c in the nehe examples and then the quad doesn't even show on the screen.

Any help would be appreciated.
Currently doing 3ds game programming!
Website: http://www.stlwd.com

psycorpse
Posts: 9
Joined: Sun Sep 13, 2009 6:37 pm
Location: St Louis, MO USA
Contact:

Re: 2D sprite rotations help?

Post by psycorpse » Mon Apr 29, 2013 6:19 pm

It appears that in my GX_Position2f32() calls needed to be adjusted (assuming it is because the guMtxTransApply()).
So instead it needed to be something like.

w = width
h = height

Code: Select all

GX_Position2f32( - (w/2), -(h/2));
GX_Position2f32( w/2, -(h/2));
GX_Position2f32( w/2, h/2);
GX_Position2f32( -(w/2), h/2);
Currently doing 3ds game programming!
Website: http://www.stlwd.com

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest