Archived

This topic is now archived and is closed to further replies.

Snowman

D3D and ROAM

Recommended Posts

Hey guys. I''ve been looking into ROAM as my LOD algo for my terrain. It looks like it will work out great, but I have one question in regards to rendering it with D3D... At run time, ROAM makes a big binary triangle tree of all of the triangles in the scene. Then, at render it loops through getting the (x, y, z) coordinate for each vertex and renders as a triangle list. My question is, what''s the best way to do this with D3D? examle code: RecurrsiveFunction( coordinates of triangle ) { // Get the three verts of the triangle. // Render them? // Pass on info for the children triangles (ones split from us) } Now, as you can see that will result in a whole lot of DrawPrimitive() calls which will be incredibly slow my intuition tells me =). So, what to do? With OpenGL you can pass verts one at a time (glVertex3f() or something like that). Any ideas? Thanks in advance!! -Snowman

Share this post


Link to post
Share on other sites
I don''t know a whole lot about vertex buffers, but the way I understand it, Vertex buffers are filled using Lock() and Unlock() right? Well, I''ve also heard that it''s slow to do that over and over which is what I''d have to do in order to add all of my triangles...

Any other ideas?

Thanks!

-Snowman

Share this post


Link to post
Share on other sites
Yeah, one idea is to call the recursive function and just
do a single lock before you enter, then unlock and a call
to drawprimtive when your finished.

Of course you will have to take into account vertex limits
on the buffers etc.

i.e.

VB->Lock()
RecursiveFunction()
{
// Get 3 verts for triangle
// Check space left in VB
// if so add them
// if not DrawPrimitive VB with current set of triangles
// and switch to another VB to start filling

// Recursive function to next tri''s
}
VB->UnLock()

Draw Remaining tri''s.

Obviously this is a basic outline of what needs to be
done.

--
Code..reboot..code..reboot..sigh!

Share this post


Link to post
Share on other sites
This sounds like a good idea, I''ll try it out and compare speeds to see if it''s faster than calling a bunch of drawprimitives(). Thanks!

-Snowman

Share this post


Link to post
Share on other sites