[ADD] GRRLIB_SetLightSpec for specular light support ;)

[ADD] 3D_Light3 for a little specular light sample code.
This commit is contained in:
N0NameN0 2010-05-01 14:29:28 +00:00
parent 84d6fd44d6
commit a968a16dfa
7 changed files with 367 additions and 0 deletions

View file

@ -583,6 +583,51 @@ void GRRLIB_SetLightDiff(u8 num, guVector pos, f32 distattn, f32 brightness, u32
GX_SetChanCtrl(GX_COLOR0A0, GX_ENABLE, GX_SRC_REG, GX_SRC_VTX, GRRLIB_Settings.lights, GX_DF_CLAMP, GX_AF_SPOT); GX_SetChanCtrl(GX_COLOR0A0, GX_ENABLE, GX_SRC_REG, GX_SRC_VTX, GRRLIB_Settings.lights, GX_DF_CLAMP, GX_AF_SPOT);
} }
/**
* Set specular light parameters.
* @param num Number of the light. It's a number from 0 to 7.
* @param dir Direction of the specular ray (x/y/z).
* @param shy Shyniness of the specular. ( between 4 and 254)
* @param lightcolor Color of the light in RGBA format.
* @param speccolor Specular color in RGBA format..
*/
void GRRLIB_SetLightSpec(u8 num, guVector dir, f32 shy, u32 lightcolor, u32 speccolor) {
Mtx mr,mv;
GXLightObj MyLight;
guVector ldir = {ldir.x, ldir.y, ldir.z};
GRRLIB_Settings.lights |= (1<<num);
guMtxInverse(_GRR_view,mr);
guMtxTranspose(mr,mv);
guVecMultiplySR(mv, &ldir,&ldir);
GX_InitSpecularDirv(&MyLight, &ldir);
GX_InitLightShininess(&MyLight, shy); // entre 4 et 255 !!!
GX_InitLightColor(&MyLight, (GXColor) { R(lightcolor), G(lightcolor), B(lightcolor), 0xFF });
GX_LoadLightObj(&MyLight, (1<<num));
/////////////////////// Turn light ON ////////////////////////////////////////////////
GX_SetNumChans(2); // use two color channels
GX_SetChanCtrl(GX_COLOR0, GX_ENABLE, GX_SRC_REG, GX_SRC_VTX, 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_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_ZERO, GX_CC_RASC, GX_CC_ONE, GX_CC_CPREV );
/////////////////////// Define MAterial and Ambiant color and draw object /////////////////////////////////////
GX_SetChanAmbColor(GX_COLOR1, (GXColor){0x00,0x00,0x00,0xFF}); // specualr ambient forced to black
GX_SetChanMatColor(GX_COLOR1, (GXColor) { R(speccolor), G(speccolor), B(speccolor), 0xFF }); // couleur du reflet specular
}
/** /**
* Set all lights off, like at init. * Set all lights off, like at init.
*/ */

View file

@ -164,6 +164,7 @@ 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_SetLightAmbient(u32 ambientcolor); void GRRLIB_SetLightAmbient(u32 ambientcolor);
void GRRLIB_SetLightDiff(u8 num, guVector pos, f32 distattn, f32 brightness, u32 lightcolor); void GRRLIB_SetLightDiff(u8 num, guVector pos, f32 distattn, f32 brightness, u32 lightcolor);
void GRRLIB_SetLightSpec(u8 num, guVector dir, f32 shy, u32 lightcolor, u32 speccolor);
void GRRLIB_SetLightOff(void); void GRRLIB_SetLightOff(void);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

139
examples/3D_Light3/Makefile Normal file
View file

@ -0,0 +1,139 @@
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC)
endif
include $(DEVKITPPC)/wii_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source source/gfx
DATA := data
INCLUDES :=
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -g -O2 -mrvl -Wall $(MACHDEP) $(INCLUDE)
CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -mrvl -Wl,-Map,$(notdir $@).map
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lgrrlib -l freetype -lpngu -lpng -ljpeg -lz -lfat -lwiiuse -lbte -logc -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CURDIR)/$(GRRLIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
$(sFILES:.s=.o) $(SFILES:.S=.o)
#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) \
-I$(LIBOGC_INC)
#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
-L$(LIBOGC_LIB)
export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
#---------------------------------------------------------------------------------
run:
psoload $(TARGET).dol
#---------------------------------------------------------------------------------
reload:
psoload -r $(TARGET).dol
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).dol: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)
#---------------------------------------------------------------------------------
# This rule links in binary data with the .jpg extension
#---------------------------------------------------------------------------------
%.jpg.o : %.jpg
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------

View file

