Welcome! Log In Create A New Profile

Advanced

drawing a tiled floor. Can somebody help me?

Posted by wilco2009 
drawing a tiled floor. Can somebody help me?
January 22, 2011 12:53AM
First of all, I'm sorry for my English.

I'm learning to programming gx, and I've found a problem
that I cant understand.

I'm making a program to walk though a world like a quake.
I'm trying to draw a tiled floor doing two nested loops
calling a function who draw a simple textured tile.
If I draw some individual tiles I haven't troubles and
floor is drawed right but if I draw more than certain
number of tiles (no so much) the program hangs.

Can somebody helpme??
Bellow you can find a extract of my code. With theese
number of tiles program hangs:


void DibujaBaldosa(float x, float z, GXTexObj *texture)
#define tBaldosa 1.0f
{

//set number of textures to generate
GX_SetNumTexGens(1);

GX_SetTevOp(GX_TEVSTAGE0,GX_BLEND);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);

GX_LoadTexObj(texture, GX_TEXMAP0);


guMtxIdentity(model);

guMtxTransApply(model, model, x,ySuelo,z);
guMtxConcat(view,model,modelview);


// load the modelview matrix into matrix memory
GX_LoadPosMtxImm(modelview, GX_PNMTX0);

guMtxInverse(modelview,mvi);
guMtxTranspose(mvi,modelview);
GX_LoadNrmMtxImm(modelview, GX_PNMTX0);


GX_Begin(GX_QUADS, GX_VTXFMT0, 4);

// Draw the floor
GX_Position3f32(tBaldosa, 0, -tBaldosa); // Top Right Of The Quad (Right)
GX_TexCoord2f32(10.0f,10.0f);
GX_Position3f32(-tBaldosa, 0, -tBaldosa); // Top Left Of The Quad (Right)
GX_TexCoord2f32(0.0f,10.0f);
GX_Position3f32(-tBaldosa, 0, tBaldosa); // Bottom Left Of The Quad (Right)
GX_TexCoord2f32(0.0f,0.0f);
GX_Position3f32(+tBaldosa, 0, tBaldosa); // Bottom Right Of The Quad (Right)
GX_TexCoord2f32(10.0f,0.0f);
GX_End(); // Done Drawing The Quad

}

void Dibujasuelo (GXTexObj *texture)
{
f32 x;
f32 z;

for (x = -4.0f; x < 6.0f;x = x + 2.0f)
for (z = -18.0f; z <= -6.0f; z = z + 2.0f)
DibujaBaldosa(x, z, texture);
}
Re: drawing a tiled floor. Can somebody help me?
January 23, 2011 03:12PM
There seem to be missing some code there but it seems like you are not calling DibujaBaldosa() the correct number of times. I think you can only call it once after each GX_Position3f32().
Re: drawing a tiled floor. Can somebody help me?
January 24, 2011 03:32PM
You're probably overflowing the graphics FIFO. To draw a tiled surface it is better to set the wrapping mode of the texture to GX_REPEAT and draw it as a single quad (or triangle fan).
Re: drawing a tiled floor. Can somebody help me?
January 24, 2011 11:29PM
Thankyou very much to both for answer

I'll try to do that.
Sorry, only registered users may post in this forum.

Click here to login