Code: Select all
void *box;
u32 boxret;
box = memalign(32,1024);
GX_BeginDispList(box,672);
GX_Begin(GX_QUADS,GX_VTXFMT0,20); // Start drawing
// Bottom face
GX_Position3f32(-1.0f,-1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(1.0f,1.0f); // Top right
GX_Position3f32( 1.0f,-1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,1.0f); // Top left
GX_Position3f32( 1.0f,-1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,0.0f); // Bottom left
GX_Position3f32( 1.0f,-1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,0.0f); // Bottom right
// Front face
GX_Position3f32(-1.0f,-1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,0.0f); // Bottom left
GX_Position3f32( 1.0f,-1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(1.0f,0.0f); // Bottom right
GX_Position3f32( 1.0f, 1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(1.0f,1.0f); // Top right
GX_Position3f32(-1.0f, 1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,1.0f); // Top left
// Back face
GX_Position3f32(-1.0f,-1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(1.0f,0.0f); // Bottom right
GX_Position3f32(-1.0f, 1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(1.0f,1.0f); // Top right
GX_Position3f32( 1.0f, 1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,1.0f); // Top left
GX_Position3f32( 1.0f,-1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,0.0f); // Bottom left
// Right face
GX_Position3f32( 1.0f,-1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(1.0f,0.0f); // Bottom right
GX_Position3f32( 1.0f, 1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(1.0f,1.0f); // Top right
GX_Position3f32( 1.0f, 1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,1.0f); // Top left
GX_Position3f32( 1.0f,-1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,0.0f); // Bottom left
// Left face
GX_Position3f32(-1.0f,-1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,0.0f); // Bottom right
GX_Position3f32(-1.0f,-1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(1.0f,0.0f); // Top right
GX_Position3f32(-1.0f, 1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(1.0f,1.0f); // Top left
GX_Position3f32(-1.0f, 1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,1.0f); // Bottom left
GX_End(); // Done drawing quads
boxret = GX_EndDispList(); // Done building the box list
if (boxret == 0) return 1;
Code: Select all
Mtx model,view,modelview;
for (yloop = 1; yloop < 6; yloop++) { // Loop through the y plane
for (xloop = 0; xloop < yloop; xloop++) { // Loop through the x plane
// Position the cubes on the screen
guMtxIdentity(model);
axis.x = 1.0f;
axis.y = 0;
axis.z = 0;
guMtxRotAxisDeg(model,&axis,(45.0f-(2.0f*yloop)+xrot)); // Tilt the cubes up and down
axis.x = 0;
axis.y = 1.0f;
guMtxRotAxisDeg(model,&axis,(45.0f+yrot)); // Spin cubes left and right
guMtxTransApply(model,model,(1.4f+((float)xloop*2.8f)-((float)yloop*1.4f)),(((6.0f-(float)yloop)*2.4f)-7.0f),-20.0f);
guMtxConcat(model,view,modelview);
GX_LoadPosMtxImm(modelview, GX_PNMTX0);
GX_CallDispList(box,boxret); // Draw the box
}
}
EDIT: The display list shape has a missing side (the top) intentionally.