This is the abstract base class that defines the interface needed to describe a terrain for rendering by SpeedTree. More...
#include "stTerrain.h"
Public Member Functions | |
virtual void | clear () |
Resets the terrain to its initial, unloaded state. More... | |
virtual void | fill_vertices (GeomVertexData *data, PN_stdfloat start_x, PN_stdfloat start_y, PN_stdfloat size_xy, int num_xy) const |
After load_data() has been called, this will be called occasionally to populate the vertices for a terrain cell. More... | |
virtual TypeHandle | force_init_type () |
virtual PN_stdfloat | get_height (PN_stdfloat x, PN_stdfloat y) const =0 |
After load_data() has been called, this should return the computed height value at point (x, y) of the terrain, where x and y are unbounded and may refer to any 2-d point in space. More... | |
PN_stdfloat | get_max_height () const |
Returns the largest height value that might be returned by get_height(). More... | |
PN_stdfloat | get_min_height () const |
Returns the smallest height value that might be returned by get_height(). More... | |
const Filename & | get_normal_map () const |
Returns the normal map that should be applied to the terrain. More... | |
int | get_num_splat_layers () const |
Returns the number of splat layers that are to be applied to the terrain. More... | |
virtual PN_stdfloat | get_slope (PN_stdfloat x, PN_stdfloat y) const |
After load_data() has been called, this should return the directionless slope at point (x, y) of the terrain, where 0.0 is flat and 1.0 is vertical. More... | |
virtual PN_stdfloat | get_smooth_height (PN_stdfloat x, PN_stdfloat y, PN_stdfloat radius) const |
After load_data() has been called, this should return the approximate average height value over a circle of the specified radius, centered at point (x, y) of the terrain. More... | |
const Filename & | get_splat_layer (int n) const |
Returns the nth splat layer that is to be applied to the terrain. More... | |
LColor | get_splat_layer_color (int n) const |
Returns the overall color of the nth splat layer. More... | |
PN_stdfloat | get_splat_layer_tiling (int n) const |
Returns the tiling value of the nth splat layer. More... | |
const Filename & | get_splat_map () const |
Returns the splat map that should be applied to the terrain. More... | |
const SpeedTree::SVertexAttribDesc * | get_st_vertex_format () const |
Returns a pointer to the SpeedTree array of vertex attribs that defines the vertex format for SpeedTree. More... | |
virtual TypeHandle | get_type () const |
const GeomVertexFormat * | get_vertex_format () |
Returns the vertex format of the vertex array that is supported by this terrain data. More... | |
bool | is_valid () const |
Returns true if the terrain data is well-defined and ready to use. More... | |
virtual void | load_data ()=0 |
This will be called at some point after initialization. More... | |
virtual void | output (std::ostream &out) const |
bool | placement_is_acceptable (PN_stdfloat x, PN_stdfloat y, PN_stdfloat height_min, PN_stdfloat height_max, PN_stdfloat slope_min, PN_stdfloat slope_max) |
Returns true if the elevation and slope of point (x, y) fall within the requested limits, false otherwise. More... | |
virtual void | write (std::ostream &out, int indent_level=0) const |
Public Member Functions inherited from TypedReferenceCount | |
TypedReferenceCount (const TypedReferenceCount ©) | |
void | operator= (const TypedReferenceCount ©) |
Public Member Functions inherited from TypedObject | |
TypedObject (const TypedObject ©)=default | |
TypedObject * | as_typed_object () |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
const TypedObject * | as_typed_object () const |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
int | get_best_parent_from_Set (const std::set< int > &) const |
int | get_type_index () const |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More... | |
bool | is_exact_type (TypeHandle handle) const |
Returns true if the current object is the indicated type exactly. More... | |
bool | is_of_type (TypeHandle handle) const |
Returns true if the current object is or derives from the indicated type. More... | |
TypedObject & | operator= (const TypedObject ©)=default |
Public Member Functions inherited from ReferenceCount | |
int | get_ref_count () const |
WeakReferenceList * | get_weak_list () const |
Returns the WeakReferenceList associated with this ReferenceCount object. More... | |
bool | has_weak_list () const |
Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More... | |
void | local_object () |
This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More... | |
void | ref () const |
Explicitly increments the reference count. More... | |
bool | ref_if_nonzero () const |
Atomically increases the reference count of this object if it is not zero. More... | |
bool | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. More... | |
bool | test_ref_count_nonzero () const |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More... | |
virtual bool | unref () const |
Explicitly decrements the reference count. More... | |
WeakReferenceList * | weak_ref () |
Adds the indicated PointerToVoid as a weak reference to this object. More... | |
void | weak_unref () |
Removes the indicated PointerToVoid as a weak reference to this object. More... | |
Public Member Functions inherited from Namable | |
Namable (const std::string &initial_name="") | |
void | clear_name () |
Resets the Namable's name to empty. More... | |
const std::string & | get_name () const |
bool | has_name () const |
Returns true if the Namable has a nonempty name set, false if the name is empty. More... | |
void | output (std::ostream &out) const |
Outputs the Namable. More... | |
void | set_name (const std::string &name) |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
Static Public Member Functions inherited from TypedReferenceCount | |
static TypeHandle | get_class_type () |
static void | init_type () |
Static Public Member Functions inherited from TypedObject | |
static TypeHandle | get_class_type () |
static void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. More... | |
Static Public Member Functions inherited from ReferenceCount | |
static TypeHandle | get_class_type () |
static void | init_type () |
Static Public Member Functions inherited from Namable | |
static TypeHandle | get_class_type () |
static void | init_type () |
Additional Inherited Members | |
Public Attributes inherited from TypedObject | |
get_type | |
Public Attributes inherited from ReferenceCount | |
get_ref_count | |
Returns the current reference count. More... | |
Public Attributes inherited from Namable | |
get_name | |
set_name | |
This is the abstract base class that defines the interface needed to describe a terrain for rendering by SpeedTree.
To use it, you must subclass and override the appropriate virtual methods. Or, consider just using STBasicTerrain.
A terrain is defined as a 2-d height function over all space: get_height(x, y) may be called for any point in space and it should return a reasonable value. A terrain also provides normal maps and splat maps, as rendered by SpeedTree's Terrain.hlsl shader file.
Definition at line 34 of file stTerrain.h.
|
virtual |
Resets the terrain to its initial, unloaded state.
Reimplemented in STBasicTerrain.
Definition at line 56 of file stTerrain.cxx.
Referenced by STBasicTerrain::clear().
|
virtual |
After load_data() has been called, this will be called occasionally to populate the vertices for a terrain cell.
It will be passed a GeomVertexData whose format will match get_vertex_format(), and already allocated with num_xy * num_xy rows. This method should fill the rows of the data with the appropriate vertex data for the terrain, over the grid described by the corners (start_x, start_y) up to and including (start_x + size_x, start_y + size_xy)–a square of the terrain with num_xy vertices on a side, arranged in row-major order.
Reimplemented in STBasicTerrain.
Definition at line 143 of file stTerrain.cxx.
|
pure virtual |
After load_data() has been called, this should return the computed height value at point (x, y) of the terrain, where x and y are unbounded and may refer to any 2-d point in space.
Implemented in STBasicTerrain.
Definition at line 85 of file stTerrain.cxx.
Referenced by get_smooth_height(), and placement_is_acceptable().
|
inline |
Returns the largest height value that might be returned by get_height().
This is used as a culling optimization.
Definition at line 105 of file stTerrain.I.
|
inline |
Returns the smallest height value that might be returned by get_height().
This is used as a culling optimization.
Definition at line 96 of file stTerrain.I.
|
inline |
Returns the normal map that should be applied to the terrain.
This will be loaded and supplied to the shader.
Definition at line 27 of file stTerrain.I.
|
inline |
Returns the number of splat layers that are to be applied to the terrain.
This must be consistent with c_nNumTerrainSplatLayers in SpeedTree's TerrainRI.h.
Definition at line 48 of file stTerrain.I.
|
virtual |
After load_data() has been called, this should return the directionless slope at point (x, y) of the terrain, where 0.0 is flat and 1.0 is vertical.
This is used for determining the legal points to place trees and grass.
Reimplemented in STBasicTerrain.
Definition at line 106 of file stTerrain.cxx.
Referenced by placement_is_acceptable().
|
virtual |
After load_data() has been called, this should return the approximate average height value over a circle of the specified radius, centered at point (x, y) of the terrain.
Reimplemented in STBasicTerrain.
Definition at line 95 of file stTerrain.cxx.
References get_height().
|
inline |
Returns the nth splat layer that is to be applied to the terrain.
Definition at line 56 of file stTerrain.I.
|
inline |
Returns the overall color of the nth splat layer.
This is used just to match the color of the grass to its terrain.
Definition at line 76 of file stTerrain.I.
|
inline |
Returns the tiling value of the nth splat layer.
This is an arbitrary UV scale that is applied to each layer individually, by the terrain shader.
Definition at line 66 of file stTerrain.I.
|
inline |
Returns the splat map that should be applied to the terrain.
This will be loaded and supplied to the shader. Presumably, the shader will use the channels of this map to determine which of the splat layers are to be rendered at any given point.
Definition at line 38 of file stTerrain.I.
const SpeedTree::SVertexAttribDesc * STTerrain::get_st_vertex_format | ( | ) | const |
Returns a pointer to the SpeedTree array of vertex attribs that defines the vertex format for SpeedTree.
Definition at line 170 of file stTerrain.cxx.
|
inline |
Returns the vertex format of the vertex array that is supported by this terrain data.
A GeomVertexData of the requested format will be passed to fill_vertices().
Definition at line 87 of file stTerrain.I.
|
inline |
Returns true if the terrain data is well-defined and ready to use.
Definition at line 18 of file stTerrain.I.
Referenced by SpeedTreeNode::set_terrain().
|
pure virtual |
This will be called at some point after initialization.
It should be overridden by a derived class to load up the terrain data from its source and fill in the data members of this class appropriately, especially _is_valid. After this call, if _is_valid is true, then get_height() etc. will be called to query the terrain's data.
Implemented in STBasicTerrain.
Definition at line 76 of file stTerrain.cxx.
Referenced by SpeedTreeNode::set_terrain().
bool STTerrain::placement_is_acceptable | ( | PN_stdfloat | x, |
PN_stdfloat | y, | ||
PN_stdfloat | height_min, | ||
PN_stdfloat | height_max, | ||
PN_stdfloat | slope_min, | ||
PN_stdfloat | slope_max | ||
) |
Returns true if the elevation and slope of point (x, y) fall within the requested limits, false otherwise.
Definition at line 115 of file stTerrain.cxx.
References get_height(), and get_slope().