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 polygon size

#98376 - Rajveer - Mon Aug 14, 2006 11:36 pm

hi there, after trying to import quite a large level, i got some unexpected results. so i did some testing with a triangle with:

Code:

glVertex3f(-10.000,0.000,-10.000);
glVertex3f(-10.000,0.000,test);
glVertex3f(10.000,0.000,-10.000);


where test would change with keypresses (test is an integer). i quickly discovered that the polygon would get larger and then all of a sudden become small, continuing like this in a loop (as if a value larger than the "limit" would remap back and make the polygon small again). anybody know whats going on? (if u get me that is)

cheers

#98379 - Mighty Max - Mon Aug 14, 2006 11:45 pm

Using a 4.12 fixed point type you can not create values bigger then
(2 ^15-1) / (2^12) ~= 7.99. So no value of 8 and above. -8 is the lower limit.

Create it smaller and scale up.
_________________
GBAMP Multiboot

#98381 - Rajveer - Tue Aug 15, 2006 12:00 am

cool cheers for the reply.

question: i thought glVertex3f used a float point number and its fixed point counterpart is glVertexv16?

scaling it up means redoing a lot of collision detection stuff :(

edit: i guess one way would be to make the actual world much smaller to fit within the 8 to -8 limit right

and it would be 7 to -7 no? cos the first bit is signed i.e. 1.3.12

#98391 - sajiimori - Tue Aug 15, 2006 12:37 am

Scaling is normal.

Collision data is typically separate from visual data anyway. The concerns are very different for those two purposes.

#98395 - Rajveer - Tue Aug 15, 2006 12:46 am

im using a method by which i store vertex data as an array (actually i created a new typedef for polygons, including 3 vertex arrays of size 3), this way i can also use the vertex data for raytracing collisions (imagine a racer where the vehicle has to snap its rotation to the rotation of the polygon). no biggie however, ill scale the level down to a power of 2 and bitshift back up wherever i use the vertex data (although may degrade performance).

oh and if these methods are newbish, its my first ever project :-D

#98448 - Cearn - Tue Aug 15, 2006 10:02 am

Rajveer wrote:
edit: i guess one way would be to make the actual world much smaller to fit within the 8 to -8 limit right

and it would be 7 to -7 no? cos the first bit is signed i.e. 1.3.12

No it wouldn't. v16 is just a typedef for short and works via 2s complement just like any other integer so the range is [-8.000h,+7.FFFh]. The 1.3.12 is just a (somewhat misleading) notation people sometimes use to indicate the thing is signed rather than unsigned, but there is no dedicated sign bit like in floats.