mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 15:02:20 +00:00
[CHG] Formating
This commit is contained in:
parent
5c15af3217
commit
38a76e29e7
4 changed files with 65 additions and 66 deletions
|
@ -145,7 +145,6 @@ void GRRLIB_2dMode() {
|
||||||
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
|
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
|
||||||
|
|
||||||
GRRLIB_Settings.lights = 0;
|
GRRLIB_Settings.lights = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -218,6 +217,7 @@ void GRRLIB_SetTexture(GRRLIB_texImg *tex, bool rep) {
|
||||||
* @param nsides Number of faces per ring.
|
* @param nsides Number of faces per ring.
|
||||||
* @param rings Number of rings.
|
* @param rings Number of rings.
|
||||||
* @param filled Wired or not.
|
* @param filled Wired or not.
|
||||||
|
* @param col Color of the torus.
|
||||||
*/
|
*/
|
||||||
void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled, u32 col) {
|
void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled, u32 col) {
|
||||||
int i, j;
|
int i, j;
|
||||||
|
@ -266,6 +266,7 @@ void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled, u32 col)
|
||||||
* @param lats Number of lattitudes.
|
* @param lats Number of lattitudes.
|
||||||
* @param longs Number of longitutes.
|
* @param longs Number of longitutes.
|
||||||
* @param filled Wired or not.
|
* @param filled Wired or not.
|
||||||
|
* @param col Color of the sphere.
|
||||||
*/
|
*/
|
||||||
void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col) {
|
void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col) {
|
||||||
int i, j;
|
int i, j;
|
||||||
|
@ -303,6 +304,7 @@ void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col) {
|
||||||
* Draw a cube (with normal).
|
* Draw a cube (with normal).
|
||||||
* @param size Size of the cube edge.
|
* @param size Size of the cube edge.
|
||||||
* @param filled Wired or not.
|
* @param filled Wired or not.
|
||||||
|
* @param col Color of the cube.
|
||||||
*/
|
*/
|
||||||
void GRRLIB_DrawCube(f32 size, bool filled, u32 col) {
|
void GRRLIB_DrawCube(f32 size, bool filled, u32 col) {
|
||||||
static f32 n[6][3] =
|
static f32 n[6][3] =
|
||||||
|
@ -363,6 +365,7 @@ void GRRLIB_DrawCube(f32 size, bool filled, u32 col) {
|
||||||
* @param h High of the cylinder.
|
* @param h High of the cylinder.
|
||||||
* @param d Dencity of slice.
|
* @param d Dencity of slice.
|
||||||
* @param filled Wired or not.
|
* @param filled Wired or not.
|
||||||
|
* @param col Color of the cylinder.
|
||||||
*/
|
*/
|
||||||
void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col) {
|
void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col) {
|
||||||
int i;
|
int i;
|
||||||
|
@ -408,22 +411,23 @@ void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Ambiant Color
|
* Set ambient color.
|
||||||
|
* When no diffuse ligth is shinig on a object, the color is equal to ambient color.
|
||||||
|
* @param ambientcolor Ambient color in RGBA format.
|
||||||
*/
|
*/
|
||||||
void GRRLIB_SetLightAmbiant(u32 ambiantcolor){
|
void GRRLIB_SetLightAmbient(u32 ambientcolor) {
|
||||||
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor) { R(ambiantcolor), G(ambiantcolor), B(ambiantcolor), 0xFF});
|
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor) { R(ambientcolor), G(ambientcolor), B(ambientcolor), 0xFF});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Diffuse Light Parameters
|
* Set diffuse light parameters.
|
||||||
* @param num number of the light
|
* @param num Number of the light. It's a number from 0 to 7.
|
||||||
* @param pos position of the diffuse light (x/y/z)
|
* @param pos Position of the diffuse light (x/y/z).
|
||||||
* @param distattn distance attenuation
|
* @param distattn Distance attenuation.
|
||||||
* @param brightness Brightness of the light
|
* @param brightness Brightness of the light. The value should be between 0 and 1.
|
||||||
* @param lightcolor color of the light
|
* @param lightcolor Color of the light in RGBA format.
|
||||||
* @param ambiant anbiant color.
|
|
||||||
*/
|
*/
|
||||||
void GRRLIB_SetLightDiff(int num, guVector pos, float distattn, float brightness , u32 lightcolor){
|
void GRRLIB_SetLightDiff(u8 num, guVector pos, f32 distattn, f32 brightness, u32 lightcolor) {
|
||||||
GXLightObj MyLight;
|
GXLightObj MyLight;
|
||||||
guVector lpos = {pos.x, pos.y, pos.z};
|
guVector lpos = {pos.x, pos.y, pos.z};
|
||||||
|
|
||||||
|
@ -436,13 +440,13 @@ guVector lpos={pos.x,pos.y,pos.z};
|
||||||
GX_InitLightDistAttn(&MyLight, distattn, brightness, GX_DA_MEDIUM); // DistAttn = 20.0 & Brightness=1.0f (full)
|
GX_InitLightDistAttn(&MyLight, distattn, brightness, GX_DA_MEDIUM); // DistAttn = 20.0 & Brightness=1.0f (full)
|
||||||
GX_LoadLightObj(&MyLight, (1<<num));
|
GX_LoadLightObj(&MyLight, (1<<num));
|
||||||
|
|
||||||
/////////////////////// Turn light ON ////////////////////////////////////////////////
|
// Turn light ON
|
||||||
GX_SetNumChans(1);
|
GX_SetNumChans(1);
|
||||||
GX_SetChanCtrl(GX_COLOR0A0, GX_ENABLE, GX_SRC_REG, GX_SRC_VTX, GRRLIB_Settings.lights, GX_DF_CLAMP,GX_AF_SPOT); //4th param is where come from the material color (REG(with setChanMatColor or VTX (vertex)) same for ambiant ($
|
GX_SetChanCtrl(GX_COLOR0A0, GX_ENABLE, GX_SRC_REG, GX_SRC_VTX, GRRLIB_Settings.lights, GX_DF_CLAMP, GX_AF_SPOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set all Lights Off (like at init);
|
* Set all lights off, like at init.
|
||||||
*/
|
*/
|
||||||
void GRRLIB_SetLightOff(void) {
|
void GRRLIB_SetLightOff(void) {
|
||||||
GX_SetNumTevStages(1);
|
GX_SetNumTevStages(1);
|
||||||
|
@ -454,6 +458,4 @@ void GRRLIB_SetLightOff(void){
|
||||||
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
|
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
|
||||||
|
|
||||||
GRRLIB_Settings.lights = 0;
|
GRRLIB_Settings.lights = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ typedef enum GRRLIB_blendMode {
|
||||||
typedef struct GRRLIB_drawSettings {
|
typedef struct GRRLIB_drawSettings {
|
||||||
bool antialias; /**< AntiAlias is enabled when set to true. */
|
bool antialias; /**< AntiAlias is enabled when set to true. */
|
||||||
GRRLIB_blendMode blend; /**< Blending Mode. */
|
GRRLIB_blendMode blend; /**< Blending Mode. */
|
||||||
int lights; /**< active lights */
|
int lights; /**< Active lights. */
|
||||||
} GRRLIB_drawSettings;
|
} GRRLIB_drawSettings;
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
|
@ -156,8 +156,8 @@ void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled, u32 col)
|
||||||
void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col);
|
void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col);
|
||||||
void GRRLIB_DrawCube(f32 size, bool filled, u32 col);
|
void GRRLIB_DrawCube(f32 size, bool filled, u32 col);
|
||||||
void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col);
|
void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col);
|
||||||
void GRRLIB_SetLightAmbiant(u32 ambiantcolor);
|
void GRRLIB_SetLightAmbient(u32 ambientcolor);
|
||||||
void GRRLIB_SetLightDiff(int num, guVector pos, float distattn, float brightness , u32 lightcolor);
|
void GRRLIB_SetLightDiff(u8 num, guVector pos, f32 distattn, f32 brightness, u32 lightcolor);
|
||||||
void GRRLIB_SetLightOff(void);
|
void GRRLIB_SetLightOff(void);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <wiiuse/wpad.h>
|
#include <wiiuse/wpad.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,7 +38,7 @@ float l1=0,l2=0;
|
||||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_MINUS) camZ--;
|
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_MINUS) camZ--;
|
||||||
|
|
||||||
GRRLIB_Camera3dSettings(0.0f,0.0f,camZ, 0,1,0, 0,0,0);
|
GRRLIB_Camera3dSettings(0.0f,0.0f,camZ, 0,1,0, 0,0,0);
|
||||||
GRRLIB_SetLightAmbiant(0x333333FF);
|
GRRLIB_SetLightAmbient(0x333333FF);
|
||||||
|
|
||||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A) {
|
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A) {
|
||||||
// Set all light off to get the spere no light sourced (only get the vertex color)
|
// Set all light off to get the spere no light sourced (only get the vertex color)
|
||||||
|
@ -59,12 +58,11 @@ float l1=0,l2=0;
|
||||||
l2+=0.05f;
|
l2+=0.05f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set a dummy black light to get the ambiant one when no light is selected
|
||||||
// SET a dummy black light to get the ambiant one when no light is selected
|
GRRLIB_SetLightDiff(0,(guVector){sin(l1)*4.0f,0.0f,cos(l1)*4.0f},20.0f,1.0f,0x000000FF);
|
||||||
GRRLIB_SetLightDiff(0,(guVector){sin(l1)*4,0.0f,cos(l1)*4.0f},20.0f,1.0f,0x000000FF);
|
|
||||||
|
|
||||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A) {
|
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A) {
|
||||||
GRRLIB_SetLightDiff(0,(guVector){sin(l1)*4,0.0f,cos(l1)*4.0f},20.0f,1.0f,0xFF0000FF);
|
GRRLIB_SetLightDiff(0,(guVector){sin(l1)*4.0f,0.0f,cos(l1)*4.0f},20.0f,1.0f,0xFF0000FF);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B) {
|
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B) {
|
||||||
|
@ -77,10 +75,9 @@ float l1=0,l2=0;
|
||||||
GRRLIB_ObjectView(0,0,0, a,a*2,a*3,1,1,1);
|
GRRLIB_ObjectView(0,0,0, a,a*2,a*3,1,1,1);
|
||||||
GRRLIB_DrawTorus(1, 2, 60, 60, true, 0xFFFFFFFF);
|
GRRLIB_DrawTorus(1, 2, 60, 60, true, 0xFFFFFFFF);
|
||||||
|
|
||||||
|
|
||||||
a+=0.5f;
|
a+=0.5f;
|
||||||
|
|
||||||
// Switch To 2D Mode to display text
|
// Switch to 2D Mode to display text
|
||||||
GRRLIB_2dMode();
|
GRRLIB_2dMode();
|
||||||
GRRLIB_Printf((640-(16*29))/2, 20, tex_font, 0xFFFFFFFF, 1, "PRESS + OR - TO ZOOM");
|
GRRLIB_Printf((640-(16*29))/2, 20, tex_font, 0xFFFFFFFF, 1, "PRESS + OR - TO ZOOM");
|
||||||
GRRLIB_Printf((640-(16*29))/2, 40, tex_font, 0xFFFFFFFF, 1, "HOLD A - RED / B - GREEN");
|
GRRLIB_Printf((640-(16*29))/2, 40, tex_font, 0xFFFFFFFF, 1, "HOLD A - RED / B - GREEN");
|
||||||
|
|
Loading…
Reference in a new issue