ISS - Shuttle Docking Simulation
Posted: 22.10.2003, 23:02
I am working on an interactive ISS - space shuttle docking simulator, and am having problems with how the ISS and shuttle are rendered when the two get close together -- sometimes the iss is completely on top of the shuttle, and sometimes it's the other way around. It really only seems to be a problem once the shuttle moves inside the ISS's bounding sphere.
I noticed in the render.cpp file that each object is allocated its own small section of the Z-buffer (by using the glDepthRange function), and that the comments mention letting "overlapping objects share a depth buffer range." I believe that I have implemented this change as so:
int nDepthBuckets = 1;
int i;
int issBucket = -1;
int orbBucket = -1;
for (i = 0; i < nEntries; i++)
{
if (renderList[i].discSizeInPixels > 1)
{
nDepthBuckets++;
if( renderList[i].body != NULL )
{
// save the bucket indeces for the ISS and shuttle - the +1
// is added because the objects are rendered from last
// to first below, but are ordered first to last in this loop
if( renderList[i].body->getName() == "ISS" )
issBucket = i+1;
if( renderList[i].body->getName() == "Shuttle" )
orbBucket = i+1;
}
}
}
.
.
.
and whenever the bucket is changed in any subsequent call to glDepthRange, I have used the following code:
if( (depthBucket == orbBucket || depthBucket == issBucket) &&
(orbBucket == (issBucket-1) || orbBucket == (issBucket+1)) )
{
if( orbBucket < issBucket )
glDepthRange( orbBucket * depthRange,
(issBucket + 1) * depthRange );
else
glDepthRange( issBucket * depthRange,
(orbBucket + 1) * depthRange );
}
else
// the original call
glDepthRange(depthBucket * depthRange,
(depthBucket + 1) * depthRange);
I did make the assumption that the shuttle will be rendered immediately after the ISS (or vice versa) -- this assumption holds true for all instances of my simulator.
Does anyone know how/why the Z-buffer is being split up like this, and how I might even be able to fix this overlapping problem?
Thanks in advance,
Dan
I noticed in the render.cpp file that each object is allocated its own small section of the Z-buffer (by using the glDepthRange function), and that the comments mention letting "overlapping objects share a depth buffer range." I believe that I have implemented this change as so:
int nDepthBuckets = 1;
int i;
int issBucket = -1;
int orbBucket = -1;
for (i = 0; i < nEntries; i++)
{
if (renderList[i].discSizeInPixels > 1)
{
nDepthBuckets++;
if( renderList[i].body != NULL )
{
// save the bucket indeces for the ISS and shuttle - the +1
// is added because the objects are rendered from last
// to first below, but are ordered first to last in this loop
if( renderList[i].body->getName() == "ISS" )
issBucket = i+1;
if( renderList[i].body->getName() == "Shuttle" )
orbBucket = i+1;
}
}
}
.
.
.
and whenever the bucket is changed in any subsequent call to glDepthRange, I have used the following code:
if( (depthBucket == orbBucket || depthBucket == issBucket) &&
(orbBucket == (issBucket-1) || orbBucket == (issBucket+1)) )
{
if( orbBucket < issBucket )
glDepthRange( orbBucket * depthRange,
(issBucket + 1) * depthRange );
else
glDepthRange( issBucket * depthRange,
(orbBucket + 1) * depthRange );
}
else
// the original call
glDepthRange(depthBucket * depthRange,
(depthBucket + 1) * depthRange);
I did make the assumption that the shuttle will be rendered immediately after the ISS (or vice versa) -- this assumption holds true for all instances of my simulator.
Does anyone know how/why the Z-buffer is being split up like this, and how I might even be able to fix this overlapping problem?
Thanks in advance,
Dan