Support Forum G3D Web Page |
A tiled regular heightfield with a single detail level, suitable for very large terrains observed mostly from above.
More...
Inherits G3D::Model.
Classes | |
class | Specification |
class | Tile |
Public Member Functions | |
virtual const String & | className () const override |
Name of the G3D::Model subclass. More... | |
float | elevation (const Point3 &osPoint, Vector3 &faceNormal) const |
Return the elevation (y value) under (osPoint.x, -, osPoint.z) according to the tessellation used for rendering (i.e., using barycentric interpolation on the triangles, not bilinear interpolation on the grid). More... | |
float | elevation (const Point3 &osPoint) const |
const shared_ptr< Image > | elevationImage () const |
const shared_ptr< Texture > | elevationTexture () const |
virtual bool | intersect (const Ray &ray, const CoordinateFrame &cframe, float &maxDistance, Model::HitInfo &info=Model::HitInfo::ignore, const Entity *entity=nullptr, const Model::Pose *pose=nullptr) const override |
Determines if the ray intersects the heightfield and fills the info with the proper information. More... | |
virtual const String & | name () const override |
Name of the instance (usually based on the filename it is loaded from) More... | |
void | pose (Array< shared_ptr< Surface > > &surfaceArray, const CFrame &rootFrame, const CFrame &prevFrame, const shared_ptr< Entity > &entity, const Model::Pose *pose, const Model::Pose *prevPose, const Surface::ExpressiveLightScatteringProperties &e) override |
This will be replaced soon with a version that takes a shared_ptr<Pose>. More... | |
const Specification & | specification () const |
Static Public Member Functions | |
static shared_ptr< HeightfieldModel > | create (const Specification &spec, const String &name="Heightfield") |
static lazy_ptr< Model > | lazyCreate (const Specification &s, const String &name="") |
static lazy_ptr< Model > | lazyCreate (const String &name, const Any &any) |
static void | setUseOptimizedIntersect (bool b) |
If true, complex models should use TriTree to accelerate intersect() calls where possible. More... | |
static bool | useOptimizedIntersect () |
Protected Member Functions | |
HeightfieldModel (const Specification &spec, const String &name) | |
void | generateGeometry () |
Called from the constructor. More... | |
void | loadShaders () |
Called from the constructor. More... | |
void | setShaderArgs (Args &args) const |
This binds attribute arrays, so it cannot accept a UniformTable argument. More... | |
Static Protected Member Functions | |
template<class T , class ... ArgTypes> | |
static shared_ptr< T > | createShared (ArgTypes &&... args) |
Like std::make_shared, but works for protected constructors. More... | |
Protected Attributes | |
shared_ptr< Shader > | m_depthAndColorShader |
Used for depth-only and wire-frame rendering. More... | |
shared_ptr< Texture > | m_elevation |
Elevation texture. More... | |
shared_ptr< Image > | m_elevationImage |
Elevation image. More... | |
shared_ptr< Shader > | m_gbufferShader |
IndexStream | m_indexStream |
Indices of the mesh. More... | |
shared_ptr< UniversalMaterial > | m_material |
const String | m_name |
AttributeArray | m_positionArray |
Shared vertex buffer for the entire mesh. More... | |
int | m_quadsPerTileSide |
shared_ptr< Shader > | m_shader |
Used for all normal rendering. More... | |
const Specification | m_specification |
A tiled regular heightfield with a single detail level, suitable for very large terrains observed mostly from above.
The geometry is procedurally generated in the vertex shader, so this requires much less memory and can therefore represent much larger heightfields than an ArticulatedModel (which can also generate a heightfield at load time from an image).
Restrictions of the current implementation:
To provide more interesting material properties that vary with elevation and angle, consider subclassing HeightfieldModel or making a similar class from its source code.
|
protected |
|
overridevirtual |
Name of the G3D::Model subclass.
Implements G3D::Model.
|
inlinestatic |
Referenced by lazyCreate().
|
inlinestaticprotectedinherited |
Like std::make_shared, but works for protected constructors.
Call as createShared<myclass>.
Return the elevation (y value) under (osPoint.x, -, osPoint.z)
according to the tessellation used for rendering (i.e., using barycentric interpolation on the triangles, not bilinear interpolation on the grid).
The faceNormal is the normal to the triangle, not the shading normal.
Referenced by elevation().
|
inline |
|
inline |
|
inline |
|
protected |
Called from the constructor.
|
overridevirtual |
Determines if the ray intersects the heightfield and fills the info with the proper information.
maxDistance | Max distance to trace to on input, hit distance written on output if hit |
Reimplemented from G3D::Model.
|
inlinestatic |
Referenced by lazyCreate().
|
protected |
Called from the constructor.
|
inlineoverridevirtual |
Name of the instance (usually based on the filename it is loaded from)
Implements G3D::Model.
Referenced by create(), and lazyCreate().
|
overridevirtual |
This will be replaced soon with a version that takes a shared_ptr<Pose>.
pose | Must have the subclass of Model::Pose appropriate to the Model subclass. |
Implements G3D::Model.
|
protected |
This binds attribute arrays, so it cannot accept a UniformTable argument.
|
inlinestaticinherited |
If true, complex models should use TriTree to accelerate intersect() calls where possible.
This can make the first intersect() call very slow for the tree build and can make loading slow. It may not affect performance of skinned or articulated models that animate.
This value should be set before the models are loaded. If it is changed after a model is loaded, the Model is not required to respond to it.
Default: false
|
inline |
|
inlinestaticinherited |
|
protected |
Used for depth-only and wire-frame rendering.
|
protected |
Elevation texture.
Referenced by elevationTexture().
|
protected |
Elevation image.
Referenced by elevationImage().
|
protected |
|
protected |
Indices of the mesh.
|
protected |
|
protected |
Shared vertex buffer for the entire mesh.
Stored in XY, since the mesh is flat, with unit spacing between vertices (i.e., vertices are at integer positions)
|
protected |
|
protected |
Used for all normal rendering.
|
protected |
Referenced by specification().