Renders the terrain. More...
#include <TerrainViz/nodes/SoTVizRender.h>
The TerrainViz extension allows terrain visualization using an auto-adaptive mesh technique and a quadtree of textures. It uses a multi-resolution technique that re-meshes the terrain at every frame with a constant number of triangles. The local mesh accuracy depends on the point of view and the altitude gradient. The texture level depends on the point of view only.
TerrainViz attempts to render the terrain at a constant frame rate.
Controls are provided for adjusting quality versus performance.
SoTVizRender is the shape node of TerrainViz. It re-computes the mesh at every frame.
Normals are enabled/disabled by the normals field. By default they are enabled. Until TerrainViz V2.0, normals were activated in the terrain model when the creaseAngle of the current SoShapeHints was different from 0. For compatibility with this older behavior, use environment variable TVIZ_COMPAT_20 (see also SoPreferences).
Normals are memory consuming. If enabled, normals are pre-computed. The memory used by pre-computed normals is not freed until a new SbTVizData is supplied in order not to slow down the frame rate when changing and changing again the normals field value.
The terrain can be mapped with a texture tree using an SbTVizTextureList node, or with color mapping using an SbTVizColorScale node (color changes depending on altitude).
All values are expressed as modeling coordinates.
Data (terrain altitudes and textures) can be provided two different ways:
The mesh computation is controlled by several fields.
NOTE: SoTVizRender is not meant to be exported as an .iv file because it uses SbTVizData/SbTVizTextureList/SbTVizTexture instances containing the data (elevations, textures). The way to save a terrain scene is to export it to an XML file referencing an elevation data file and image files for textures. Use writeToXML to export your scene and loadFromXML to retrieve it.
< !-- TGS TerrainViz X.X --> | File header with TerrainViz version in XML comment format. |
<TerrainViz> | Begins the file. |
<data> | Begins the data block. |
<format> <value> </format> Ex: <format> "REGULARGRID" </format> | Specificies the format. Can be "REGULARGRID" (data is organized in a 2D array). Default: "REGULARGRID". |
<fileName> <value> </fileName> Ex: <fileName> "elevation.dat" </fileName> | Data file name between "". |
<step> <value> </step> Ex: <step> (2.5E-4, 2.5E-4, 2.5E-4) </step> | Sample size along the three dimensions. |
<realOffset> <value> </realOffset> Ex: <realOffset> (0., 0., 0.) </realOffset> | Offset of the terrain. The terrain starts at (x=0, y=0, z(0, 0)) by default. Default (0., 0., 0.). |
<encoding> <value> </encoding> Ex: <encoding> "BIG_ENDIAN" </encoding> | Can be "LITTLE_ENDIAN" or "BIG_ENDIAN". UNIX systems are generally big endian whereas Intel systems are usually little endian. This field must refer to the system encoding where the binary file was created (necessary for binary files). |
<openMode> <value> </openMode> Ex: <openMode> "BINARY" </openMode> | Can be "ASCII" or "BINARY". Tells if the file is binary or ASCII. In the binary case, the encoding field is necessary. |
<type> <value> </type> Ex: <type> "UCHAR" </type> | Gives the data type (unsigned char, unsigned short, or float). Can be "UCHAR", "USHORT", "UINT", "FLOAT", "CHAR", "SHORT", "INT". |
</data> | Ends the data block. |
<texture> | Begins the texture block. |
<fileName> <value> </fileName> Ex: <fileName> "tex00.jpg" </fileName> | Texture file name between "". |
<level> <value> </level> Ex: <level> 0 </level> | Level of the texture. This is the level of the quadtree in which this texture appears. Levels start at 0. |
<position> <value> </position> Ex: <position> (0, 0) </position> | Position of the texture. This is the position of the texture inside the level. Can be omitted if level is zero. |
</texture> | Ends the texture block. |
</TerrainViz> | Ends the file. |
NOTE: | Blocks are order independent. Fields within the parent block are order independent too. There should be one data block and zero or more texture blocks. |
camera | NULL | |
maxRenderedTriangles | 2500 | |
triangleSizeAttenuation | 2.0 | deprecated |
distanceAttenuation | 3.4 | deprecated |
mappingMode | TVIZ_TEXTURES | |
frustumCulling | TRUE | |
normals | TRUE | |
normalQuality | TVIZ_32BIT_NORMALS |
SbTVizData, SbTVizRegularGridData, SbTVizTexture, SbTVizTextureList, SoTViz
COPY |
TerrainViz will make a copy of the data. |
NO_COPY |
Passed buffer used, user will delete (default). |
NO_COPY_AND_DELETE |
Passed buffer used, SoTVizRender will delete. |
SoTVizRender::SoTVizRender | ( | ) |
Constructor.
static SoType SoTVizRender::getClassTypeId | ( | ) | [static] |
Returns the type identifier for this class.
Reimplemented from SoShape.
const SbTVizColorScale* SoTVizRender::getColorScale | ( | ) | const |
Returns the color scale for contouring/shading.
const SbTVizData* SoTVizRender::getData | ( | ) | const |
Returns the elevation data.
const SbTVizTextureList* SoTVizRender::getTextureList | ( | ) | const |
Returns the texture list.
virtual SoType SoTVizRender::getTypeId | ( | ) | const [virtual] |
Returns the type identifier for this specific instance.
Reimplemented from SoShape.
SbBool SoTVizRender::loadFromXML | ( | const char * | fileName | ) |
Loads a TerrainViz description file (XML) and initializes the members SbTVizData and SbTVizTextureList.
Returns TRUE if loaded successfully, FALSE otherwise.
SbBool SoTVizRender::loadFromXML | ( | const FILE * | fd | ) |
Loads a TerrainViz description file (XML) and initializes the members SbTVizData and SbTVizTextureList.
Returns TRUE if loaded successfully, FALSE otherwise.
NOTE: In this case, files referenced in this XML file (elevation & textures) must be specified with an absolute path as the path of the XML file is unknown.
void SoTVizRender::setColorScale | ( | const SbTVizColorScale * | colorScale, | |
CopyPolicy | cp = SoTVizRender::NO_COPY | |||
) |
Sets the color scale for contouring/shading.
If TVIZ_COMPAT_20 is defined, the copy policy default is NO_COPY_AND_DELETE.
void SoTVizRender::setData | ( | const SbTVizData * | data, | |
CopyPolicy | cp = SoTVizRender::NO_COPY | |||
) |
Sets the elevation data.
If TVIZ_COMPAT_20 is defined, the copy policy default is NO_COPY_AND_DELETE.
void SoTVizRender::setTextureList | ( | const SbTVizTextureList * | texList, | |
CopyPolicy | cp = SoTVizRender::NO_COPY | |||
) |
Sets the texture list.
If TVIZ_COMPAT_20 is defined, the copy policy default is NO_COPY_AND_DELETE.
void SoTVizRender::showTarget | ( | SbBool | state | ) |
Displays the look-at vector.
SbBool SoTVizRender::writeToXML | ( | const char * | fileName | ) |
Writes the node description (elevation and textures) in a TerrainViz file as shown above.
Writes the node description (elevation and textures) in a TerrainViz file as shown above.
Specifies the camera to be used for real-time mesh processing.
If NULL, the current camera is used.
SoDEPRECATED SoSFFloat SoTVizRender::distanceAttenuation |
This field allows the user to decrease the number of triangles displayed as the camera gets further from the terrain.
If s is the largest dimension of the terrain, and d is the distance between the camera and the terrain, and
Enables frustum culling so that the invisible parts of the terrain are not rendered.
Mapping mode.
Two modes are available:
Specifies the maximum number of rendered triangles.
The number of triangles displayed can be decreased using the distanceAttenuation field.
Sets the normal quality.
Default value is: TVIZ_32BIT_NORMALS If the lighting of the terrain has black areas, you can increase the normal precision (e.g., specify TVIZ_64BIT_NORMALS) to remove this artifact.
Enables/disables the normals at each vertex.
Default is TRUE.
SoDEPRECATED SoSFFloat SoTVizRender::triangleSizeAttenuation |
Specifies the value used in the function 1/distance^triangleSizeAttenuation which specifies the triangle size variation according to the distance.
In other words, this field adjusts the mesh density. Larger values cause the triangle size to increase more rapidly (or conversely, the mesh density decreases more rapidly).