From bd14db7c46bf4548401277915b465a19dc32122b Mon Sep 17 00:00:00 2001 From: Xane Date: Mon, 9 Mar 2009 01:43:03 +0000 Subject: [PATCH] [CHG] Separated SetHandle and SetOffset for more control when rotating. --- GRRLIB/GRRLIB/GRRLIB.c | 19 ++++++++++++++----- GRRLIB/GRRLIB/GRRLIB.h | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/GRRLIB/GRRLIB/GRRLIB.c b/GRRLIB/GRRLIB/GRRLIB.c index f497e03..a6d353f 100644 --- a/GRRLIB/GRRLIB/GRRLIB.c +++ b/GRRLIB/GRRLIB/GRRLIB.c @@ -565,7 +565,7 @@ inline void GRRLIB_DrawImg(f32 xpos, f32 ypos, struct GRRLIB_texImg tex, float d guMtxRotAxisDeg (m2, &axis, degrees); guMtxConcat(m2, m1, m); - guMtxTransApply(m, m, xpos+width+tex.handlex-tex.offsetx+(scaleX*( -tex.handley*sin(-DegToRad(degrees)) - tex.handlex*cos(-DegToRad(degrees)) )), ypos+height+tex.handley-tex.offsety+(scaleX*( -tex.handley*cos(-DegToRad(degrees)) + tex.handlex*sin(-DegToRad(degrees)) )), 0); + guMtxTransApply(m, m, xpos+width+tex.handlex+tex.offsetx+(scaleX*( -tex.handley*sin(-DegToRad(degrees)) - tex.handlex*cos(-DegToRad(degrees)) )), ypos+height+tex.handley+tex.offsety+(scaleX*( -tex.handley*cos(-DegToRad(degrees)) + tex.handlex*sin(-DegToRad(degrees)) )), 0); guMtxConcat(GXmodelView2D, m, mv); GX_LoadPosMtxImm(mv, GX_PNMTX0); @@ -683,7 +683,7 @@ inline void GRRLIB_DrawTile(f32 xpos, f32 ypos, struct GRRLIB_texImg tex, float Vector axis = (Vector) {0, 0, 1 }; guMtxRotAxisDeg(m2, &axis, degrees); guMtxConcat(m2, m1, m); - guMtxTransApply(m, m, xpos+width+tex.handlex-tex.offsetx+(scaleX*( -tex.handley*sin(-DegToRad(degrees)) - tex.handlex*cos(-DegToRad(degrees)) )), ypos+height+tex.handley-tex.offsety+(scaleX*( -tex.handley*cos(-DegToRad(degrees)) + tex.handlex*sin(-DegToRad(degrees)) )), 0); + guMtxTransApply(m, m, xpos+width+tex.handlex+tex.offsetx+(scaleX*( -tex.handley*sin(-DegToRad(degrees)) - tex.handlex*cos(-DegToRad(degrees)) )), ypos+height+tex.handley+tex.offsety+(scaleX*( -tex.handley*cos(-DegToRad(degrees)) + tex.handlex*sin(-DegToRad(degrees)) )), 0); guMtxConcat(GXmodelView2D, m, mv); GX_LoadPosMtxImm(mv, GX_PNMTX0); @@ -808,8 +808,8 @@ void GRRLIB_ClipReset() { /** * Set a texture's X and Y handles (e.g. for rotation). * @param tex The texture to set the handle on. - * @param x The handle's x-coordinate. - * @param y The handle's y-coordinate. + * @param x The x-coordinate of the handle. + * @param y The y-coordinate of the handle. */ void GRRLIB_SetHandle( struct GRRLIB_texImg * tex, int x, int y ) { if (tex->tiledtex) { @@ -819,6 +819,15 @@ void GRRLIB_SetHandle( struct GRRLIB_texImg * tex, int x, int y ) { tex->handlex = -(((int)tex->w)/2) + x; tex->handley = -(((int)tex->h)/2) + y; } +} + +/** + * Set a texture's X and Y offset (e.g. for rotation). + * @param tex The texture to set the handle on. + * @param x The x-coordinate of the offset. + * @param y The y-coordinate of the offset. + */ +void GRRLIB_SetOffset( struct GRRLIB_texImg * tex, int x, int y ) { tex->offsetx = x; tex->offsety = y; } @@ -1266,7 +1275,7 @@ int GRRLIB_ListDelTexture( struct GRRLIB_texImg *img ) { if (!temp) { return false; } // List is empty. while ( temp->next ) { if (temp->texture == img) { // <- Doesn't really work, need to find another way. :x - return true; + return 1337; //free(img->data); //free(img); //GRRLIB_ListRemove( &temp ); diff --git a/GRRLIB/GRRLIB/GRRLIB.h b/GRRLIB/GRRLIB/GRRLIB.h index d9c059a..c5659e4 100644 --- a/GRRLIB/GRRLIB/GRRLIB.h +++ b/GRRLIB/GRRLIB/GRRLIB.h @@ -140,6 +140,7 @@ void GRRLIB_ClipDrawing( int x, int y, int width, int height ); void GRRLIB_ClipReset(); void GRRLIB_SetHandle(struct GRRLIB_texImg * tex, int x, int y); +void GRRLIB_SetOffset( struct GRRLIB_texImg * tex, int x, int y ); void GRRLIB_SetMidHandle(struct GRRLIB_texImg * tex); u32 GRRLIB_GetPixelFromtexImg(int x, int y, struct GRRLIB_texImg tex);