Sign in to follow this  
McGrane

Problem with basic ROAM

Recommended Posts

I am currently trying to lear abit about LOD and ROAM, but unfortunatly have hit a brick wall at the first step :P
[code]
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;
}
}
[/code]
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

Share this post


Link to post
Share on other sites
[quote]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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
[quote name='mcgrane66' timestamp='1302713342' post='4798011']
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?
[/quote]

Correct, it is completely unnecessary on modern GPUs.

The GPU Gems 2 book has [url="http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter02.html"]this article[/url] which is a little dated but explains the basics with an example. Their summary explains: "[i]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.[/i]" 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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this