mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-10 10:22:20 +00:00
[CHG] Separated SetHandle and SetOffset for more control when rotating.
This commit is contained in:
parent
e4152ff067
commit
bd14db7c46
2 changed files with 15 additions and 5 deletions
|
@ -565,7 +565,7 @@ inline void GRRLIB_DrawImg(f32 xpos, f32 ypos, struct GRRLIB_texImg tex, float d
|
||||||
guMtxRotAxisDeg (m2, &axis, degrees);
|
guMtxRotAxisDeg (m2, &axis, degrees);
|
||||||
guMtxConcat(m2, m1, m);
|
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);
|
guMtxConcat(GXmodelView2D, m, mv);
|
||||||
|
|
||||||
GX_LoadPosMtxImm(mv, GX_PNMTX0);
|
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 };
|
Vector axis = (Vector) {0, 0, 1 };
|
||||||
guMtxRotAxisDeg(m2, &axis, degrees);
|
guMtxRotAxisDeg(m2, &axis, degrees);
|
||||||
guMtxConcat(m2, m1, m);
|
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);
|
guMtxConcat(GXmodelView2D, m, mv);
|
||||||
|
|
||||||
GX_LoadPosMtxImm(mv, GX_PNMTX0);
|
GX_LoadPosMtxImm(mv, GX_PNMTX0);
|
||||||
|
@ -808,8 +808,8 @@ void GRRLIB_ClipReset() {
|
||||||
/**
|
/**
|
||||||
* Set a texture's X and Y handles (e.g. for rotation).
|
* Set a texture's X and Y handles (e.g. for rotation).
|
||||||
* @param tex The texture to set the handle on.
|
* @param tex The texture to set the handle on.
|
||||||
* @param x The handle's x-coordinate.
|
* @param x The x-coordinate of the handle.
|
||||||
* @param y The handle's y-coordinate.
|
* @param y The y-coordinate of the handle.
|
||||||
*/
|
*/
|
||||||
void GRRLIB_SetHandle( struct GRRLIB_texImg * tex, int x, int y ) {
|
void GRRLIB_SetHandle( struct GRRLIB_texImg * tex, int x, int y ) {
|
||||||
if (tex->tiledtex) {
|
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->handlex = -(((int)tex->w)/2) + x;
|
||||||
tex->handley = -(((int)tex->h)/2) + y;
|
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->offsetx = x;
|
||||||
tex->offsety = y;
|
tex->offsety = y;
|
||||||
}
|
}
|
||||||
|
@ -1266,7 +1275,7 @@ int GRRLIB_ListDelTexture( struct GRRLIB_texImg *img ) {
|
||||||
if (!temp) { return false; } // List is empty.
|
if (!temp) { return false; } // List is empty.
|
||||||
while ( temp->next ) {
|
while ( temp->next ) {
|
||||||
if (temp->texture == img) { // <- Doesn't really work, need to find another way. :x
|
if (temp->texture == img) { // <- Doesn't really work, need to find another way. :x
|
||||||
return true;
|
return 1337;
|
||||||
//free(img->data);
|
//free(img->data);
|
||||||
//free(img);
|
//free(img);
|
||||||
//GRRLIB_ListRemove( &temp );
|
//GRRLIB_ListRemove( &temp );
|
||||||
|
|
|
@ -140,6 +140,7 @@ void GRRLIB_ClipDrawing( int x, int y, int width, int height );
|
||||||
void GRRLIB_ClipReset();
|
void GRRLIB_ClipReset();
|
||||||
|
|
||||||
void GRRLIB_SetHandle(struct GRRLIB_texImg * tex, int x, int y);
|
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);
|
void GRRLIB_SetMidHandle(struct GRRLIB_texImg * tex);
|
||||||
|
|
||||||
u32 GRRLIB_GetPixelFromtexImg(int x, int y, struct GRRLIB_texImg tex);
|
u32 GRRLIB_GetPixelFromtexImg(int x, int y, struct GRRLIB_texImg tex);
|
||||||
|
|
Loading…
Reference in a new issue