Properly format NEED_GRRLIB_FUNCTION example

This commit is contained in:
Crayon2000 2022-05-28 02:03:53 -04:00
parent 5126a84654
commit 3af649b2a9

View file

@ -1,11 +1,11 @@
/*=========================================== /*===========================================
NoNameNo NoNameNo
Since i cant code all these new function alone, Since I cant code all these new function alone,
i really need help to find the best way to provide I really need help to find the best way to provide
GRRLIB functions to all these new effets in this demo. GRRLIB functions to all these new effects in this demo.
With the help of the doc you can try also to find how it works, With the help of the doc you can try also to find how it works,
for exemple i didnt succes fully coded a specular position and direction.... for example I didn't success fully coded a specular position and direction...
So i repeat i need HELP !!! ;) So I repeat I need HELP !!! ;)
============================================*/ ============================================*/
#include <grrlib.h> #include <grrlib.h>
@ -25,8 +25,8 @@ int main() {
GXLightObj MyLight1; GXLightObj MyLight1;
int demo = 0; int demo = 0;
Mtx mr,mv,rx,ry,rz,m; Mtx mr, mv, rx, ry, rz, m;
GXTexObj texObj; GXTexObj texObj;
GRRLIB_Init(); GRRLIB_Init();
WPAD_Init(); WPAD_Init();
@ -47,207 +47,203 @@ int main() {
GRRLIB_2dMode(); GRRLIB_2dMode();
WPAD_ScanPads(); WPAD_ScanPads();
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) exit(0); if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) exit(0);
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_PLUS) if(demo<5) demo++; if(WPAD_ButtonsDown(0) & WPAD_BUTTON_PLUS && demo < 5) demo++;
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_MINUS) if(demo>0) demo--; if(WPAD_ButtonsDown(0) & WPAD_BUTTON_MINUS && demo > 0) demo--;
GRRLIB_3dMode(0.1,1000,45,0,1); GRRLIB_3dMode(0.1, 1000, 45, false, true);
if(demo==0) { if(demo==0) {
/////////////////// DEFINE A DIFUSE LIGHT ///////////////////////////////////////////// /////////////////// DEFINE A DIFFUSE LIGHT /////////////////////////////////////////////
guVector l0pos={0.0f,20.0f,0.0f}; guVector l0pos={0.0f,20.0f,0.0f};
guVecMultiply(_GRR_view, &l0pos, &l0pos); guVecMultiply(_GRR_view, &l0pos, &l0pos);
GX_InitLightPos(&MyLight0, l0pos.x, l0pos.y, l0pos.z); GX_InitLightPos(&MyLight0, l0pos.x, l0pos.y, l0pos.z);
GX_InitLightColor(&MyLight0, (GXColor) { 0xFF, 0x00, 0x00, 0xFF }); GX_InitLightColor(&MyLight0, (GXColor) { 0xFF, 0x00, 0x00, 0xFF });
GX_InitLightSpot(&MyLight0, 0.0f, GX_SP_OFF); GX_InitLightSpot(&MyLight0, 0.0f, GX_SP_OFF);
GX_InitLightDistAttn(&MyLight0, 20.0f, 1.0f, GX_DA_MEDIUM); // DistAttn = 20.0 & Brightness=1.0f (full) GX_InitLightDistAttn(&MyLight0, 20.0f, 1.0f, GX_DA_MEDIUM); // DistAttn = 20.0 & Brightness=1.0f (full)
GX_LoadLightObj(&MyLight0, GX_LIGHT0); GX_LoadLightObj(&MyLight0, GX_LIGHT0);
/////////////////////// Turn light ON //////////////////////////////////////////////// /////////////////////// Turn light ON ////////////////////////////////////////////////
GX_SetNumChans(1); GX_SetNumChans(1);
GX_SetChanCtrl(GX_COLOR0A0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0, GX_DF_CLAMP,GX_AF_SPOT); //4th param is where come from the material color (REG(with setChanMatColor or VTX (vertex)) same for ambiant (3th param) GX_SetChanCtrl(GX_COLOR0A0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0, GX_DF_CLAMP,GX_AF_SPOT); //4th param is where come from the material color (REG(with setChanMatColor or VTX (vertex)) same for ambiant (3th param)
/////////////////////// Define MAterial and Ambiant color and draw object ///////////////////////////////////// /////////////////////// Define Material and Ambiant color and draw object /////////////////////////////////////
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f); GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor) { 0x33, 0x33, 0x33, 0xFF}); GX_SetChanAmbColor(GX_COLOR0A0, (GXColor) { 0x33, 0x33, 0x33, 0xFF});
GX_SetChanMatColor(GX_COLOR0A0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF}); GX_SetChanMatColor(GX_COLOR0A0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true,0xFFFFFFFF); GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60, true, 0xFFFFFFFF);
a+=0.8f; a+=0.8f;
//////////////////////////// Turn light off and Write demo name //////////////////////////// Turn light off and Write demo name
GX_SetNumChans(1); GX_SetNumChans(1);
GX_SetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX, 0, GX_DF_NONE, GX_AF_NONE); GX_SetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX, 0, GX_DF_NONE, GX_AF_NONE);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GRRLIB_2dMode(); GRRLIB_2dMode();
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 1 Diffuse Light Source"); GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 1 Diffuse Light Source");
} }
else if(demo==1) {
/////////////////// DEFINE 2 DIFFUSE LIGHTS /////////////////////////////////////////////
guVector l0pos={0.0f,20.0f,0.0f};
guVecMultiply(_GRR_view, &l0pos, &l0pos);
GX_InitLightPos(&MyLight0, l0pos.x, l0pos.y, l0pos.z);
GX_InitLightColor(&MyLight0, (GXColor) { 0x00, 0xFF, 0x00, 0xFF });
GX_InitLightSpot(&MyLight0, 0.0f, GX_SP_OFF);
GX_InitLightDistAttn(&MyLight0, 20.0f, 1.0f, GX_DA_MEDIUM); // DistAttn = 20.0 & Brightness=1.0f (full)
GX_LoadLightObj(&MyLight0, GX_LIGHT0);
if(demo==1) { guVector l1pos={0.0f,-20.0f,0.0f};
/////////////////// DEFINE 2 DIFUSE LIGHTS ///////////////////////////////////////////// guVecMultiply(_GRR_view, &l1pos, &l1pos);
guVector l0pos={0.0f,20.0f,0.0f}; GX_InitLightPos(&MyLight1, l1pos.x, l1pos.y, l1pos.z);
guVecMultiply(_GRR_view, &l0pos, &l0pos); GX_InitLightColor(&MyLight1, (GXColor) { 0x00, 0x00, 0xFF, 0xFF });
GX_InitLightPos(&MyLight0, l0pos.x, l0pos.y, l0pos.z); GX_InitLightSpot(&MyLight1, 0.0f, GX_SP_OFF);
GX_InitLightColor(&MyLight0, (GXColor) { 0x00, 0xFF, 0x00, 0xFF }); GX_InitLightDistAttn(&MyLight1, 20.0f, 1.0f, GX_DA_MEDIUM); // DistAttn = 20.0 & Brightness=1.0f (full)
GX_InitLightSpot(&MyLight0, 0.0f, GX_SP_OFF); GX_LoadLightObj(&MyLight1, GX_LIGHT1);
GX_InitLightDistAttn(&MyLight0, 20.0f, 1.0f, GX_DA_MEDIUM); // DistAttn = 20.0 & Brightness=1.0f (full)
GX_LoadLightObj(&MyLight0, GX_LIGHT0);
guVector l1pos={0.0f,-20.0f,0.0f}; /////////////////////// Turn lights ON ////////////////////////////////////////////////
guVecMultiply(_GRR_view, &l1pos, &l1pos); GX_SetNumChans(1);
GX_InitLightPos(&MyLight1, l1pos.x, l1pos.y, l1pos.z); GX_SetChanCtrl(GX_COLOR0A0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0|GX_LIGHT1, GX_DF_CLAMP, GX_AF_SPOT); //4th param is where come from the material color (REG(with setChanMatColor or VTX (vertex)) same for ambiant (3th param)
GX_InitLightColor(&MyLight1, (GXColor) { 0x00, 0x00, 0xFF, 0xFF });
GX_InitLightSpot(&MyLight1, 0.0f, GX_SP_OFF);
GX_InitLightDistAttn(&MyLight1, 20.0f, 1.0f, GX_DA_MEDIUM); // DistAttn = 20.0 & Brightness=1.0f (full)
GX_LoadLightObj(&MyLight1, GX_LIGHT1);
/////////////////////// Turn lights ON //////////////////////////////////////////////// /////////////////////// Define Material and Ambiant color and draw object /////////////////////////////////////
GX_SetNumChans(1); GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
GX_SetChanCtrl(GX_COLOR0A0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0|GX_LIGHT1, GX_DF_CLAMP,GX_AF_SPOT); //4th param is where come from the material color (REG(with setChanMatColor or VTX (vertex)) same for ambiant (3th param) GX_SetChanAmbColor(GX_COLOR0A0, (GXColor) { 0x33, 0x33, 0x33, 0xFF});
GX_SetChanMatColor(GX_COLOR0A0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60, true, 0xFFFFFFFF);
a+=0.8f;
/////////////////////// Define MAterial and Ambiant color and draw object ///////////////////////////////////// //////////////////////////// Turn light off and Write demo name
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f); GX_SetNumChans(1);
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor) { 0x33, 0x33, 0x33, 0xFF}); GX_SetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX, 0, GX_DF_NONE, GX_AF_NONE);
GX_SetChanMatColor(GX_COLOR0A0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF}); GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true, 0xFFFFFFFF); GRRLIB_2dMode();
a+=0.8f; GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 2 Diffuse Light Sources");
}
else if(demo==2) {
/////////////////// DEFINE A SPECULAR LIGHT /////////////////////////////////////////////
guVector l0dir={0.0f,0.0f,0.0f};
GX_InitSpecularDir(&MyLight0, l0dir.x,l0dir.y,l0dir.z);
//////////////////////////// Turn light off and Write demo name GX_InitLightShininess(&MyLight0, 20); // between 4 and 255 !!!
GX_SetNumChans(1); GX_InitLightColor(&MyLight0, (GXColor){0xFF,0xFF,0xFF,0xFF});
GX_SetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX, 0, GX_DF_NONE, GX_AF_NONE); GX_LoadLightObj(&MyLight0, GX_LIGHT0);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GRRLIB_2dMode();
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 2 Diffuse Light Sources");
}
if(demo==2) { /////////////////////// Turn light ON ////////////////////////////////////////////////
/////////////////// DEFINE A SPECUALR LIGHT ///////////////////////////////////////////// GX_SetNumChans(2); // use two color channels
guVector l0dir={0.0f,0.0f,0.0f}; GX_SetChanCtrl(GX_COLOR0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0, GX_DF_CLAMP, GX_AF_NONE);
GX_InitSpecularDir(&MyLight0, l0dir.x,l0dir.y,l0dir.z); GX_SetChanCtrl(GX_COLOR1, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0, GX_DF_NONE, GX_AF_SPEC);
GX_SetChanCtrl(GX_ALPHA0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHTNULL, GX_DF_NONE, GX_AF_NONE);
GX_SetChanCtrl(GX_ALPHA1, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHTNULL, GX_DF_NONE, GX_AF_NONE);
GX_InitLightShininess(&MyLight0, 20); // entre 4 et 255 !!! GX_SetNumTevStages(2);
GX_InitLightColor(&MyLight0, (GXColor){0xFF,0xFF,0xFF,0xFF}); GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0);
GX_LoadLightObj(&MyLight0, GX_LIGHT0); GX_SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR1A1);
GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
GX_SetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV);
GX_SetTevColorIn(GX_TEVSTAGE1, GX_CC_CPREV, GX_CC_ONE, GX_CC_RASC, GX_CC_ZERO);
/////////////////////// Turn light ON //////////////////////////////////////////////// /////////////////////// Define Material and Ambiant color and draw object /////////////////////////////////////
GX_SetNumChans(2); // use two color channels GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
GX_SetChanCtrl(GX_COLOR0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0, GX_DF_CLAMP, GX_AF_NONE); GX_SetChanAmbColor(GX_COLOR0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
GX_SetChanCtrl(GX_COLOR1, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0, GX_DF_NONE, GX_AF_SPEC); GX_SetChanMatColor(GX_COLOR0, (GXColor) { 0x00, 0x00, 0x00, 0xFF});
GX_SetChanCtrl(GX_ALPHA0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHTNULL, GX_DF_NONE, GX_AF_NONE); GX_SetChanAmbColor(GX_COLOR1, (GXColor){0x00,0x00,0x00,0x00});
GX_SetChanCtrl(GX_ALPHA1, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHTNULL, GX_DF_NONE, GX_AF_NONE); GX_SetChanMatColor(GX_COLOR1, (GXColor){0xFF,0xFF,0xFF,0xFF});
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60, true, 0xFFFFFFFF);
a+=0.8f;
GX_SetNumTevStages(2); //////////////////////////// Turn light off and Write demo name
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0 ); GX_SetNumChans(1);
GX_SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR1A1 ); GX_SetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX, 0, GX_DF_NONE, GX_AF_NONE);
GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR); GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GX_SetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV ); GRRLIB_2dMode();
GX_SetTevColorIn(GX_TEVSTAGE1, GX_CC_CPREV, GX_CC_ONE, GX_CC_RASC, GX_CC_ZERO ); GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 1 Specular Source with shininess = 20");
}
else if(demo==3) {
/////////////////// DEFINE A SPECULAR LIGHT /////////////////////////////////////////////
guVector l0dir={0.0f,0.0f,0.0f};
GX_InitSpecularDir(&MyLight0, l0dir.x,l0dir.y,l0dir.z);
/////////////////////// Define MAterial and Ambiant color and draw object ///////////////////////////////////// GX_InitLightShininess(&MyLight0, 200); // between 4 and 255 !!!
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f); GX_InitLightColor(&MyLight0, (GXColor){0xFF,0xFF,0xFF,0xFF});
GX_SetChanAmbColor(GX_COLOR0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF}); GX_LoadLightObj(&MyLight0, GX_LIGHT0);
GX_SetChanMatColor(GX_COLOR0, (GXColor) { 0x00, 0x00, 0x00, 0xFF});
GX_SetChanAmbColor(GX_COLOR1, (GXColor){0x00,0x00,0x00,0x00});
GX_SetChanMatColor(GX_COLOR1, (GXColor){0xFF,0xFF,0xFF,0xFF});
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true, 0xFFFFFFFF);
a+=0.8f;
//////////////////////////// Turn light off and Write demo name /////////////////////// Turn light ON ////////////////////////////////////////////////
GX_SetNumChans(1); GX_SetNumChans(2); // use two color channels
GX_SetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX, 0, GX_DF_NONE, GX_AF_NONE); GX_SetChanCtrl(GX_COLOR0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0, GX_DF_CLAMP, GX_AF_NONE);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); GX_SetChanCtrl(GX_COLOR1, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0, GX_DF_NONE, GX_AF_SPEC);
GRRLIB_2dMode(); GX_SetChanCtrl(GX_ALPHA0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHTNULL, GX_DF_NONE, GX_AF_NONE);
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 1 Specular Source with shininess = 20"); GX_SetChanCtrl(GX_ALPHA1, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHTNULL, GX_DF_NONE, GX_AF_NONE);
}
if(demo==3) { GX_SetNumTevStages(2);
/////////////////// DEFINE A SPECUALR LIGHT ///////////////////////////////////////////// GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0);
guVector l0dir={0.0f,0.0f,0.0f}; GX_SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR1A1);
GX_InitSpecularDir(&MyLight0, l0dir.x,l0dir.y,l0dir.z); GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
GX_SetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV);
GX_SetTevColorIn(GX_TEVSTAGE1, GX_CC_CPREV, GX_CC_ONE, GX_CC_RASC, GX_CC_ZERO);
GX_InitLightShininess(&MyLight0, 200); // entre 4 et 255 !!! /////////////////////// Define Material and Ambiant color and draw object /////////////////////////////////////
GX_InitLightColor(&MyLight0, (GXColor){0xFF,0xFF,0xFF,0xFF}); GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
GX_LoadLightObj(&MyLight0, GX_LIGHT0); GX_SetChanAmbColor(GX_COLOR0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
GX_SetChanMatColor(GX_COLOR0, (GXColor) { 0x00, 0x00, 0x00, 0xFF});
GX_SetChanAmbColor(GX_COLOR1, (GXColor){0x00,0x00,0x00,0x00});
GX_SetChanMatColor(GX_COLOR1, (GXColor){0xFF,0xFF,0xFF,0xFF});
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true, 0xFFFFFFFF);
a+=0.8f;
/////////////////////// Turn light ON //////////////////////////////////////////////// //////////////////////////// Turn light off and Write demo name
GX_SetNumChans(2); // use two color channels GX_SetNumChans(1);
GX_SetChanCtrl(GX_COLOR0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0, GX_DF_CLAMP, GX_AF_NONE); GX_SetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX, 0, GX_DF_NONE, GX_AF_NONE);
GX_SetChanCtrl(GX_COLOR1, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0, GX_DF_NONE, GX_AF_SPEC); GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GX_SetChanCtrl(GX_ALPHA0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHTNULL, GX_DF_NONE, GX_AF_NONE); GRRLIB_2dMode();
GX_SetChanCtrl(GX_ALPHA1, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHTNULL, GX_DF_NONE, GX_AF_NONE); GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 1 Specular Source with shininess = 200");
}
else if(demo==4) {
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX3x4, GX_TG_NRM, GX_TEXMTX0); // We say we use the Normal coord to map the texture (since there is no textcoord with this torus)
guLightFrustum(mv, 1.0F, -1.0F, 1.0F, -1.0F, 1.0F, 0.5F, 0.5F, 0.5F, 0.5F); // we are projecting the texture like a light (ie : videoprojector))
GX_SetNumTevStages(2); guMtxScale(mr, -2.8f, -2.8f, 0.0f); //here is a little scaling to fit the torus
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0 ); guMtxConcat(mr, mv, mv);
GX_SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR1A1 );
GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
GX_SetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV );
GX_SetTevColorIn(GX_TEVSTAGE1, GX_CC_CPREV, GX_CC_ONE, GX_CC_RASC, GX_CC_ZERO );
/////////////////////// Define MAterial and Ambiant color and draw object ///////////////////////////////////// GX_LoadTexMtxImm(mv, GX_TEXMTX0, GX_MTX3x4);
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f); GX_InitTexObj(&texObj, tex_room->data, tex_room->w, tex_room->h, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
GX_SetChanAmbColor(GX_COLOR0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF}); GX_InitTexObjLOD(&texObj, GX_NEAR, GX_NEAR, 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_4);
GX_SetChanMatColor(GX_COLOR0, (GXColor) { 0x00, 0x00, 0x00, 0xFF}); GX_SetNumTexGens(1);
GX_SetChanAmbColor(GX_COLOR1, (GXColor){0x00,0x00,0x00,0x00}); GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
GX_SetChanMatColor(GX_COLOR1, (GXColor){0xFF,0xFF,0xFF,0xFF}); GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true, 0xFFFFFFFF); GX_LoadTexObj(&texObj, GX_TEXMAP0);
a+=0.8f;
//////////////////////////// Turn light off and Write demo name GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
GX_SetNumChans(1); GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60, true, 0xFFFFFFFF);
GX_SetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX, 0, GX_DF_NONE, GX_AF_NONE); a+=0.8f;
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GRRLIB_2dMode();
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 1 Specular Source with shininess = 200");
}
if(demo==4) {
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX3x4, GX_TG_NRM, GX_TEXMTX0); // We say we use the Normal coord to map the texture (since there is no textcoord with this torus)
guLightFrustum(mv, 1.0F, -1.0F, 1.0F, -1.0F, 1.0F, 0.5F, 0.5F, 0.5F, 0.5F); // we are projecting the texture like a light (ie : videoprojector))
guMtxScale(mr, -2.8f, -2.8f, 0.0f); //here is a little scaling to fit the torus GRRLIB_2dMode();
guMtxConcat(mr, mv, mv); GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo Mapping Using textgen from normal coord");
}
else if(demo==5) {
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX3x4, GX_TG_NRM, GX_TEXMTX0); // We say we use the Normal coord to map the texture (since there is no textcoord with this torus)
guLightFrustum(mv, 1.0F, -1.0F, 1.0F, -1.0F, 1.0F, 0.5F, 0.5F, 0.5F, 0.5F); // we are projecting the texture like a light (ie : videoprojector))
guMtxRotDeg(rx, 'X', a); // Here i rotate the texture
guMtxRotDeg(ry, 'Y', a*2); // in the inverse way
guMtxRotDeg(rz, 'Z', a*3); // of the
guMtxConcat(ry, rx, m); // rotation of
guMtxConcat(m, rz, m); // the object
guMtxConcat(mv, m, mv); // make it show the texture not moving.... ;)
GX_LoadTexMtxImm(mv, GX_TEXMTX0, GX_MTX3x4); guMtxScale(mr, -2.8f, -2.8f, 0.0f); //here is a little scaling to fit the torus
GX_InitTexObj(&texObj, tex_room->data, tex_room->w, tex_room->h, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE); guMtxConcat(mr, mv, mv);
GX_InitTexObjLOD(&texObj, GX_NEAR, GX_NEAR, 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_4);
GX_SetNumTexGens(1);
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GX_LoadTexObj(&texObj, GX_TEXMAP0);
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f); GX_LoadTexMtxImm(mv, GX_TEXMTX0, GX_MTX3x4);
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true, 0xFFFFFFFF); GX_InitTexObj(&texObj, tex_room->data, tex_room->w, tex_room->h, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
a+=0.8f; GX_InitTexObjLOD(&texObj, GX_NEAR, GX_NEAR, 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_4);
GX_SetNumTexGens(1);
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GX_LoadTexObj(&texObj, GX_TEXMAP0);
GRRLIB_2dMode(); GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo Mapping Using textgen from normal coord"); GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60, true, 0xFFFFFFFF);
} a+=0.8f;
if(demo==5) {
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX3x4, GX_TG_NRM, GX_TEXMTX0); // We say we use the Normal coord to map the texture (since there is no textcoord with this torus)
guLightFrustum(mv, 1.0F, -1.0F, 1.0F, -1.0F, 1.0F, 0.5F, 0.5F, 0.5F, 0.5F); // we are projecting the texture like a light (ie : videoprojector))
guMtxRotDeg(rx, 'X', a); // Here i rotate the texture
guMtxRotDeg(ry, 'Y', a*2); // in the inverse way
guMtxRotDeg(rz, 'Z', a*3); // of the
guMtxConcat(ry, rx, m); // rotation of
guMtxConcat(m, rz, m); // the object
guMtxConcat(mv, m, mv); // make it show the texture not moving.... ;)
guMtxScale(mr, -2.8f, -2.8f, 0.0f); //here is a little scaling to fit the torus
guMtxConcat(mr, mv, mv);
GX_LoadTexMtxImm(mv, GX_TEXMTX0, GX_MTX3x4);
GX_InitTexObj(&texObj, tex_room->data, tex_room->w, tex_room->h, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
GX_InitTexObjLOD(&texObj, GX_NEAR, GX_NEAR, 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_4);
GX_SetNumTexGens(1);
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GX_LoadTexObj(&texObj, GX_TEXMAP0);
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true, 0xFFFFFFFF);
a+=0.8f;
GRRLIB_2dMode();
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo Environmental Mapping");
}
GRRLIB_2dMode();
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo Environmental Mapping");
}
GRRLIB_Render(); GRRLIB_Render();
} }