mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 06:52:20 +00:00
[CHG] Code formatting
This commit is contained in:
parent
04cec42e7c
commit
f9e3976fd5
3 changed files with 97 additions and 95 deletions
|
@ -160,46 +160,45 @@ void GRRLIB_2dMode() {
|
|||
* @param scalz z scale of the object.
|
||||
*/
|
||||
void GRRLIB_ObjectView(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 angz, f32 scalx, f32 scaly, f32 scalz) {
|
||||
Mtx ObjTransformationMtx;
|
||||
Mtx m, rx,ry,rz;
|
||||
Mtx mv, mvi;
|
||||
Mtx ObjTransformationMtx;
|
||||
Mtx m, rx,ry,rz;
|
||||
Mtx mv, mvi;
|
||||
|
||||
guMtxIdentity(ObjTransformationMtx);
|
||||
guMtxIdentity(ObjTransformationMtx);
|
||||
|
||||
if((scalx !=1.0f) || (scaly !=1.0f) || (scalz !=1.0f)){
|
||||
guMtxIdentity(m);
|
||||
guMtxScaleApply(m, m, scalx, scaly, scalz);
|
||||
if((scalx !=1.0f) || (scaly !=1.0f) || (scalz !=1.0f)) {
|
||||
guMtxIdentity(m);
|
||||
guMtxScaleApply(m, m, scalx, scaly, scalz);
|
||||
|
||||
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
|
||||
}
|
||||
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
|
||||
}
|
||||
|
||||
if((angx !=0.0f) || (angy !=0.0f) || (angz !=0.0f)){
|
||||
guMtxIdentity(m);
|
||||
guMtxRotAxisDeg(rx, &_GRRaxisx, angx);
|
||||
guMtxRotAxisDeg(ry, &_GRRaxisy, angy);
|
||||
guMtxRotAxisDeg(rz, &_GRRaxisz, angz);
|
||||
guMtxConcat(ry, rx, m);
|
||||
guMtxConcat(m, rz, m);
|
||||
if((angx !=0.0f) || (angy !=0.0f) || (angz !=0.0f)) {
|
||||
guMtxIdentity(m);
|
||||
guMtxRotAxisDeg(rx, &_GRRaxisx, angx);
|
||||
guMtxRotAxisDeg(ry, &_GRRaxisy, angy);
|
||||
guMtxRotAxisDeg(rz, &_GRRaxisz, angz);
|
||||
guMtxConcat(ry, rx, m);
|
||||
guMtxConcat(m, rz, m);
|
||||
|
||||
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
|
||||
}
|
||||
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
|
||||
}
|
||||
|
||||
if((posx !=0.0f) || (posy !=0.0f) || (posz !=0.0f)){
|
||||
guMtxIdentity(m);
|
||||
guMtxTransApply(m, m, posx, posy, posz);
|
||||
if((posx !=0.0f) || (posy !=0.0f) || (posz !=0.0f)) {
|
||||
guMtxIdentity(m);
|
||||
guMtxTransApply(m, m, posx, posy, posz);
|
||||
|
||||
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
|
||||
}
|
||||
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
|
||||
}
|
||||
|
||||
guMtxConcat(_GRR_view, ObjTransformationMtx, mv);
|
||||
GX_LoadPosMtxImm(mv, GX_PNMTX0);
|
||||
guMtxConcat(_GRR_view, ObjTransformationMtx, mv);
|
||||
GX_LoadPosMtxImm(mv, GX_PNMTX0);
|
||||
|
||||
guMtxInverse(mv, mvi);
|
||||
guMtxTranspose(mvi, mv);
|
||||
GX_LoadNrmMtxImm(mv, GX_PNMTX0);
|
||||
guMtxInverse(mv, mvi);
|
||||
guMtxTranspose(mvi, mv);
|
||||
GX_LoadNrmMtxImm(mv, GX_PNMTX0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the view matrix to draw object (in this order scale, trans AND rotate).
|
||||
* @param posx x position of the object.
|
||||
|
@ -213,44 +212,43 @@ Mtx mv, mvi;
|
|||
* @param scalz z scale of the object.
|
||||
*/
|
||||
void GRRLIB_ObjectViewInv(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 angz, f32 scalx, f32 scaly, f32 scalz) {
|
||||
Mtx ObjTransformationMtx;
|
||||
Mtx m, rx,ry,rz;
|
||||
Mtx mv, mvi;
|
||||
Mtx ObjTransformationMtx;
|
||||
Mtx m, rx,ry,rz;
|
||||
Mtx mv, mvi;
|
||||
|
||||
guMtxIdentity(ObjTransformationMtx);
|
||||
guMtxIdentity(ObjTransformationMtx);
|
||||
|
||||
if((scalx !=1.0f) || (scaly !=1.0f) || (scalz !=1.0f)){
|
||||
guMtxIdentity(m);
|
||||
guMtxScaleApply(m, m, scalx, scaly, scalz);
|
||||
if((scalx !=1.0f) || (scaly !=1.0f) || (scalz !=1.0f)) {
|
||||
guMtxIdentity(m);
|
||||
guMtxScaleApply(m, m, scalx, scaly, scalz);
|
||||
|
||||
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
|
||||
}
|
||||
|
||||
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
|
||||
}
|
||||
if((posx !=0.0f) || (posy !=0.0f) || (posz !=0.0f)) {
|
||||
guMtxIdentity(m);
|
||||
guMtxTransApply(m, m, posx, posy, posz);
|
||||
|
||||
if((posx !=0.0f) || (posy !=0.0f) || (posz !=0.0f)){
|
||||
guMtxIdentity(m);
|
||||
guMtxTransApply(m, m, posx, posy, posz);
|
||||
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
|
||||
}
|
||||
|
||||
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
|
||||
}
|
||||
if((angx !=0.0f) || (angy !=0.0f) || (angz !=0.0f)) {
|
||||
guMtxIdentity(m);
|
||||
guMtxRotAxisDeg(rx, &_GRRaxisx, angx);
|
||||
guMtxRotAxisDeg(ry, &_GRRaxisy, angy);
|
||||
guMtxRotAxisDeg(rz, &_GRRaxisz, angz);
|
||||
guMtxConcat(ry, rx, m);
|
||||
guMtxConcat(m, rz, m);
|
||||
|
||||
if((angx !=0.0f) || (angy !=0.0f) || (angz !=0.0f)){
|
||||
guMtxIdentity(m);
|
||||
guMtxRotAxisDeg(rx, &_GRRaxisx, angx);
|
||||
guMtxRotAxisDeg(ry, &_GRRaxisy, angy);
|
||||
guMtxRotAxisDeg(rz, &_GRRaxisz, angz);
|
||||
guMtxConcat(ry, rx, m);
|
||||
guMtxConcat(m, rz, m);
|
||||
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
|
||||
}
|
||||
|
||||
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
|
||||
}
|
||||
guMtxConcat(_GRR_view, ObjTransformationMtx, mv);
|
||||
GX_LoadPosMtxImm(mv, GX_PNMTX0);
|
||||
|
||||
|
||||
guMtxConcat(_GRR_view, ObjTransformationMtx, mv);
|
||||
GX_LoadPosMtxImm(mv, GX_PNMTX0);
|
||||
|
||||
guMtxInverse(mv, mvi);
|
||||
guMtxTranspose(mvi, mv);
|
||||
GX_LoadNrmMtxImm(mv, GX_PNMTX0);
|
||||
guMtxInverse(mv, mvi);
|
||||
guMtxTranspose(mvi, mv);
|
||||
GX_LoadNrmMtxImm(mv, GX_PNMTX0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,6 +25,11 @@ THE SOFTWARE.
|
|||
* Inline functions for manipulating pixels in textures.
|
||||
*/
|
||||
|
||||
#define _SHIFTL(v, s, w) \
|
||||
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
|
||||
#define _SHIFTR(v, s, w) \
|
||||
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
|
||||
|
||||
/**
|
||||
* Return the color value of a pixel from a GRRLIB_texImg.
|
||||
* @param x Specifies the x-coordinate of the pixel in the texture.
|
||||
|
@ -69,31 +74,30 @@ void GRRLIB_SetPixelTotexImg (const int x, const int y,
|
|||
* Reads a pixel directly from the FrontBuffer.
|
||||
* @param x The x-coordinate within the FB.
|
||||
* @param y The y-coordinate within the FB.
|
||||
* @return The color of a pixel in RGBA format.
|
||||
*/
|
||||
INLINE
|
||||
u32 GRRLIB_GetPixelFromFB (int x, int y) {
|
||||
GXColor peekColor;
|
||||
u32 MyColor;
|
||||
u32 regval,val;
|
||||
|
||||
GX_PeekARGB(x, y, &peekColor);
|
||||
MyColor = RGBA(peekColor.r,peekColor.g,peekColor.b,peekColor.a);
|
||||
regval = 0xc8000000|(_SHIFTL(x,2,10));
|
||||
regval = (regval&~0x3FF000)|(_SHIFTL(y,12,10));
|
||||
val = *(u32*)regval;
|
||||
|
||||
return (MyColor);
|
||||
return RGBA(_SHIFTR(val,16,8), _SHIFTR(val,8,8), val&0xff, _SHIFTR(val,24,8));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a pixel directly from the FrontBuffer.
|
||||
* @param x The x-coordinate within the FB.
|
||||
* @param y The y-coordinate within the FB.
|
||||
* @param pokeColor The color of the pixel in RGBA format.
|
||||
*/
|
||||
INLINE
|
||||
void GRRLIB_SetPixelToFB (int x, int y, u32 pokeColor) {
|
||||
GXColor MyColor;
|
||||
u32 regval;
|
||||
|
||||
MyColor.r=R(pokeColor);
|
||||
MyColor.g=G(pokeColor);
|
||||
MyColor.b=B(pokeColor);
|
||||
MyColor.a=A(pokeColor);
|
||||
|
||||
GX_PokeARGB(x, y, MyColor);
|
||||
regval = 0xc8000000|(_SHIFTL(x,2,10));
|
||||
regval = (regval&~0x3FF000)|(_SHIFTL(y,12,10));
|
||||
*(u32*)regval = _SHIFTL(A(pokeColor),24,8) | _SHIFTL(R(pokeColor),16,8) | _SHIFTL(G(pokeColor),8,8) | (B(pokeColor)&0xff);
|
||||
}
|
||||
|
|
|
@ -39,35 +39,35 @@ int main() {
|
|||
|
||||
GRRLIB_Camera3dSettings(0.0f, 0.0f,13.0f, 0,1,0, 0,0,0);
|
||||
|
||||
GRRLIB_SetLightAmbient(0x333333FF);
|
||||
GRRLIB_SetLightDiff(0,(guVector){0.0f,0.0f,0.0f},20.0f,1.0f,0x00FFFFFF);
|
||||
GRRLIB_SetLightDiff(1,(guVector){0.0f,13.0f,3.0f},20.0f,1.0f,0xFF00FFFF);
|
||||
GRRLIB_SetLightDiff(2,(guVector){0.0f,-13.0f,3.0f},20.0f,1.0f,0xFFFF00FF);
|
||||
GRRLIB_SetLightDiff(3,(guVector){13.0f,0.0f,3.0f},20.0f,1.0f,0xFF0000FF);
|
||||
GRRLIB_SetLightDiff(4,(guVector){-13.0f,0.0f,3.0f},20.0f,1.0f,0x00FF00FF);
|
||||
GRRLIB_SetLightAmbient(0x333333FF);
|
||||
GRRLIB_SetLightDiff(0,(guVector){0.0f,0.0f,0.0f},20.0f,1.0f,0x00FFFFFF);
|
||||
GRRLIB_SetLightDiff(1,(guVector){0.0f,13.0f,3.0f},20.0f,1.0f,0xFF00FFFF);
|
||||
GRRLIB_SetLightDiff(2,(guVector){0.0f,-13.0f,3.0f},20.0f,1.0f,0xFFFF00FF);
|
||||
GRRLIB_SetLightDiff(3,(guVector){13.0f,0.0f,3.0f},20.0f,1.0f,0xFF0000FF);
|
||||
GRRLIB_SetLightDiff(4,(guVector){-13.0f,0.0f,3.0f},20.0f,1.0f,0x00FF00FF);
|
||||
|
||||
GRRLIB_3dMode(0.1,1000,45,0,1);
|
||||
|
||||
GRRLIB_ObjectViewInv(1.0f, -1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
|
||||
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
|
||||
GRRLIB_ObjectViewInv(-1.0f, -1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
|
||||
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
|
||||
GRRLIB_ObjectViewInv(1.0f, 1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
|
||||
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
|
||||
GRRLIB_ObjectViewInv(-1.0f, 1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
|
||||
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
|
||||
GRRLIB_ObjectViewInv(1.0f, -1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
|
||||
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
|
||||
GRRLIB_ObjectViewInv(-1.0f, -1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
|
||||
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
|
||||
GRRLIB_ObjectViewInv(1.0f, 1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
|
||||
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
|
||||
GRRLIB_ObjectViewInv(-1.0f, 1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
|
||||
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
|
||||
|
||||
GRRLIB_ObjectViewInv(1.0f, -1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
|
||||
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
|
||||
GRRLIB_ObjectViewInv(-1.0f, -1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
|
||||
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
|
||||
GRRLIB_ObjectViewInv(1.0f, 1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
|
||||
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
|
||||
GRRLIB_ObjectViewInv(-1.0f, 1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
|
||||
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
|
||||
GRRLIB_ObjectViewInv(1.0f, -1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
|
||||
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
|
||||
GRRLIB_ObjectViewInv(-1.0f, -1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
|
||||
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
|
||||
GRRLIB_ObjectViewInv(1.0f, 1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
|
||||
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
|
||||
GRRLIB_ObjectViewInv(-1.0f, 1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
|
||||
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
|
||||
|
||||
GRRLIB_ObjectView(0.0f, 0.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
|
||||
GRRLIB_DrawCube(3.0,true,0xFFFFFF44);
|
||||
GRRLIB_ObjectView(0.0f, 0.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
|
||||
GRRLIB_DrawCube(3.0, true, 0xFFFFFF44);
|
||||
|
||||
a+=0.6f;
|
||||
|
||||
|
|
Loading…
Reference in a new issue