[CHG] Separated SetHandle and SetOffset for more control when rotating.

This commit is contained in:
Xane 2009-03-09 01:43:03 +00:00
parent e4152ff067
commit bd14db7c46
2 changed files with 15 additions and 5 deletions

View file

@ -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 );

View file

@ -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);