gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Maximum Size of 3D Shapes

#45753 - iainprice - Tue Jun 14, 2005 4:48 pm

I seem to be able to display 3d shapes with co-ordinates of up to 10.0

Is there any way of using larger shapes than this or do I have to try to scale everything else down?

I am drawing a series of quads and they are all fine until the co-ords get above 10, then they just don't draw...yes the zfar is set to 40 so the camera can cope....

any ideas anyone?

#45761 - mike260 - Tue Jun 14, 2005 6:45 pm

The DS can only handle input vertices between -8 and 8. The trick is that although this restricts the vertices you can pass in, internally it can handle a much larger range.

So the best way to get around this problem is to store each object translated and scaled to fit within a 16x16x16 cube centered on the origin. Then, before rendering an object, apply a scale and translation to the current modelview matrix that will take the object back to the correct position and size.

#45763 - iainprice - Tue Jun 14, 2005 7:00 pm

Not quite with you... so how do I pass in values to glVertex3v16 of larger than 8?

#45780 - mike260 - Tue Jun 14, 2005 9:41 pm

iainprice wrote:
Not quite with you... so how do I pass in values to glVertex3v16 of larger than 8?


You can't. All verts you pass in with glVertex* MUST be between (-8,-8,-8) and (8,8,8). But there's no restriction on where your verts end up after being transformed.

So say you want to draw an object in the general area of (100,100,100). The following will NOT work:

Code:

glBegin( GL_TRIANGLE );
glVertex3v16( intov16(100), intov16(100), intov16(100) );
glVertex3v16( intov16(101), intov16(100), intov16(100) );
glVertex3v16( intov16(100), intov16(101), intov16(100) );
glEnd();

Instead, you need to do something like this:

Code:

glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glTranslate3f32( floatof32(100), floatof32(100), floatof32(100) );

glBegin( GL_TRIANGLE );
glVertex3v16( intov16(0), intov16(0), intov16(0) );
glVertex3v16( intov16(1), intov16(0), intov16(0) );
glVertex3v16( intov16(0), intov16(1), intov16(0) );
glEnd();

glPopMatrix();


The glTranslate() in this code has the effect of adding (100,100,100) to each vertex.