Infinity Engine v0.6.20
C++ API Documentation
Loading...
Searching...
No Matches
Infinity::Types::Procedural::Landscape Class Reference

Renderable terrain representation with heightmap and material distribution data. More...

#include <Landscape.hpp>

Inheritance diagram for Infinity::Types::Procedural::Landscape:
[legend]
Collaboration diagram for Infinity::Types::Procedural::Landscape:
[legend]

Public Member Functions

virtual ~Landscape ()
 Destructor.
 
std::unique_ptr< Core::Baseclone () const override
 
const Infinity::Types::TypeIDtypeId () const override
 Gets the TypeID for Landscape.
 
- Public Member Functions inherited from Infinity::Types::Rendering::RenderObject
 RenderObject ()
 Default constructor.
 
virtual ~RenderObject ()
 Destructor.
 
std::unique_ptr< Core::Baseclone () const override
 
const Infinity::Types::TypeIDtypeId () const override
 Gets the TypeID for RenderObject.
 
- Public Member Functions inherited from Infinity::Types::Core::Data
 Data ()
 
 Data (const Data &other)
 
 Data (Data &&other)
 
Dataoperator= (const Data &other)
 
Dataoperator= (Data &&other)
 
virtual ~Data ()
 Virtual destructor.
 
bool hasProperty (const std::string &key) const
 
template<typename T >
void setProperty (const std::string &key, T &&value)
 Sets a typed property value.
 
template<typename T >
void setProperty (const std::string &key, const T &value)
 Sets a typed property value.
 
void setProperty (const std::string &key, PropertyValue &&value)
 Sets a typed property value.
 
const PropertyValuegetProperty (const std::string &key) const
 Gets a property value without type checking.
 
template<typename T >
const T & getProperty (const std::string &key) const
 Gets a typed property value.
 
void removeProperty (const std::string &key)
 
- Public Member Functions inherited from Infinity::Types::Core::Base
virtual ~Base ()
 Virtual destructor.
 
virtual std::istream & legibleDataRead (std::istream &in) override
 Deserializes the object from a single-line text representation.
 
virtual std::ostream & legibleDataWrite (std::ostream &out) const override
 Serializes the object to a single-line text representation.
 

Public Attributes

Containers::Heightmap heightmap
 Heightmap defining terrain elevation.
 
Containers::Array< Containers::Splatmapsplatmaps
 Material distribution splatmaps for texture blending.
 
Containers::Array< Containers::Array2D< float > > detailmaps
 Detail density maps for surface feature distribution.
 
- Public Attributes inherited from Infinity::Types::Rendering::RenderObject
Spatial::Transform transform
 World-space transform for this object.
 
Renderable renderable
 Renderable content (geometry, materials, instances).
 
- Public Attributes inherited from Infinity::Types::Core::Data
std::unordered_map< std::string, PropertyValueproperties
 Property storage for arbitrary metadata.
 

Detailed Description

Renderable terrain representation with heightmap and material distribution data.

Landscape encapsulates a complete terrain surface with elevation data, material distribution (splatmaps), and optional detail maps for vegetation or surface features. It extends RenderObject to provide full integration with the Infinity Engine's rendering pipeline while maintaining the procedural generation data needed for runtime modifications and streaming.

The landscape structure consists of:

  • Heightmap: Primary elevation data defining terrain shape (Array2D<float>)
  • Splatmaps: Material distribution maps for texture blending (Array of Array2D<uint8_t>)
  • Detailmaps: Optional density maps for grass, rocks, or other surface details

This unified representation enables:

  • Procedural terrain generation from noise and algorithms
  • Real-time terrain editing and sculpting
  • Material blending for realistic surfaces
  • Detail placement (vegetation, rocks, debris)
  • Streaming and LOD management
  • Collision mesh generation
  • Integration with physics systems

The heightmap defines the base terrain geometry, while splatmaps control which materials/textures appear at each location. Multiple splatmaps allow complex multi-material blending. Detailmaps provide additional per-texel data for spawning grass, rocks, or other surface elements.

Note
Inherits from RenderObject for rendering pipeline integration.
All maps should typically have matching or related resolutions.
Heightmap values are in world-space units (typically meters).
Splatmap values (0-255) represent material weights/indices.

Example usage:

