Page 1 of 1

2D sprite rotations help?

Posted: Sun Apr 28, 2013 4:43 pm
by psycorpse
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.

Re: 2D sprite rotations help?

Posted: Mon Apr 29, 2013 6:19 pm
by psycorpse
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);