@ -0,0 +1,105 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
const unsigned char font9x12[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x03, 0x58, 0x00, 0x00, 0x00, 0x0c, 0x08, 0x06, 0x00, 0x00, 0x00, 0x7f, 0x68, 0x1c,
0xd4, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00,
0x00, 0x06, 0x62, 0x4b, 0x47, 0x44, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xa0, 0xbd, 0xa7, 0x93,
0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00, 0x00, 0x0b, 0x13,
0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x00, 0x07, 0x74, 0x49, 0x4d, 0x45, 0x07, 0xda, 0x01,
0x07, 0x0f, 0x37, 0x1a, 0xb9, 0xff, 0x9a, 0x93, 0x00, 0x00, 0x05, 0x87, 0x49, 0x44, 0x41, 0x54,
0x78, 0xda, 0xed, 0x5d, 0x4d, 0xd2, 0xa4, 0x30, 0x08, 0xb5, 0x67, 0xe5, 0x11, 0x5d, 0x7a, 0x34,
0x97, 0x1e, 0xd1, 0x5d, 0xcf, 0x2a, 0x55, 0x19, 0x26, 0x84, 0xc7, 0x4f, 0xa2, 0xdd, 0xcd, 0xab,
0x9a, 0xaa, 0xf9, 0x34, 0x62, 0x02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0xad,
0x3e, 0x23, 0xef, 0xf0, 0xe8, 0x8f, 0xe7, 0xb3, 0x0e, 0xe9, 0x80, 0x3b, 0xab, 0xef, 0xf2, 0x2b,
0x3f, 0xb9, 0x94, 0x48, 0x24, 0x12, 0x89, 0x44, 0x22, 0x91, 0x98, 0xb0, 0xa9, 0x3d, 0xda, 0xb1,
0xfc, 0x96, 0xdf, 0x0c, 0x8d, 0x3a, 0x6d, 0x38, 0xf1, 0x9d, 0xfa, 0x91, 0x48, 0x24, 0x12, 0x89,
0x44, 0x22, 0x91, 0xf8, 0x51, 0x47, 0x76, 0xe6, 0xa9, 0x98, 0xdf, 0xe4, 0x3c, 0x67, 0x80, 0x35,
0x46, 0x07, 0x33, 0xb8, 0x4a, 0x24, 0x12, 0x89, 0x44, 0x22, 0x91, 0x48, 0x24, 0x12, 0x89, 0xc4,
0x3f, 0xf8, 0x0b, 0xea, 0x2a, 0xe7, 0xc4, 0x8d, 0xfe, 0xbd, 0xe3, 0x00, 0x00, 0x00, 0x00, 0x49,
0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
const int font9x12_size = sizeof(font9x12);

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _font9x12_h_
#define _font9x12_h_
//---------------------------------------------------------------------------------
extern const unsigned char font9x12[];
extern const int font9x12_size;
//---------------------------------------------------------------------------------
#endif //_font9x12_h_
//---------------------------------------------------------------------------------

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -0,0 +1,63 @@
/*===========================================
NoNameNo
A little Specular light sample code
============================================*/
#include <grrlib.h>
#include <stdlib.h>
#include <wiiuse/wpad.h>
#include "gfx/font9x12.h"
extern Mtx _GRR_view;
int main() {
f32 rot=0.0f;
float shy=10.0f;
GRRLIB_Init();
WPAD_Init();
GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(font9x12);
GRRLIB_InitTileSet(tex_font, 9, 12, 32);
GRRLIB_Settings.antialias = true;
GRRLIB_SetBackgroundColour(0x40, 0x40, 0x40, 0xFF);
while(1) {
GRRLIB_Camera3dSettings(0.0f,0.0f,10.0f, 0,1,0, 0,0,0);
WPAD_ScanPads();
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) break;
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A) shy+=1;
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B) shy-=1;
GRRLIB_3dMode(0.1,1000,45,0,1);
// dir param of GRRLIB_SetLightSpec function have to be a crazy 0,0,0 value
// there is a bug in libogc about this
// http://forums.devkitpro.org/viewtopic.php?f=7&t=1933
// we are waiting for a fix from libogc devs
GRRLIB_SetLightAmbient(0x404040FF);
GRRLIB_SetLightSpec(0, (guVector){0.0f,0.0f,0.0f}, shy, 0xFFFFFFFF, 0xFFFFFFFF);
GRRLIB_ObjectView(0,0,0, rot,rot*2,rot*3, 1.0f,1.0f,1.0f);
GRRLIB_DrawTorus(0.6f, 2.6f, 60, 60,true, 0x502010FF);
GRRLIB_DrawCube(1.8f, true, 0x202050FF);
rot+=0.8f;
GRRLIB_2dMode();
GRRLIB_Printf(50, 60, tex_font, 0xFFFFFFFF, 1, "Use ( A / B ) to change the shyniness value : %d ",(int)shy);
GRRLIB_Render();
}
GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
GRRLIB_FreeTexture(tex_font);
exit(0);
}