Re: [Plib-users] Pre/Post draw callbacks on ssgBranches.
Brought to you by:
sjbaker
From: Jon A. <jan...@on...> - 2000-09-20 02:44:22
|
> > Well, when I first started, I attached all the Terrain and the Patches as > > user data on a ssgBranch and ssgVtxTable, respectively. That was okay to > > get it up an running, but made it clunky to use. > > Yes - I can imagine. It would also be hard to eliminate the problem of > people attaching 'conventional' ssgVtxTables to the Terrain's ssgBranch > node - which could be messy! Obviously you can tell people not to do > that - but it would be nicer if that was something the compiler could > just toss out. > > > >Can I see the code? It would be easier to discuss. > > > > I'll post it somewhere tonight. > > Thanks. I've posted the code at: http://innovation3d.sourceforge.net/roam I also put up some screenshots so you could see how it looks so far. =) I'll try to explain how it works. The ssgTerrain is a sub class of ssgBranch. It basically is a loose encapsulation of ssgPatches, which are what contain the ROAM logic. I used a branch rather than a leaf, because I thought it would be conceptually nice to be able to add other things to the terrain, such as buildings, trees, etc. This might also allow the terrain to tesselate a little higher around those objects, if needed. Each patch is: 1) An ssgVtxTable representing a quad for the water line. 2) A TriTree structure attached to the ssgVtxTable as user data. It is the TriTree that is actually used in ROAM. The actually patch is rendered in a PostDraw callback registered on the VtxTable. This way when the VtxTable is culled, the patch isn't rendered. The ssgTerrain is added to the scene in the normal manner. But in the update, it's all rendered by: t->reset(); //resets all the patches t->tesselate(); //tesselates all the patches. ssgCullAndDraw( root ); Because the tessellation occurs outside the CullAndDraw, all patches are tessellated, even those who are culled later. I have some misc. utility functions defined like getHeight(), but I'd like to make it work for ssgHOT, etc. Anyway, you can take a look at the code. Jon |