mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-12-22 18:39:18 +00:00
[CHG] Files cleanup
This commit is contained in:
parent
45a9b43afb
commit
25876beeb9
2 changed files with 53 additions and 56 deletions
|
@ -103,7 +103,6 @@ void GRRLIB_3dMode(f32 minDist, f32 maxDist, f32 fov, bool colormode, bool textu
|
|||
|
||||
if(texturemode==FALSE) GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
|
||||
else GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,7 +169,6 @@ void GRRLIB_ObjectView(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 ang
|
|||
GX_LoadNrmMtxImm(mv, GX_PNMTX0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the texture to an object (contributed by chris_c aka DaShAmAn).
|
||||
* @param tex poiter to an image texture (GRRLIB_texImg format).
|
||||
|
@ -199,44 +197,43 @@ void GRRLIB_SetTexture(GRRLIB_texImg *tex, bool rep) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Initialise a Diffuse Light.
|
||||
* @param id a light ID in libogc style : GX_LIGHT0,..., GX_LIGHT7).
|
||||
* @param lpos a guVector x,y,z position of the light.
|
||||
* @param lcol color of the light.
|
||||
* Initialise a diffuse light.
|
||||
* @param id A light ID in libogc style : GX_LIGHT0,..., GX_LIGHT7.
|
||||
* @param lpos A guVector x,y,z position of the light.
|
||||
* @param lcol Color of the light.
|
||||
*/
|
||||
void GRRLIB_InitLight(u8 id, guVector lpos, u32 lcol){
|
||||
GXLightObj MyLight;
|
||||
guVecMultiply(_GRR_view, &lpos, &lpos);
|
||||
GX_InitLightPos(&MyLight, lpos.x, lpos.y, lpos.z);
|
||||
GX_InitLightColor(&MyLight, (GXColor) { R(lcol), G(lcol),B(lcol), A(lcol) });
|
||||
GX_InitLightAttn(&MyLight, 1.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F);
|
||||
GX_LoadLightObj(&MyLight, id);
|
||||
void GRRLIB_InitLight(u8 id, guVector lpos, u32 lcol) {
|
||||
GXLightObj MyLight;
|
||||
guVecMultiply(_GRR_view, &lpos, &lpos);
|
||||
GX_InitLightPos(&MyLight, lpos.x, lpos.y, lpos.z);
|
||||
GX_InitLightColor(&MyLight, (GXColor) { R(lcol), G(lcol),B(lcol), A(lcol) });
|
||||
GX_InitLightAttn(&MyLight, 1.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F);
|
||||
GX_LoadLightObj(&MyLight, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* All Light Off, colors come from the Vertex.
|
||||
* All light off, colors come from the Vertex.
|
||||
*/
|
||||
void GRRLIB_LightOff(void){
|
||||
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);
|
||||
void GRRLIB_LightOff(void) {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what light to turn on and some other param.
|
||||
* @param id light IDs of the desired switched ON lights (ORed) (ie GX_LIGHT0|GX_LIGHT7).
|
||||
* @param id Light IDs of the desired switched ON lights (ORed) (ie GX_LIGHT0|GX_LIGHT7).
|
||||
* @param ambcol Ambiant color u32 formated
|
||||
* @param matcol Material color u32 formated.
|
||||
* @param colsrc Material color sources comes from the Vertex ???? (True/False)
|
||||
*/
|
||||
void GRRLIB_LightSwitch(u8 id, u32 ambcol, u32 matcol, u8 colsrc){
|
||||
u8 src;
|
||||
if(colsrc==0) src = GX_SRC_REG;
|
||||
else src = GX_SRC_VTX;
|
||||
void GRRLIB_LightSwitch(u8 id, u32 ambcol, u32 matcol, u8 colsrc) {
|
||||
u8 src;
|
||||
if(colsrc==0) src = GX_SRC_REG;
|
||||
else src = GX_SRC_VTX;
|
||||
|
||||
GX_SetNumChans(1);
|
||||
GX_SetChanCtrl(GX_COLOR0A0, GX_ENABLE, GX_SRC_REG, src, id, GX_DF_CLAMP,GX_AF_SPOT);
|
||||
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor) { R(ambcol), G(ambcol), B(ambcol), A(ambcol)});
|
||||
GX_SetChanMatColor(GX_COLOR0A0, (GXColor) { R(matcol), G(matcol), B(matcol), A(matcol)});
|
||||
GX_SetNumChans(1);
|
||||
GX_SetChanCtrl(GX_COLOR0A0, GX_ENABLE, GX_SRC_REG, src, id, GX_DF_CLAMP,GX_AF_SPOT);
|
||||
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor) { R(ambcol), G(ambcol), B(ambcol), A(ambcol)});
|
||||
GX_SetChanMatColor(GX_COLOR0A0, (GXColor) { R(matcol), G(matcol), B(matcol), A(matcol)});
|
||||
}
|
||||
|
||||
|
|
|
@ -31,26 +31,26 @@ typedef struct GRRLIB_3dObj {
|
|||
#include "torus.h"
|
||||
|
||||
|
||||
void GRRLIB_Draw3dObj(GRRLIB_3dObj obj, u32 col, bool tex, bool norm){
|
||||
int i;
|
||||
GX_Begin(GX_TRIANGLES, GX_VTXFMT0, obj.NbFace*3);
|
||||
for(i=0;i<obj.NbFace*3;i+=3){
|
||||
GX_Position3f32(obj.Pos[obj.FacPos[i]-1].x,obj.Pos[obj.FacPos[i]-1].y,-obj.Pos[obj.FacPos[i]-1].z);
|
||||
if(col) GX_Color1u32 (col);
|
||||
if(norm) GX_Normal3f32(obj.Nrm[obj.FacNrm[i]-1].x,obj.Nrm[obj.FacNrm[i]-1].y,-obj.Nrm[obj.FacNrm[i]-1].z);
|
||||
if(tex) GX_TexCoord2f32(obj.Tex[obj.FacTex[i]-1].x, obj.Tex[obj.FacTex[i]-1].y);
|
||||
void GRRLIB_Draw3dObj(GRRLIB_3dObj obj, u32 col, bool tex, bool norm) {
|
||||
int i;
|
||||
GX_Begin(GX_TRIANGLES, GX_VTXFMT0, obj.NbFace*3);
|
||||
for(i=0;i<obj.NbFace*3;i+=3) {
|
||||
GX_Position3f32(obj.Pos[obj.FacPos[i]-1].x,obj.Pos[obj.FacPos[i]-1].y,-obj.Pos[obj.FacPos[i]-1].z);
|
||||
if(col) GX_Color1u32 (col);
|
||||
if(norm) GX_Normal3f32(obj.Nrm[obj.FacNrm[i]-1].x,obj.Nrm[obj.FacNrm[i]-1].y,-obj.Nrm[obj.FacNrm[i]-1].z);
|
||||
if(tex) GX_TexCoord2f32(obj.Tex[obj.FacTex[i]-1].x, obj.Tex[obj.FacTex[i]-1].y);
|
||||
|
||||
GX_Position3f32(obj.Pos[obj.FacPos[i+1]-1].x,obj.Pos[obj.FacPos[i+1]-1].y,-obj.Pos[obj.FacPos[i+1]-1].z);
|
||||
if(col) GX_Color1u32 (col);
|
||||
if(norm) GX_Normal3f32(obj.Nrm[obj.FacNrm[i+1]-1].x,obj.Nrm[obj.FacNrm[i+1]-1].y,-obj.Nrm[obj.FacNrm[i+1]-1].z);
|
||||
if(tex) GX_TexCoord2f32(obj.Tex[obj.FacTex[i+1]-1].x, obj.Tex[obj.FacTex[i+1]-1].y);
|
||||
GX_Position3f32(obj.Pos[obj.FacPos[i+1]-1].x,obj.Pos[obj.FacPos[i+1]-1].y,-obj.Pos[obj.FacPos[i+1]-1].z);
|
||||
if(col) GX_Color1u32 (col);
|
||||
if(norm) GX_Normal3f32(obj.Nrm[obj.FacNrm[i+1]-1].x,obj.Nrm[obj.FacNrm[i+1]-1].y,-obj.Nrm[obj.FacNrm[i+1]-1].z);
|
||||
if(tex) GX_TexCoord2f32(obj.Tex[obj.FacTex[i+1]-1].x, obj.Tex[obj.FacTex[i+1]-1].y);
|
||||
|
||||
GX_Position3f32(obj.Pos[obj.FacPos[i+2]-1].x,obj.Pos[obj.FacPos[i+2]-1].y,-obj.Pos[obj.FacPos[i+2]-1].z);
|
||||
if(col) GX_Color1u32 (col);
|
||||
if(norm) GX_Normal3f32(obj.Nrm[obj.FacNrm[i+2]-1].x,obj.Nrm[obj.FacNrm[i+2]-1].y,-obj.Nrm[obj.FacNrm[i+2]-1].z);
|
||||
if(tex) GX_TexCoord2f32(obj.Tex[obj.FacTex[i+2]-1].x, obj.Tex[obj.FacTex[i+2]-1].y);
|
||||
}
|
||||
GX_End();
|
||||
GX_Position3f32(obj.Pos[obj.FacPos[i+2]-1].x,obj.Pos[obj.FacPos[i+2]-1].y,-obj.Pos[obj.FacPos[i+2]-1].z);
|
||||
if(col) GX_Color1u32 (col);
|
||||
if(norm) GX_Normal3f32(obj.Nrm[obj.FacNrm[i+2]-1].x,obj.Nrm[obj.FacNrm[i+2]-1].y,-obj.Nrm[obj.FacNrm[i+2]-1].z);
|
||||
if(tex) GX_TexCoord2f32(obj.Tex[obj.FacTex[i+2]-1].x, obj.Tex[obj.FacTex[i+2]-1].y);
|
||||
}
|
||||
GX_End();
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
@ -75,26 +75,26 @@ int main() {
|
|||
GRRLIB_2dMode();
|
||||
WPAD_ScanPads();
|
||||
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) exit(0);
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_PLUS){if(Amb<255) Amb++; }
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_MINUS){if(Amb>0) Amb--; }
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A){zlight++; }
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B){zlight--; }
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_PLUS) {if(Amb<255) Amb++; }
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_MINUS) {if(Amb>0) Amb--; }
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A) {zlight++; }
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B) {zlight--; }
|
||||
|
||||
|
||||
GRRLIB_3dMode(0.1,1000,45,0,0,1);
|
||||
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 3,3,3);
|
||||
|
||||
GRRLIB_InitLight(GX_LIGHT0, (guVector){-6, 0, zlight}, 0xFF0000FF);
|
||||
GRRLIB_InitLight(GX_LIGHT1, (guVector){ 6, 0, zlight}, 0x00FF00FF);
|
||||
GRRLIB_InitLight(GX_LIGHT2, (guVector){ 0,-6, zlight}, 0x0000FFFF);
|
||||
GRRLIB_InitLight(GX_LIGHT0, (guVector){-6, 0, zlight}, 0xFF0000FF);
|
||||
GRRLIB_InitLight(GX_LIGHT1, (guVector){ 6, 0, zlight}, 0x00FF00FF);
|
||||
GRRLIB_InitLight(GX_LIGHT2, (guVector){ 0,-6, zlight}, 0x0000FFFF);
|
||||
|
||||
GRRLIB_LightSwitch(GX_LIGHT0|GX_LIGHT1|GX_LIGHT2,RGBA(Amb,Amb,Amb,0xFF),0x808080FF,0);
|
||||
GRRLIB_LightSwitch(GX_LIGHT0|GX_LIGHT1|GX_LIGHT2,RGBA(Amb,Amb,Amb,0xFF),0x808080FF,0);
|
||||
|
||||
GRRLIB_Draw3dObj(torus,0,0,1);
|
||||
GRRLIB_Draw3dObj(torus,0,0,1);
|
||||
|
||||
a+=0.5f;
|
||||
|
||||
GRRLIB_LightOff();
|
||||
GRRLIB_LightOff();
|
||||
// Switch To 2D Mode to display text
|
||||
GRRLIB_2dMode();
|
||||
GRRLIB_Printf((640-(16*35))/2, 20, tex_font, 0xFFFFFFFF, 1, "(PLUS / MINUS) AMBIENT = 0X%02X%02X%02XFF",Amb,Amb,Amb,Amb);
|
||||
|
|
Loading…
Reference in a new issue