[ADD] GRRLIB_ObjectViewInv (see doc for info)

[CHG] Improve GRRLIB_ObjectView
[ADD] 3D_Light2 to show use of GRRLIB_ObjectViewInv
This commit is contained in:
N0NameN0 2010-04-29 17:37:00 +00:00
parent c53ff66250
commit 46a2297aa6
7 changed files with 393 additions and 17 deletions

View file

@ -148,7 +148,7 @@ void GRRLIB_2dMode() {
} }
/** /**
* Set the view matrix to draw object (contributed by chris_c aka DaShAmAn). * Set the view matrix to draw object (in this order scale, rotate AND trans).
* @param posx x position of the object. * @param posx x position of the object.
* @param posy y position of the object. * @param posy y position of the object.
* @param posz z position of the object. * @param posz z position of the object.
@ -160,22 +160,92 @@ void GRRLIB_2dMode() {
* @param scalz z scale of the object. * @param scalz z scale of the object.
*/ */
void GRRLIB_ObjectView(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 angz, f32 scalx, f32 scaly, f32 scalz) { void GRRLIB_ObjectView(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 angz, f32 scalx, f32 scaly, f32 scalz) {
Mtx m, m1, mv, rx, ry, rz; Mtx ObjTransformationMtx;
Mtx mvi; Mtx m, rx,ry,rz;
Mtx mv, mvi;
guMtxIdentity(m1); guMtxIdentity(ObjTransformationMtx);
guMtxScaleApply(m1, m1, scalx, scaly, scalz);
if((scalx !=1.0f) || (scaly !=1.0f) || (scalz !=1.0f)){
guMtxIdentity(m);
guMtxScaleApply(m, m, scalx, scaly, scalz);
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
}
if((angx !=0.0f) || (angy !=0.0f) || (angz !=0.0f)){
guMtxIdentity(m);
guMtxRotAxisDeg(rx, &_GRRaxisx, angx); guMtxRotAxisDeg(rx, &_GRRaxisx, angx);
guMtxRotAxisDeg(ry, &_GRRaxisy, angy); guMtxRotAxisDeg(ry, &_GRRaxisy, angy);
guMtxRotAxisDeg(rz, &_GRRaxisz, angz); guMtxRotAxisDeg(rz, &_GRRaxisz, angz);
guMtxConcat(ry, rx, m); guMtxConcat(ry, rx, m);
guMtxConcat(m, rz, m); guMtxConcat(m, rz, m);
guMtxConcat(m, m1, m); guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
}
if((posx !=0.0f) || (posy !=0.0f) || (posz !=0.0f)){
guMtxIdentity(m);
guMtxTransApply(m, m, posx, posy, posz); guMtxTransApply(m, m, posx, posy, posz);
guMtxConcat(_GRR_view, m, mv);
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
}
guMtxConcat(_GRR_view, ObjTransformationMtx, mv);
GX_LoadPosMtxImm(mv, GX_PNMTX0);
guMtxInverse(mv, mvi);
guMtxTranspose(mvi, mv);
GX_LoadNrmMtxImm(mv, GX_PNMTX0);
}
/**
* Set the view matrix to draw object (in this order scale, trans AND rotate).
* @param posx x position of the object.
* @param posy y position of the object.
* @param posz z position of the object.
* @param angx x rotation angle of the object.
* @param angy y rotation angle of the object.
* @param angz z rotation angle of the object.
* @param scalx x scale of the object.
* @param scaly y scale of the object.
* @param scalz z scale of the object.
*/
void GRRLIB_ObjectViewInv(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 angz, f32 scalx, f32 scaly, f32 scalz) {
Mtx ObjTransformationMtx;
Mtx m, rx,ry,rz;
Mtx mv, mvi;
guMtxIdentity(ObjTransformationMtx);
if((scalx !=1.0f) || (scaly !=1.0f) || (scalz !=1.0f)){
guMtxIdentity(m);
guMtxScaleApply(m, m, scalx, scaly, scalz);
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
}
if((posx !=0.0f) || (posy !=0.0f) || (posz !=0.0f)){
guMtxIdentity(m);
guMtxTransApply(m, m, posx, posy, posz);
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
}
if((angx !=0.0f) || (angy !=0.0f) || (angz !=0.0f)){
guMtxIdentity(m);
guMtxRotAxisDeg(rx, &_GRRaxisx, angx);
guMtxRotAxisDeg(ry, &_GRRaxisy, angy);
guMtxRotAxisDeg(rz, &_GRRaxisz, angz);
guMtxConcat(ry, rx, m);
guMtxConcat(m, rz, m);
guMtxConcat(m, ObjTransformationMtx, ObjTransformationMtx);
}
guMtxConcat(_GRR_view, ObjTransformationMtx, mv);
GX_LoadPosMtxImm(mv, GX_PNMTX0); GX_LoadPosMtxImm(mv, GX_PNMTX0);
guMtxInverse(mv, mvi); guMtxInverse(mv, mvi);

View file

@ -151,6 +151,7 @@ void GRRLIB_Camera3dSettings(f32 posx, f32 posy, f32 posz, f32 upx, f32 upy, f32
void GRRLIB_3dMode(f32 minDist, f32 maxDist, f32 fov, bool texturemode, bool normalmode); void GRRLIB_3dMode(f32 minDist, f32 maxDist, f32 fov, bool texturemode, bool normalmode);
void GRRLIB_2dMode(); void GRRLIB_2dMode();
void GRRLIB_ObjectView(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 angz, f32 scalx, f32 scaly, f32 scalz); void GRRLIB_ObjectView(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 angz, f32 scalx, f32 scaly, f32 scalz);
void GRRLIB_ObjectViewInv(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 angz, f32 scalx, f32 scaly, f32 scalz);
void GRRLIB_SetTexture(GRRLIB_texImg *tex, bool rep); void GRRLIB_SetTexture(GRRLIB_texImg *tex, bool rep);
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);
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);

139
examples/3D_Light2/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 -lfreetype -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,67 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
const unsigned char font[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0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x8a,
0x7e, 0x06, 0x8f, 0xca, 0x21, 0xd4, 0x72, 0x51, 0xdc, 0x8d, 0x73, 0xeb, 0xef, 0x7d, 0x5c, 0x6f,
0xc1, 0x4d, 0xf4, 0x5f, 0x9e, 0xd3, 0x11, 0xf5, 0x30, 0x23, 0xf3, 0xad, 0xe4, 0x00, 0x61, 0xe9,
0x48, 0x1f, 0xa0, 0xcb, 0x01, 0x8e, 0x30, 0x2c, 0xeb, 0x73, 0xb6, 0xde, 0x4d, 0x22, 0xfa, 0x8a,
0xfc, 0x7a, 0x25, 0xe1, 0x7b, 0xfa, 0x94, 0x69, 0xfc, 0x24, 0x25, 0xc2, 0xa2, 0x4b, 0xc1, 0x79,
0xeb, 0xff, 0xf4, 0xea, 0x04, 0x4e, 0x10, 0x79, 0x9c, 0x20, 0xe3, 0x9f, 0xcd, 0x09, 0x5e, 0xd9,
0x8c, 0x2b, 0x7b, 0x5e, 0x86, 0xf5, 0x61, 0xe8, 0xc4, 0x9a, 0xe7, 0x4b, 0x84, 0x19, 0xaf, 0xd3,
0xb3, 0x5f, 0xd6, 0x6d, 0xb1, 0x0c, 0x06, 0xdc, 0x26, 0x39, 0xa3, 0x20, 0x77, 0x82, 0xdc, 0x78,
0x17, 0x8e, 0x00, 0xa3, 0x97, 0x31, 0x94, 0x8c, 0x4f, 0xfb, 0xf5, 0xae, 0xe8, 0xc9, 0xe3, 0xd9,
0x7f, 0x49, 0xfb, 0x96, 0x7d, 0x58, 0xc5, 0x7e, 0x5a, 0xae, 0xa3, 0x26, 0x17, 0xad, 0x7f, 0xab,
0xf1, 0xe7, 0x25, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0xf0, 0x0f,
0xab, 0xb9, 0x5f, 0xb5, 0x2f, 0x5e, 0xd2, 0x50, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44,
0xae, 0x42, 0x60, 0x82
};
const int font_size = sizeof(font);

View file

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 932 B

View file

@ -0,0 +1,85 @@
/*===========================================
NoNameNo
Simple Lights and GRRLIB_ObjectViewInv sample
============================================*/
#include <grrlib.h>
#include <stdlib.h>
#include <math.h>
#include <malloc.h>
#include <wiiuse/wpad.h>
#include "gfx/font.h"
extern Mtx _GRR_view;
int main() {
float a=0;
float objscal=0.5f;
int objqual = 20;
GRRLIB_Init();
WPAD_Init();
GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(font);
GRRLIB_InitTileSet(tex_font, 16, 16, 32);
GRRLIB_Settings.antialias = true;
GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF);
while(1) {
GRRLIB_2dMode();
WPAD_ScanPads();
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) break;
GRRLIB_Camera3dSettings(0.0f, 0.0f,13.0f, 0,1,0, 0,0,0);
GRRLIB_SetLightAmbient(0x333333FF);
GRRLIB_SetLightDiff(0,(guVector){0.0f,0.0f,0.0f},20.0f,1.0f,0x00FFFFFF);
GRRLIB_SetLightDiff(1,(guVector){0.0f,13.0f,3.0f},20.0f,1.0f,0xFF00FFFF);
GRRLIB_SetLightDiff(2,(guVector){0.0f,-13.0f,3.0f},20.0f,1.0f,0xFFFF00FF);
GRRLIB_SetLightDiff(3,(guVector){13.0f,0.0f,3.0f},20.0f,1.0f,0xFF0000FF);
GRRLIB_SetLightDiff(4,(guVector){-13.0f,0.0f,3.0f},20.0f,1.0f,0x00FF00FF);
GRRLIB_3dMode(0.1,1000,45,0,1);
GRRLIB_ObjectViewInv(1.0f, -1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
GRRLIB_ObjectViewInv(-1.0f, -1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
GRRLIB_ObjectViewInv(1.0f, 1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
GRRLIB_ObjectViewInv(-1.0f, 1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
GRRLIB_ObjectViewInv(1.0f, -1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
GRRLIB_ObjectViewInv(-1.0f, -1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
GRRLIB_ObjectViewInv(1.0f, 1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
GRRLIB_ObjectViewInv(-1.0f, 1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
GRRLIB_ObjectView(0.0f, 0.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
GRRLIB_DrawCube(3.0,true,0xFFFFFF44);
a+=0.6f;
// Switch To 2D Mode to display text
GRRLIB_2dMode();
GRRLIB_Printf((640-(16*29))/2, 20, tex_font, 0xFFFFFFFF, 1, "LIGHT SAMPLE CODE 2");
GRRLIB_Render();
}
GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
GRRLIB_FreeTexture(tex_font);
exit(0);
}