#### Archived

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

# D3D and ROAM

This topic is 6490 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
Can you build a vertexbuffer while ROAM''ing?

Then you can call just the one function to render the whole buffer, right?

##### 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 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

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

1. 1
2. 2
Rutin
22
3. 3
JoeJ
18
4. 4
5. 5

• 15
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631725
• Total Posts
3001905
×