mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-12-22 18:39:18 +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);
|
||||
|
||||
GRRLIB_Settings.lights = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -218,6 +217,7 @@ void GRRLIB_SetTexture(GRRLIB_texImg *tex, bool rep) {
|
|||
* @param nsides Number of faces per ring.
|
||||
* @param rings Number of rings.
|
||||
* @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) {
|
||||
int i, j;
|
||||
|
@ -248,10 +248,10 @@ void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled, u32 col)
|
|||
|
||||
GX_Position3f32(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
|
||||
GX_Normal3f32(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
|
||||
GX_Color1u32(col);
|
||||
GX_Color1u32(col);
|
||||
GX_Position3f32(cosTheta * dist, -sinTheta * dist, r * sinPhi);
|
||||
GX_Normal3f32(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
|
||||
GX_Color1u32(col);
|
||||
GX_Color1u32(col);
|
||||
}
|
||||
GX_End();
|
||||
theta = theta1;
|
||||
|
@ -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 longs Number of longitutes.
|
||||
* @param filled Wired or not.
|
||||
* @param col Color of the sphere.
|
||||
*/
|
||||
void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col) {
|
||||
int i, j;
|
||||
|
@ -290,10 +291,10 @@ void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col) {
|
|||
|
||||
GX_Position3f32(x * zr0 * r, y * zr0 * r, z0 * r);
|
||||
GX_Normal3f32(x * zr0 * r, y * zr0 * r, z0 * r);
|
||||
GX_Color1u32(col);
|
||||
GX_Color1u32(col);
|
||||
GX_Position3f32(x * zr1 * r, y * zr1 * r, z1 * r);
|
||||
GX_Normal3f32(x * zr1 * r, y * zr1 * r, z1 * r);
|
||||
GX_Color1u32(col);
|
||||
GX_Color1u32(col);
|
||||
}
|
||||
GX_End();
|
||||
}
|
||||
|
@ -303,6 +304,7 @@ void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col) {
|
|||
* Draw a cube (with normal).
|
||||
* @param size Size of the cube edge.
|
||||
* @param filled Wired or not.
|
||||
* @param col Color of the cube.
|
||||
*/
|
||||
void GRRLIB_DrawCube(f32 size, bool filled, u32 col) {
|
||||
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 d Dencity of slice.
|
||||
* @param filled Wired or not.
|
||||
* @param col Color of the cylinder.
|
||||
*/
|
||||
void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col) {
|
||||
int i;
|
||||
|
@ -408,43 +411,44 @@ 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){
|
||||
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor) { R(ambiantcolor), G(ambiantcolor), B(ambiantcolor), 0xFF});
|
||||
void GRRLIB_SetLightAmbient(u32 ambientcolor) {
|
||||
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor) { R(ambientcolor), G(ambientcolor), B(ambientcolor), 0xFF});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Diffuse Light Parameters
|
||||
* @param num number of the light
|
||||
* @param pos position of the diffuse light (x/y/z)
|
||||
* @param distattn distance attenuation
|
||||
* @param brightness Brightness of the light
|
||||
* @param lightcolor color of the light
|
||||
* @param ambiant anbiant color.
|
||||
* Set diffuse light parameters.
|
||||
* @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 distattn Distance attenuation.
|
||||
* @param brightness Brightness of the light. The value should be between 0 and 1.
|
||||
* @param lightcolor Color of the light in RGBA format.
|
||||
*/
|
||||
void GRRLIB_SetLightDiff(int num, guVector pos, float distattn, float brightness , u32 lightcolor){
|
||||
GXLightObj MyLight;
|
||||
guVector lpos={pos.x,pos.y,pos.z};
|
||||
void GRRLIB_SetLightDiff(u8 num, guVector pos, f32 distattn, f32 brightness, u32 lightcolor) {
|
||||
GXLightObj MyLight;
|
||||
guVector lpos = {pos.x, pos.y, pos.z};
|
||||
|
||||
GRRLIB_Settings.lights |= (1<<num);
|
||||
GRRLIB_Settings.lights |= (1<<num);
|
||||
|
||||
guVecMultiply(_GRR_view, &lpos, &lpos);
|
||||
GX_InitLightPos(&MyLight, lpos.x, lpos.y, lpos.z);
|
||||
GX_InitLightColor(&MyLight, (GXColor) { R(lightcolor), G(lightcolor), B(lightcolor), 0xFF });
|
||||
GX_InitLightSpot(&MyLight, 0.0f, GX_SP_OFF);
|
||||
GX_InitLightDistAttn(&MyLight, distattn, brightness, GX_DA_MEDIUM); // DistAttn = 20.0 & Brightness=1.0f (full)
|
||||
GX_LoadLightObj(&MyLight, (1<<num));
|
||||
guVecMultiply(_GRR_view, &lpos, &lpos);
|
||||
GX_InitLightPos(&MyLight, lpos.x, lpos.y, lpos.z);
|
||||
GX_InitLightColor(&MyLight, (GXColor) { R(lightcolor), G(lightcolor), B(lightcolor), 0xFF });
|
||||
GX_InitLightSpot(&MyLight, 0.0f, GX_SP_OFF);
|
||||
GX_InitLightDistAttn(&MyLight, distattn, brightness, GX_DA_MEDIUM); // DistAttn = 20.0 & Brightness=1.0f (full)
|
||||
GX_LoadLightObj(&MyLight, (1<<num));
|
||||
|
||||
/////////////////////// Turn light ON ////////////////////////////////////////////////
|
||||
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 ($
|
||||
// Turn light ON
|
||||
GX_SetNumChans(1);
|
||||
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_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
|
||||
|
@ -454,6 +458,4 @@ void GRRLIB_SetLightOff(void){
|
|||
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
|
||||
|
||||
GRRLIB_Settings.lights = 0;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ typedef enum GRRLIB_blendMode {
|
|||
typedef struct GRRLIB_drawSettings {
|
||||
bool antialias; /**< AntiAlias is enabled when set to true. */
|
||||
GRRLIB_blendMode blend; /**< Blending Mode. */
|
||||
int lights; /**< active lights */
|
||||
int lights; /**< Active lights. */
|
||||
} 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_DrawCube(f32 size, bool filled, u32 col);
|
||||
void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col);
|
||||
void GRRLIB_SetLightAmbiant(u32 ambiantcolor);
|
||||
void GRRLIB_SetLightDiff(int num, guVector pos, float distattn, float brightness , u32 lightcolor);
|
||||
void GRRLIB_SetLightAmbient(u32 ambientcolor);
|
||||
void GRRLIB_SetLightDiff(u8 num, guVector pos, f32 distattn, f32 brightness, u32 lightcolor);
|
||||
void GRRLIB_SetLightOff(void);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <malloc.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
|
||||
|
||||
|
@ -15,7 +14,7 @@
|
|||
extern Mtx _GRR_view;
|
||||
|
||||
int main() {
|
||||
float l1=0,l2=0;
|
||||
float l1=0, l2=0;
|
||||
float a=0;
|
||||
int camZ=13.0f;
|
||||
|
||||
|
@ -39,48 +38,46 @@ float l1=0,l2=0;
|
|||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_MINUS) camZ--;
|
||||
|
||||
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){
|
||||
// Set all light off to get the spere no light sourced (only get the vertex color)
|
||||
GRRLIB_SetLightOff();
|
||||
GRRLIB_3dMode(0.1,1000,45,0,1);
|
||||
GRRLIB_ObjectView(sin(l1)*4.0f,0.0f,cos(l1)*4.0f, 0,0,0,1,1,1);
|
||||
GRRLIB_DrawSphere(0.2f,20,20,true,0xFF0000FF);
|
||||
l1+=0.03f;
|
||||
}
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A) {
|
||||
// Set all light off to get the spere no light sourced (only get the vertex color)
|
||||
GRRLIB_SetLightOff();
|
||||
GRRLIB_3dMode(0.1,1000,45,0,1);
|
||||
GRRLIB_ObjectView(sin(l1)*4.0f,0.0f,cos(l1)*4.0f, 0,0,0,1,1,1);
|
||||
GRRLIB_DrawSphere(0.2f, 20, 20, true, 0xFF0000FF);
|
||||
l1+=0.03f;
|
||||
}
|
||||
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B){
|
||||
// Set all light off to get the spere no light sourced (only get the vertex color)
|
||||
GRRLIB_SetLightOff();
|
||||
GRRLIB_3dMode(0.1,1000,45,0,1);
|
||||
GRRLIB_ObjectView(0.0f,sin(l2)*4.0f,cos(l2)*4.0f, 0,0,0,1,1,1);
|
||||
GRRLIB_DrawSphere(0.2f,20,20,true,0x00FF00FF);
|
||||
l2+=0.05f;
|
||||
}
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B) {
|
||||
// Set all light off to get the spere no light sourced (only get the vertex color)
|
||||
GRRLIB_SetLightOff();
|
||||
GRRLIB_3dMode(0.1,1000,45,0,1);
|
||||
GRRLIB_ObjectView(0.0f,sin(l2)*4.0f,cos(l2)*4.0f, 0,0,0,1,1,1);
|
||||
GRRLIB_DrawSphere(0.2f, 20, 20, true, 0x00FF00FF);
|
||||
l2+=0.05f;
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
// SET a dummy black light to get the ambiant one when no light is selected
|
||||
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) {
|
||||
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_A){
|
||||
GRRLIB_SetLightDiff(0,(guVector){sin(l1)*4,0.0f,cos(l1)*4.0f},20.0f,1.0f,0xFF0000FF);
|
||||
}
|
||||
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B){
|
||||
GRRLIB_SetLightDiff(1,(guVector){0.0f,sin(l2)*4.0f,cos(l2)*4.0f},20.0f,1.0f,0x00FF00FF);
|
||||
}
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B) {
|
||||
GRRLIB_SetLightDiff(1,(guVector){0.0f,sin(l2)*4.0f,cos(l2)*4.0f},20.0f,1.0f,0x00FF00FF);
|
||||
}
|
||||
|
||||
|
||||
GRRLIB_3dMode(0.1,1000,45,0,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;
|
||||
|
||||
// Switch To 2D Mode to display text
|
||||
// Switch to 2D Mode to display text
|
||||
GRRLIB_2dMode();
|
||||
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");
|
||||
|
|
Loading…
Reference in a new issue