// Create a procedural landscape
Landscape terrain;
// Generate heightmap from noise
terrain.heightmap = Heightmap(512, 512);
Noise terrainNoise("base64_mountain_config...");
terrainNoise.generate2D(terrain.heightmap.data(), 512, 512, worldSeed);
// Scale heightmap values to world units
for (size_t i = 0; i < terrain.heightmap.size(); ++i) {
terrain.heightmap[i] *= 100.0f; // 0-100 meter range
}
// Create material splatmaps
Splatmap grassMap(512, 512);
Splatmap rockMap(512, 512);
Splatmap snowMap(512, 512);
// Generate material distribution based on elevation and slope
for (size_t y = 0; y < 512; ++y) {
for (size_t x = 0; x < 512; ++x) {
float height = terrain.heightmap.at(x, y);
float slope = calculateSlope(terrain.heightmap, x, y);
// Grass at low elevations with gentle slopes
grassMap.at(x, y) = (height < 40.0f && slope < 0.3f) ? 255 : 0;
// Rock on steep slopes
rockMap.at(x, y) = (slope > 0.5f) ? 255 : 0;
// Snow at high elevations
snowMap.at(x, y) = (height > 80.0f) ? 255 : 0;
}
}
terrain.splatmaps.push_back(std::move(grassMap));
terrain.splatmaps.push_back(std::move(rockMap));
terrain.splatmaps.push_back(std::move(snowMap));
// Create detail maps for grass density
Array2D<float> grassDensity(512, 512);
Noise grassNoise("base64_grass_distribution...");
grassNoise.generate2D(grassDensity.data(), 512, 512, worldSeed + 1);
// Modulate grass density by grass splatmap
for (size_t i = 0; i < grassDensity.size(); ++i) {
float splatWeight = grassMap[i] / 255.0f;
grassDensity[i] = (grassDensity[i] * 0.5f + 0.5f) * splatWeight;
}
terrain.detailmaps.push_back(std::move(grassDensity));
// Use with ProceduralSystem
system->setIn("generated_terrain", std::move(terrain));
// Chunk-based landscape generation
Landscape chunk = generateTerrainChunk(chunkX, chunkZ, worldSeed);
T & at(size_t x, size_t y)
Accesses element at 2D coordinates.
Definition Array2D.hpp:192
T * data()
Gets a pointer to the underlying data array.
Definition Array.hpp:604
size_t size() const noexcept override
Gets the number of elements in the array.
Definition Array.hpp:696
Renderable terrain representation with heightmap and material distribution data.
Definition Landscape.hpp:106
Containers::Array< Containers::Array2D< float > > detailmaps
Detail density maps for surface feature distribution.
Definition Landscape.hpp:166
Containers::Array< Containers::Splatmap > splatmaps
Material distribution splatmaps for texture blending.
Definition Landscape.hpp:144
Containers::Heightmap heightmap
Heightmap defining terrain elevation.
Definition Landscape.hpp:123
Configurable procedural noise generator powered by FastNoise2.
Definition Noise.hpp:97

Constructor & Destructor Documentation

◆ ~Landscape()

virtual Infinity::Types::Procedural::Landscape::~Landscape ( )
virtual

Destructor.

Member Function Documentation

◆ clone()

std::unique_ptr< Core::Base > Infinity::Types::Procedural::Landscape::clone ( ) const
overridevirtual

Reimplemented from Infinity::Types::Core::Data.

◆ typeId()

const Infinity::Types::TypeID & Infinity::Types::Procedural::Landscape::typeId ( ) const
overridevirtual

Gets the TypeID for Landscape.

Returns
TypeID identifying this Landscape type.

Reimplemented from Infinity::Types::Core::Data.

Member Data Documentation

◆ detailmaps

Containers::Array<Containers::Array2D<float> > Infinity::Types::Procedural::Landscape::detailmaps

Detail density maps for surface feature distribution.

Array of 2D float maps defining density/probability values for placing surface details like grass, rocks, flowers, or debris. Values typically range from 0.0 (no details) to 1.0 (maximum density).

Typical usage:

  • detailmaps[0]: Grass blade density
  • detailmaps[1]: Rock/pebble scatter density
  • detailmaps[2]: Flower/plant density
  • detailmaps[3]: Debris/clutter density

These maps are sampled during detail placement to control where and how densely surface features appear, enabling realistic and varied terrain surfaces.

Note
Resolution can differ from heightmap for optimization.
Often combined with noise for natural variation.

◆ heightmap

Containers::Heightmap Infinity::Types::Procedural::Landscape::heightmap

Heightmap defining terrain elevation.

2D array of float values representing the terrain's vertical displacement at each point. Values are typically in world-space units (meters) and define the shape of the landscape surface.

Common resolutions:

  • 256x256: Low-detail terrain or distant LODs
  • 512x512: Standard terrain chunks
  • 1024x1024 or higher: High-detail hero terrain
Note
Heightmap resolution determines terrain geometric detail.
Higher values = higher elevation in world space.

◆ splatmaps

Containers::Array<Containers::Splatmap> Infinity::Types::Procedural::Landscape::splatmaps

Material distribution splatmaps for texture blending.

Array of 2D uint8 maps where each map represents the weight/presence of a specific material at each terrain location. Values range from 0 (material absent) to 255 (material fully present).

Typical usage:

  • splatmaps[0]: Grass/vegetation material
  • splatmaps[1]: Rock/stone material
  • splatmaps[2]: Dirt/soil material
  • splatmaps[3]: Snow/ice material

Multiple splatmaps are blended together during rendering to create smooth transitions between terrain materials.

Note
Each splatmap should match or relate to the heightmap resolution.
The rendering system normalizes weights for proper blending.