[vtkusers] Terrain rendering problem

Georgios Katsaros gkatsaros at rcc.com
Tue Feb 3 11:14:42 EST 2004


Dear vtk users,

Since this is my first post to this  list, I would like to thank you for
making using vtk so much more rewarding.

Here's my question:

I have written a simple derived class from vtkPolyDataSource, called vtkCSDTerrainSource, that creates a set of triangle strips that model a chunk of terrain data. I'm using this class to visualize terrain in a large simulation environment.

The result is "almost" correct, except for the following intermittent problem: When the "edges" of the terrain data are of higher elevation than data closer to the center of the terrain patch, the internal data is rendered "underneath" the terrain. So, instead of having a "valley" in the middle of the terrain, there is a "mountain" under the terrain model. The "valley" on the upper face is rendered as flat, with some straight-line patterns.
On the other hand, an island (where surrounding elevations are zero), renders correctly.

Any ideas as to what could be causing this would be greatly appreciated. 

Please note: I have already tried adding a vtkPolyDataNormals layer and/or a vtkElevationFilter.
The specific problem was not solved by those. 
Also, I'm aware that one could use a vtkImageSource-derived source to render terrain,
but I'm concerned with this specific "mystery" in the use of a vtkPolyDataSource.

Here is a relevant part of the pipeline:

// Create the terrain source and fill with data
m_pMyTerrain = vtkMyTerrainSource::New();
m_pMyTerrain->Update();

// Create the terrain mapper
m_pTerrainMapper = vtkPolyDataMapper::New();

// Link mapper to terrain source
m_pTerrainMapper->SetInput((vtkPolyData *)m_pMyTerrain->GetOutput());

// Create the terrain actor
vtkLODActor *terrainActor = vtkLODActor::New();
terrainActor->SetNumberOfCloudPoints(25000);
terrainActor->SetMapper(m_pTerrainMapper);
vtkProperty *prop = terrainActor->GetProperty();
prop->SetRepresentationToSurface();
prop->SetInterpolationToGouraud();


Here is the triangle-strip creation part in the 
vtkMyTerrainSource::Execute() method. 
Another part has already created a vtkPoints array with 
(m_nYResolution X m_nXResolution) elements.


// Create the triangle strips
m_pTerrStrips = vtkCellArray::New();
for (int nR = 1; nR < m_nYResolution; nR++)
{
 m_pTerrStrips->InsertNextCell(2*m_nXResolution);
 for (int nC = 0; nC < m_nXResolution; nC++)
 {
  m_pTerrStrips->InsertCellPoint(nR*m_nXResolution + nC);
  m_pTerrStrips->InsertCellPoint((nR-1)*m_nXResolution + nC);
 }
 UpdateProgress((double)nR/(double)(m_nYResolution-1));
}
Thanks in advance,

George.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040203/5f6a1fe0/attachment.htm>


More information about the vtkusers mailing list