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
Since i cant code all these new function alone,
i really need help to find the best way to provide
GRRLIB functions to all these new effets in this demo.
Since I cant code all these new function alone,
I really need help to find the best way to provide
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,
for exemple i didnt succes fully coded a specular position and direction....
So i repeat i need HELP !!! ;)
for example I didn't success fully coded a specular position and direction...
So I repeat I need HELP !!! ;)
============================================*/
#include <grrlib.h>
@ -25,8 +25,8 @@ int main() {
GXLightObj MyLight1;
int demo = 0;
Mtx mr,mv,rx,ry,rz,m;
GXTexObj texObj;
Mtx mr, mv, rx, ry, rz, m;
GXTexObj texObj;
GRRLIB_Init();
WPAD_Init();
@ -47,207 +47,203 @@ int main() {
GRRLIB_2dMode();
WPAD_ScanPads();
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_MINUS) if(demo>0) demo--;
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_PLUS && demo < 5) 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) {
/////////////////// DEFINE A DIFUSE LIGHT /////////////////////////////////////////////
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) { 0xFF, 0x00, 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==0) {
/////////////////// DEFINE A DIFFUSE LIGHT /////////////////////////////////////////////
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) { 0xFF, 0x00, 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);
/////////////////////// Turn light ON ////////////////////////////////////////////////
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)
/////////////////////// Turn light ON ////////////////////////////////////////////////
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)
/////////////////////// Define MAterial and Ambiant color and draw object /////////////////////////////////////
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_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 /////////////////////////////////////
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_SetChanMatColor(GX_COLOR0A0, (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
GX_SetNumChans(1);
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);
GRRLIB_2dMode();
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 1 Diffuse Light Source");
}
//////////////////////////// Turn light off and Write demo name
GX_SetNumChans(1);
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);
GRRLIB_2dMode();
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) {
/////////////////// DEFINE 2 DIFUSE 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);
guVector l1pos={0.0f,-20.0f,0.0f};
guVecMultiply(_GRR_view, &l1pos, &l1pos);
GX_InitLightPos(&MyLight1, l1pos.x, l1pos.y, l1pos.z);
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);
guVector l1pos={0.0f,-20.0f,0.0f};
guVecMultiply(_GRR_view, &l1pos, &l1pos);
GX_InitLightPos(&MyLight1, l1pos.x, l1pos.y, l1pos.z);
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 ////////////////////////////////////////////////
GX_SetNumChans(1);
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)
/////////////////////// Turn lights ON ////////////////////////////////////////////////
GX_SetNumChans(1);
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)
/////////////////////// Define Material and Ambiant color and draw object /////////////////////////////////////
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_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 /////////////////////////////////////
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_SetChanMatColor(GX_COLOR0A0, (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
GX_SetNumChans(1);
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);
GRRLIB_2dMode();
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_SetNumChans(1);
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);
GRRLIB_2dMode();
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 2 Diffuse Light Sources");
}
GX_InitLightShininess(&MyLight0, 20); // between 4 and 255 !!!
GX_InitLightColor(&MyLight0, (GXColor){0xFF,0xFF,0xFF,0xFF});
GX_LoadLightObj(&MyLight0, GX_LIGHT0);
if(demo==2) {
/////////////////// DEFINE A SPECUALR LIGHT /////////////////////////////////////////////
guVector l0dir={0.0f,0.0f,0.0f};
GX_InitSpecularDir(&MyLight0, l0dir.x,l0dir.y,l0dir.z);
/////////////////////// Turn light ON ////////////////////////////////////////////////
GX_SetNumChans(2); // use two color channels
GX_SetChanCtrl(GX_COLOR0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0, GX_DF_CLAMP, GX_AF_NONE);
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_InitLightColor(&MyLight0, (GXColor){0xFF,0xFF,0xFF,0xFF});
GX_LoadLightObj(&MyLight0, GX_LIGHT0);
GX_SetNumTevStages(2);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0);
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 ////////////////////////////////////////////////
GX_SetNumChans(2); // use two color channels
GX_SetChanCtrl(GX_COLOR0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0, GX_DF_CLAMP, GX_AF_NONE);
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);
/////////////////////// Define Material and Ambiant color and draw object /////////////////////////////////////
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
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;
GX_SetNumTevStages(2);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0 );
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 off and Write demo name
GX_SetNumChans(1);
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);
GRRLIB_2dMode();
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 /////////////////////////////////////
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
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;
GX_InitLightShininess(&MyLight0, 200); // between 4 and 255 !!!
GX_InitLightColor(&MyLight0, (GXColor){0xFF,0xFF,0xFF,0xFF});
GX_LoadLightObj(&MyLight0, GX_LIGHT0);
//////////////////////////// Turn light off and Write demo name
GX_SetNumChans(1);
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);
GRRLIB_2dMode();
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 1 Specular Source with shininess = 20");
}
/////////////////////// Turn light ON ////////////////////////////////////////////////
GX_SetNumChans(2); // use two color channels
GX_SetChanCtrl(GX_COLOR0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0, GX_DF_CLAMP, GX_AF_NONE);
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);
if(demo==3) {
/////////////////// DEFINE A SPECUALR LIGHT /////////////////////////////////////////////
guVector l0dir={0.0f,0.0f,0.0f};
GX_InitSpecularDir(&MyLight0, l0dir.x,l0dir.y,l0dir.z);
GX_SetNumTevStages(2);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0);
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);
GX_InitLightShininess(&MyLight0, 200); // entre 4 et 255 !!!
GX_InitLightColor(&MyLight0, (GXColor){0xFF,0xFF,0xFF,0xFF});
GX_LoadLightObj(&MyLight0, GX_LIGHT0);
/////////////////////// Define Material and Ambiant color and draw object /////////////////////////////////////
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
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 ////////////////////////////////////////////////
GX_SetNumChans(2); // use two color channels
GX_SetChanCtrl(GX_COLOR0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0, GX_DF_CLAMP, GX_AF_NONE);
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);
//////////////////////////// Turn light off and Write demo name
GX_SetNumChans(1);
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);
GRRLIB_2dMode();
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);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0 );
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 );
guMtxScale(mr, -2.8f, -2.8f, 0.0f); //here is a little scaling to fit the torus
guMtxConcat(mr, mv, mv);
/////////////////////// Define MAterial and Ambiant color and draw object /////////////////////////////////////
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
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;
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);
//////////////////////////// Turn light off and Write demo name
GX_SetNumChans(1);
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);
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))
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;
guMtxScale(mr, -2.8f, -2.8f, 0.0f); //here is a little scaling to fit the torus
guMtxConcat(mr, mv, mv);
GRRLIB_2dMode();
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);
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);
guMtxScale(mr, -2.8f, -2.8f, 0.0f); //here is a little scaling to fit the torus
guMtxConcat(mr, mv, mv);
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;
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_2dMode();
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo Mapping Using textgen from normal coord");
}
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_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_Render();
}