[ODE] RE: Cone and Terrain
Nate W
coding at natew.com
Tue Mar 9 20:06:23 MST 2004
On Tue, 9 Mar 2004, Eric Buchanan wrote:
> I would agree with the previous poster about the need for Geom
> position and orientation support. I'm current working on a simulation
> and we plan in the future to start using very large terrains at high
> resolution(hopefully 1cm or better) for multiple km traverses and to
> do this feasible we have decided to load our terrain as patches
> dynamically as needed.
I just integrated Benoit's terrain stuff into an already-existing game
engine, which already had a terrain engine of its own. Rather than
converting our map to the format required by the terrain object, removed
the terrain object's vertex data member and replaced it with a callback
function that fetches vertex data from the other terrain engine,
vertex by vertex, on demand.
In our case there's typically just a handful of vertices (our terrain
squares are about the same size as the objects themselves) so the overhead
is negligible. In your case, with so many vertices, the overhead might
add up, but then again since you'll be supplying data on a per-vertex
basis you might be able to do some more sophisticated caching to save on
space as well as time.
The change basically amounts to removing a bunch of code and adding just a
little. Here's the constructor:
dxTerrain::dxTerrain (dSpaceID space, dReal vLength,
GetHeightmapPlaneProc_mapCallback) :
dxGeom (space,0)
{
mapCallback = _mapCallback;
m_vNodeLength = vLength;
type = dTerrainClass;
m_vMinHeight = -dInfinity;
m_vMaxHeight = dInfinity;
}
There are two versions of GetHeight, one taking int parameters and the
other taking dReals. Both are basically identical. One could optimize
this by using two callbacks, one taking ints and the other dReals, to get
a litte better performance (using ints you can just return Heights
directly from the vertex array, using floats you have to interpolate).
dReal dxTerrain::GetHeight(int x,int y)
{
dReal position[3];
position[0] = x;
position[1] = y;
position[2] = 0;
return mapCallback (position);
}
There's a little more to it, but I'm not sure my mods to dGetDepthFn() are
quite right so I'll keep those to myself a bit longer. :-) It works, and
looks right, but I don't think it's as accurate as it could be.
--
Nate Waddoups
Redmond WA USA
http://www.natew.com/
More information about the ODE
mailing list