Inheritance diagram for demeter::Terrain:
Public Types | |
enum | DIRECTION { DIR_NORTH = 0, DIR_NORTHEAST = 1, DIR_EAST = 2, DIR_SOUTHEAST = 3, DIR_SOUTH = 4, DIR_SOUTHWEST = 5, DIR_WEST = 6, DIR_NORTHWEST = 7, DIR_CENTER = 8, DIR_INVALID = 9 } |
Public Member Functions | |
Terrain (char *szElevationsFilename, char *szTextureFilename, char *szDetailTextureFilename, float vertexSpacing, float elevationScale, int maxNumTriangles, bool bUseBorders) | |
Constructs a new terrain from raw grayscale data. This constructor is only used by the terrain compiler and should generally not be used by applications. Applications should use the constructor that takes map files (map files are generated by the terrain compiler.). | |
Terrain (char *szCompiledMapFilename, int maxNumTriangles, bool bUseBorders=false, float offsetX=0.0f, float offsetY=0.0f) | |
Constructs a new terrain from a compiled map file. Map files are created by the terrain compiler and they can be distributed with your application. | |
Terrain (char *szURL, char *szCompiledMapFilename, int maxNumTriangles, bool bUseBorders=false) | |
Constructs a new terrain by downloading a compiled map file from a remote HTTP server. Map files are created by the terrain compiler. The URL should be a well formed address with the protocol explicitly listed (for example, "http://www.terrainengine.com") The compiled map file AND the texture and detail texture files that are referenced by the compiled map file should be available from the same URL. | |
~Terrain () | |
Destructor. | |
int | Tessellate () |
Based on the current viewing parameters, this method breaks the terrain down into a visually optimum set of triangles that can be rendered. Normally, an application will never call this method directly, but will instead call the method ModelViewMatrixChanged() to allow Demeter to take care of this automatically. | |
void | Render () |
Renders the terrain to the current OpenGL surface. Applications should always call ModelViewMatrixChanged() at least once prior to calling Render(), so that Demeter will have a chance to tessellate the terrain. | |
void | SetDetailThreshold (float threshold) |
Sets the "detail theshold", which controls how much Demeter simplifies the terrain. Higher thresholds will increase performance but make the terrain look worse, while lower thresholds will reduce performance and increase visual quality. Extremely high thresholds can cause significant visual artifacts and make the terrain look very strange. | |
float | GetDetailThreshold () |
Returns the "detail threshold", which controls how much Demeter simplifies the terrain. Higher thresholds will increase performance but make the terrain look worse, while lower thresholds will reduce performance and increase visual quality. Extremely high thresholds can cause significant visual artifacts and make the terrain look very strange. | |
void | SetMaximumVisibleBlockSize (int stride) |
Sets the maximum size of blocks that can be simplified when the terrain is tessellated. The parameter stride specifies the number of vertices along one edge of the block (blocks are always square.) This parameter can be used by applications that allow much of the terrain to be visible from above, such as flight simulators, to prevent oversimplification of terrain in the distance. Setting this value too low will adversely affect performance. | |
int | GetWidthVertices () |
Returns the width of the terrain in vertices (this is the count of vertices along the world's x-axis.). | |
int | GetHeightVertices () |
Returns the height of the terrain in vertices (this is the count of vertices along the world's y-axis.). | |
float | GetWidth () const |
Returns the width of the terrain in real units (this is the length of the terrain along the world's x-axis.). | |
float | GetHeight () const |
Returns the height of the terrain in real units (this is the length of the terrain along the world's y-axis.). | |
float | GetVertexSpacing () |
Returns the number of real units between vertices in the terrain's mesh. | |
float | GetElevation (float x, float y) |
Returns the elevation (z-coordinate) in real units of the specified point on the terrain. | |
float | GetElevation (int index) |
Returns the elevation (z-coordinate) in real units of the specified terrain vertex. | |
void | GetNormal (float x, float y, float &normalX, float &normalY, float &normalZ) |
Returns the surface normal of the terrain at the specified point. | |
float | GetMaxElevation () const |
Returns the elevation (z-coordinate) in real units of the highest point on the terrain. | |
float | GetVertexElevation (int index) const |
Returns the elevation (z-coordinate) in real units of the specified vertex on the terrain. | |
void | SetVertexElevation (int index, float newElevation) |
Sets the elevation (z-coordinate) in real units of the specified vertex on the terrain. | |
bool | Write (char *szCompiledMapFilename) |
Writes the current terrain to disk as a compiled map file. This method is used by the terrain compiler, but could also be used by applications as a way to persist the terrain's current state. | |
int | GetNumberOfVertices () |
Returns the total number of vertices in the terrain's mesh. | |
int | GetTextureTileWidth () |
Returns the width (in vertices) of the terrain's texture tiles. | |
int | GetTextureTileHeight () |
Returns the height (in vertices) of the terrain's texture tiles. | |
int | GetNumberOfTextureTilesWidth () |
Returns the number of texture tiles along the terrain's x-axis. | |
int | GetNumberOfTextureTilesHeight () |
Returns the number of texture tiles along the terrain's y-axis. | |
GLuint | GetTerrainTile (int index) |
Returns the OpenGL texture number (which can be used in calls to glBindTexture()) of the specified tile. This method could be used by applications that allow some form of terrain "editing" by the user, etc. where it is necessary to show the user some or all of the tiles on the map. | |
bool | SetTexture (char *szFilename, bool bUseBorders) |
Applies the specified graphics image as a texture to the terrain. This is done by breaking the specified image up into smaller textures of 256x256 called "tiles" and mapping these contiguously onto the terrain's surface. The parameter bUseBorders specified whether or not the texture border OpenGL extensions should be used when creating the tiles. Textures are automatically applied when loading compiled map files, so use of this method is strictly optional. | |
bool | SetCommonTexture (char *szFilename) |
Uses the specified graphics file to apply a "common" texture to the entire surface of the terrain. A common texture is repeated across the entire terrain and is blended with the terrain's normal texture (if blending is supported by the user's hardware - which covers almost all OpenGL cards.) This is used to provide a "detailed" texture to give the ground some definition when the camera is close to the ground. | |
void | SetCommonTextureRepeats (float commonTextureRepeats) |
Sets the number of times that the "common" texture (as set by a call to SetCommonTexture()) is to repeated within each texture tile. | |
float | GetCommonTextureRepeats () |
Returns the number of times that the "common" texture (as set by a call to SetCommonTexture()) is to repeated within each texture tile. | |
void | SetFluidElevation (float elevation) |
Not yet well implemented. Fluid support will be available soon. | |
bool | SetFluidTexture (char *szFilename) |
Not yet well implemented. Fluid support will be available soon. | |
void | Animate () |
Not yet well implemented. Animation support will be available soon. | |
int | ModelViewMatrixChanged () |
Notifies Demeter that OpenGL's modelview matrix has been modified, allowing Demeter to tessellate the terrain based on the new modelview matrix. It is IMPERATIVE that his method be called every time the modelview matrix is changed, even if this is in every single rendering cycle of the application. | |
bool | CubeInFrustum (float x, float y, float z, float size) |
Returns whether or not the specified cube is inside of the viewing frustum (as defined at the previous call to ModelViewMatrixChanged()). | |
bool | IsMultiTextureSupported () |
Indicates whether or not OpenGL multitexture extensions are available from the OpenGL driver that this terrain instance is currently rendering against (as determined at the time the terrain instance was first constructed.). | |
void | DisableTextures () |
A convenience method that sets the current OpenGL state to untextured. Calling this method disables texture state immediately; it has no effect on the terrain itself (which will reenable textures the next time it is rendered.) This is only a convenience method that allows external callers to have easy access to OpenGL multitexture extensions. There is rarely a good reason for applications to call this method. | |
void | EnableTextures () |
A convenience method that sets the current OpenGL state to textured. Calling this method enables texture state immediately; it has no effect on the terrain itself (which will reenable textures the next time it is rendered.) This is only a convenience method that allows external callers to have easy access to OpenGL multitexture extensions. There is rarely a good reason for applications to call this method. | |
void | SetLatticePosition (int x, int y) |
void | GetLatticePosition (int &x, int &y) |
Friends | |
class | Triangle |
class | TriangleStrip |
class | TerrainBlock |
class | TriangleFan |
class | TerrainLattice |
Definition at line 154 of file CLODTerrainRenderer.
|
Definition at line 246 of file CLODTerrainRenderer. |
|
Constructs a new terrain from raw grayscale data. This constructor is only used by the terrain compiler and should generally not be used by applications. Applications should use the constructor that takes map files (map files are generated by the terrain compiler.).
Definition at line 550 of file CLODTerrainRenderer.cpp. References Exception, demeter::Settings::GetInstance(), IsPowerOf2(), demeter::Settings::PrependMediaPath(), SetCommonTexture(), SetTexture(), demeter::Uint32, demeter::Uint8, demeter::Vector::x, demeter::Vector::y, and demeter::Vector::z. |
|
Constructs a new terrain from a compiled map file. Map files are created by the terrain compiler and they can be distributed with your application.
Definition at line 659 of file CLODTerrainRenderer.cpp. |
|
Constructs a new terrain by downloading a compiled map file from a remote HTTP server. Map files are created by the terrain compiler. The URL should be a well formed address with the protocol explicitly listed (for example, "http://www.terrainengine.com") The compiled map file AND the texture and detail texture files that are referenced by the compiled map file should be available from the same URL.
Definition at line 665 of file CLODTerrainRenderer.cpp. |
|
Destructor.
Definition at line 673 of file CLODTerrainRenderer.cpp. |
|
Not yet well implemented. Animation support will be available soon.
|
|
Returns whether or not the specified cube is inside of the viewing frustum (as defined at the previous call to ModelViewMatrixChanged()).
Definition at line 1797 of file CLODTerrainRenderer.cpp. Referenced by demeter::TerrainBlock::Tessellate(). |
|
A convenience method that sets the current OpenGL state to untextured. Calling this method disables texture state immediately; it has no effect on the terrain itself (which will reenable textures the next time it is rendered.) This is only a convenience method that allows external callers to have easy access to OpenGL multitexture extensions. There is rarely a good reason for applications to call this method.
Definition at line 1511 of file CLODTerrainRenderer.cpp. References GL_TEXTURE0_ARB, GL_TEXTURE1_ARB, and glActiveTextureARB_ptr. Referenced by demeter::DemeterDrawable::drawImplementation(). |
|
A convenience method that sets the current OpenGL state to textured. Calling this method enables texture state immediately; it has no effect on the terrain itself (which will reenable textures the next time it is rendered.) This is only a convenience method that allows external callers to have easy access to OpenGL multitexture extensions. There is rarely a good reason for applications to call this method.
Definition at line 1524 of file CLODTerrainRenderer.cpp. References GL_TEXTURE0_ARB, GL_TEXTURE1_ARB, and glActiveTextureARB_ptr. |
|
Returns the number of times that the "common" texture (as set by a call to SetCommonTexture()) is to repeated within each texture tile.
Definition at line 1414 of file CLODTerrainRenderer.cpp. Referenced by demeter::TriangleFan::Render(), and demeter::TriangleStrip::Render(). |
|
Returns the "detail threshold", which controls how much Demeter simplifies the terrain. Higher thresholds will increase performance but make the terrain look worse, while lower thresholds will reduce performance and increase visual quality. Extremely high thresholds can cause significant visual artifacts and make the terrain look very strange.
Definition at line 1023 of file CLODTerrainRenderer.cpp. Referenced by demeter::TerrainBlock::Tessellate(). |
|
Returns the elevation (z-coordinate) in real units of the specified terrain vertex.
Definition at line 955 of file CLODTerrainRenderer.cpp. References demeter::Vector::z. |
|
Returns the elevation (z-coordinate) in real units of the specified point on the terrain.
Definition at line 960 of file CLODTerrainRenderer.cpp. References demeter::Plane::a, demeter::Plane::b, demeter::Plane::c, demeter::Plane::d, demeter::Plane::defineFromPoints(), GetHeight(), and GetWidth(). Referenced by demeter::TerrainBlock::DummyFunc(), demeter::TerrainLattice::GetElevation(), and demeter::TerrainBlock::TerrainBlock(). |
|
Returns the height of the terrain in real units (this is the length of the terrain along the world's y-axis.).
Definition at line 1043 of file CLODTerrainRenderer.cpp. Referenced by demeter::TerrainBlock::DummyFunc(), GetElevation(), GetNormal(), and demeter::TerrainLattice::Load(). |
|
Returns the height of the terrain in vertices (this is the count of vertices along the world's y-axis.).
Definition at line 1033 of file CLODTerrainRenderer.cpp. Referenced by demeter::TerrainBlock::DummyFunc(), and Tessellate(). |
|
Definition at line 1851 of file CLODTerrainRenderer.cpp. |
|
Returns the elevation (z-coordinate) in real units of the highest point on the terrain.
Definition at line 1048 of file CLODTerrainRenderer.cpp. |
|
Returns the surface normal of the terrain at the specified point.
Definition at line 990 of file CLODTerrainRenderer.cpp. References demeter::Plane::a, demeter::Plane::b, demeter::Plane::c, demeter::Plane::defineFromPoints(), GetHeight(), and GetWidth(). |
|
Returns the number of texture tiles along the terrain's y-axis.
Definition at line 1684 of file CLODTerrainRenderer.cpp. |
|
Returns the number of texture tiles along the terrain's x-axis.
Definition at line 1679 of file CLODTerrainRenderer.cpp. Referenced by demeter::TriangleFan::Setup(), and demeter::TriangleStrip::Setup(). |
|
Returns the total number of vertices in the terrain's mesh.
Definition at line 776 of file CLODTerrainRenderer.cpp. |
|
Returns the OpenGL texture number (which can be used in calls to glBindTexture()) of the specified tile. This method could be used by applications that allow some form of terrain "editing" by the user, etc. where it is necessary to show the user some or all of the tiles on the map.
Definition at line 1689 of file CLODTerrainRenderer.cpp. References demeter::Texture::UploadTexture(). Referenced by Render(). |
|
Returns the height (in vertices) of the terrain's texture tiles.
Definition at line 1674 of file CLODTerrainRenderer.cpp. Referenced by demeter::TriangleFan::Render(), demeter::TriangleStrip::Render(), demeter::TriangleFan::Setup(), and demeter::TriangleStrip::Setup(). |
|
Returns the width (in vertices) of the terrain's texture tiles.
Definition at line 1669 of file CLODTerrainRenderer.cpp. Referenced by demeter::TriangleFan::Render(), demeter::TriangleStrip::Render(), demeter::TriangleFan::Setup(), and demeter::TriangleStrip::Setup(). |
|
Returns the elevation (z-coordinate) in real units of the specified vertex on the terrain.
Definition at line 1053 of file CLODTerrainRenderer.cpp. References demeter::Vector::z. |
|
Returns the number of real units between vertices in the terrain's mesh.
Definition at line 1071 of file CLODTerrainRenderer.cpp. Referenced by demeter::TerrainBlock::CalculateGeometry(), and demeter::TerrainBlock::DummyFunc(). |
|
Returns the width of the terrain in real units (this is the length of the terrain along the world's x-axis.).
Definition at line 1038 of file CLODTerrainRenderer.cpp. Referenced by demeter::TerrainBlock::DummyFunc(), GetElevation(), GetNormal(), and demeter::TerrainLattice::Load(). |
|
Returns the width of the terrain in vertices (this is the count of vertices along the world's x-axis.).
Definition at line 1028 of file CLODTerrainRenderer.cpp. Referenced by demeter::TerrainBlock::CalculateGeometry(), demeter::TerrainBlock::RepairCracks(), demeter::TerrainBlock::TerrainBlock(), Tessellate(), and demeter::TerrainBlock::Tessellate(). |
|
Indicates whether or not OpenGL multitexture extensions are available from the OpenGL driver that this terrain instance is currently rendering against (as determined at the time the terrain instance was first constructed.).
Definition at line 771 of file CLODTerrainRenderer.cpp. |
|
Notifies Demeter that OpenGL's modelview matrix has been modified, allowing Demeter to tessellate the terrain based on the new modelview matrix. It is IMPERATIVE that his method be called every time the modelview matrix is changed, even if this is in every single rendering cycle of the application.
Definition at line 1424 of file CLODTerrainRenderer.cpp. References demeter::TerrainBlock::RepairCracks(), and Tessellate(). Referenced by demeter::DemeterDrawable::drawImplementation(). |
|
Renders the terrain to the current OpenGL surface. Applications should always call ModelViewMatrixChanged() at least once prior to calling Render(), so that Demeter will have a chance to tessellate the terrain.
Definition at line 1431 of file CLODTerrainRenderer.cpp. References f, demeter::Settings::GetInstance(), GetTerrainTile(), GL_COMBINE_RGB_EXT, GL_TEXTURE0_ARB, GL_TEXTURE1_ARB, glActiveTextureARB_ptr, demeter::TriangleFan::Render(), demeter::TriangleStrip::Render(), demeter::TriangleFan::Setup(), demeter::TriangleStrip::Setup(), demeter::TriangleFan::textureId, demeter::TriangleStrip::textureId, demeter::Texture::UploadTexture(), and demeter::Settings::UseDynamicTextures(). Referenced by demeter::DemeterDrawable::drawImplementation(), and demeter::TerrainLattice::Render(). |
|
Uses the specified graphics file to apply a "common" texture to the entire surface of the terrain. A common texture is repeated across the entire terrain and is blended with the terrain's normal texture (if blending is supported by the user's hardware - which covers almost all OpenGL cards.) This is used to provide a "detailed" texture to give the ground some definition when the camera is close to the ground.
Definition at line 1159 of file CLODTerrainRenderer.cpp. References Exception, demeter::Settings::GetInstance(), demeter::Settings::IsCompilerOnly(), IsPowerOf2(), demeter::Settings::IsVerbose(), LoadImage(), demeter::Settings::PrependMediaPath(), and demeter::Uint8. Referenced by Terrain(). |
|
Sets the number of times that the "common" texture (as set by a call to SetCommonTexture()) is to repeated within each texture tile.
Definition at line 1419 of file CLODTerrainRenderer.cpp. |
|
Sets the "detail theshold", which controls how much Demeter simplifies the terrain. Higher thresholds will increase performance but make the terrain look worse, while lower thresholds will reduce performance and increase visual quality. Extremely high thresholds can cause significant visual artifacts and make the terrain look very strange.
Definition at line 1018 of file CLODTerrainRenderer.cpp. Referenced by demeter::TerrainLattice::SetDetailThreshold(). |
|
Not yet well implemented. Fluid support will be available soon.
|
|
Not yet well implemented. Fluid support will be available soon.
|
|
Definition at line 1845 of file CLODTerrainRenderer.cpp. Referenced by demeter::TerrainLattice::AddTerrain(). |
|
Sets the maximum size of blocks that can be simplified when the terrain is tessellated. The parameter stride specifies the number of vertices along one edge of the block (blocks are always square.) This parameter can be used by applications that allow much of the terrain to be visible from above, such as flight simulators, to prevent oversimplification of terrain in the distance. Setting this value too low will adversely affect performance.
Definition at line 1409 of file CLODTerrainRenderer.cpp. |
|
Applies the specified graphics image as a texture to the terrain. This is done by breaking the specified image up into smaller textures of 256x256 called "tiles" and mapping these contiguously onto the terrain's surface. The parameter bUseBorders specified whether or not the texture border OpenGL extensions should be used when creating the tiles. Textures are automatically applied when loading compiled map files, so use of this method is strictly optional.
Definition at line 1229 of file CLODTerrainRenderer.cpp. References Exception, demeter::Settings::GetInstance(), demeter::Settings::IsCompilerOnly(), demeter::Settings::IsHeadless(), IsPowerOf2(), demeter::Settings::IsVerbose(), LoadImage(), demeter::Settings::PrependMediaPath(), and demeter::Uint8. Referenced by Terrain(). |
|
Sets the elevation (z-coordinate) in real units of the specified vertex on the terrain.
Definition at line 1063 of file CLODTerrainRenderer.cpp. References demeter::Vector::z. |
|
Based on the current viewing parameters, this method breaks the terrain down into a visually optimum set of triangles that can be rendered. Normally, an application will never call this method directly, but will instead call the method ModelViewMatrixChanged() to allow Demeter to take care of this automatically.
Definition at line 1118 of file CLODTerrainRenderer.cpp. References base::BitArray::Clear(), GetHeightVertices(), demeter::Settings::GetInstance(), GetWidthVertices(), demeter::Settings::IsVerbose(), and demeter::TerrainBlock::Tessellate(). Referenced by ModelViewMatrixChanged(), and demeter::TerrainLattice::Tessellate(). |
|
Writes the current terrain to disk as a compiled map file. This method is used by the terrain compiler, but could also be used by applications as a way to persist the terrain's current state.
Definition at line 781 of file CLODTerrainRenderer.cpp. References demeter::Settings::GetInstance(), and demeter::Settings::PrependMediaPath(). |
|
Definition at line 294 of file CLODTerrainRenderer. |
|
Definition at line 296 of file CLODTerrainRenderer. |
|
Definition at line 292 of file CLODTerrainRenderer. |
|
Definition at line 295 of file CLODTerrainRenderer. |
|
Definition at line 293 of file CLODTerrainRenderer. |