Problem with basic ROAM

Started by
3 comments, last by McGrane 13 years ago
I am currently trying to lear abit about LOD and ROAM, but unfortunatly have hit a brick wall at the first step :P

int d_mmount = 3;
int d_size = 64;

struct sVerts
{
float x;
float y;
float z;
};

sVerts Vert1,Vert2,Vert3;
sVerts newVert1, newVert2, newVert3, newVert4, newVert5, newVert6;

void DrawTri( int level, sVerts tmpVerts1, sVerts tmpVerts2, sVerts tmpVerts3 )
{

glBegin( GL_TRIANGLES );
glColor3f( 1.0f, 0.0f, 0.0f );
glVertex3f( tmpVerts1.x, tmpVerts1.y, tmpVerts1.z );
glVertex3f( tmpVerts2.x, tmpVerts2.y, tmpVerts2.z );
glVertex3f( tmpVerts3.x, tmpVerts3.y, tmpVerts3.z );
glEnd();

float midpoint = (tmpVerts2.x+tmpVerts3.x)/2;
float midpoint2 = (tmpVerts2.y+tmpVerts3.y)/2;

newVert1.x = midpoint; newVert1.y = midpoint2; newVert1.z = 0.0f;
newVert2.x = tmpVerts1.x; newVert2.y = tmpVerts1.y; newVert2.z = 0.0f;
newVert3.x = tmpVerts2.x; newVert3.y = tmpVerts2.y; newVert3.z = 0.0f;

newVert4.x = midpoint; newVert4.y = midpoint2; newVert4.z = 0.0f;
newVert5.x = tmpVerts3.x; newVert5.y = tmpVerts3.y; newVert5.z = 0.0f;
newVert6.x = tmpVerts1.x; newVert6.y = tmpVerts1.y; newVert6.z = 0.0f;

if( level < d_mmount )
{
DrawTri( level + 1, newVert4, newVert5, newVert6 );
DrawTri( level + 1, newVert1, newVert2, newVert3 );
return;
}
}

The Problem is, it is only splitting on one side, i think i understand why, its keeps looping threw the first of the two calls to DrawTri(), and the loop ends before it ever gets to the secound call.
My question is how can i call both functions at once? Should i just store to seperate counters? My biggest confusion about this is that in the articles i am reading, all use this method with no problem.
Any help or suggestions would be appreciated
Advertisement
Any help or suggestions would be appreciated [/quote]

My first suggestion is to not bother with the terrain work.

This was a great research area and hotbed of development about 10 years ago. In fact, it was my graduate thesis topic.

Then this awesome new video card called the GeForce 3 was released that could handle all that work and more just by passing some simple arrays to the card. Overnight, research on ROAM terrains became a mostly dead field, reserved for those few die-hards and niche workers who needed to work on multi-gigabyte terrain models.

Modern graphics cards can handle complex terrain meshes without difficulty. Just dump the entire mesh to data and let the card do the work.




My second suggestion is that you are doing your graphics wrong by working with primitives.

They are provided as a lowest-common-denominator fallback in case you absolutely need them. Even in the first editions of OpenGL they were something that should have been avoided unless you truly need a primitive. They are probably the slowest way to push data to the card.

Instead you should be using large buffers of points, indexed primitives, and batches of data. Instead of pushing across one point per transfer, you can push across thousands or even hundreds of thousands of points and mesh data in a single transfer. Instead of transferring them every frame, you can transfer them once and leave them there.
Thanks for the reply, i dont usually use primitives for my programs, i was moreso just going from the example, but thanks for the advise. I was only looking into ROAM because i was readering heightmaps, and once over maybe 256x256 it slows down significally, I originally was looking into different LOD's but they where more complicated, so i tought i would go to a less complicated method. I do most my programming on differnt computers and laptops, because i myself dont own one, are you saying that newer graphic cards can actually render terrain without the use of any LOD?

Thanks for the reply, i dont usually use primitives for my programs, i was moreso just going from the example, but thanks for the advise. I was only looking into ROAM because i was readering heightmaps, and once over maybe 256x256 it slows down significally, I originally was looking into different LOD's but they where more complicated, so i tought i would go to a less complicated method. I do most my programming on differnt computers and laptops, because i myself dont own one, are you saying that newer graphic cards can actually render terrain without the use of any LOD?


Correct, it is completely unnecessary on modern GPUs.

The GPU Gems 2 book has this article which is a little dated but explains the basics with an example. Their summary explains: "The technique is easy to implement, and allows interactive flight over a 20-billion-sample grid of the United States stored in just 355 MB of memory, at around 90 frames per second." Hardware, of course, has advanced quite a bit since then.
[font=Verdana, Geneva, Arial, Helvetica,]
[/font]
I'm guessing your terrain is less than 20 billion samples and covers a somewhat smaller geographic region.
Computers ... you just cant beat em ha. Well thats good news as far as programming goes, bad news that i dont have a good computer to try it on. But atleast i can concentrate on something else.
Much Appreciated

This topic is closed to new replies.

Advertisement