mercator  0.4.0
A terrain generation library for the Worldforge system.
Mercator::SlopeTerrainMod< Shape > Class Template Reference

Terrain modifier that defines an area of sloped height. More...

#include <TerrainMod.h>

Inheritance diagram for Mercator::SlopeTerrainMod< Shape >:
Collaboration diagram for Mercator::SlopeTerrainMod< Shape >:

Public Member Functions

 SlopeTerrainMod (float level, float dx, float dz, const Shape< 2 > &s)
 Constructor. More...
 
 SlopeTerrainMod (SlopeTerrainMod &)=delete
 Copy constructor. More...
 
virtual void apply (float &point, int x, int z) const
 Apply this modifier on a terrain segment. More...
 
void setShape (float level, float dx, float dz, const Shape< 2 > &s)
 
bool checkIntersects (const Segment &s) const override
 
void setShape (const Shape< 2 > &s)
 
void setFunction (effector_func f)
 Change the function used to apply this mod to existing points. More...
 
Contextcontext () const
 
void setContext (std::unique_ptr< Context > context)
 
const WFMath::AxisBox< 2 > & bbox () const
 Accessor for the bounding box of the geometric shape. More...
 

Protected Attributes

float m_level
 The height of the centre point. More...
 
float m_dx
 The rate of change of the height along X. More...
 
float m_dz
 The rate of change of the height along Z. More...
 
Shape< 2 > m_shape
 Shape of the modifier. More...
 
effector_func m_function
 Function used to apply this mod to existing points. More...
 
WFMath::AxisBox< 2 > m_box
 The bounding box of the geometric shape. More...
 
std::unique_ptr< Contextm_context
 The application context of this effector. More...
 

Detailed Description

template<template< int > class Shape>
class Mercator::SlopeTerrainMod< Shape >

Terrain modifier that defines an area of sloped height.

This modifier creates a sloped area. The center point is set to a level and all other points are set based on specified gradients.

Definition at line 134 of file TerrainMod.h.

Constructor & Destructor Documentation

◆ SlopeTerrainMod() [1/2]

template<template< int > class Shape>
Mercator::SlopeTerrainMod< Shape >::SlopeTerrainMod ( float  level,
float  dx,
float  dz,
const Shape< 2 > &  s 
)
inline

Constructor.

Parameters
levelthe height of the centre point.
dxthe rate of change of the height along X.
dzthe rate of change of the height along Z.
sshape of the modifier.

Definition at line 144 of file TerrainMod.h.

References Mercator::TerrainMod::apply().

◆ SlopeTerrainMod() [2/2]

template<template< int > class Shape>
Mercator::SlopeTerrainMod< Shape >::SlopeTerrainMod ( SlopeTerrainMod< Shape > &  )
delete

Copy constructor.

Member Function Documentation

◆ apply()

template<template< int > class Shape>
void Mercator::SlopeTerrainMod< Shape >::apply ( float &  point,
int  x,
int  z 
) const
virtual

Apply this modifier on a terrain segment.

The segment is at x,y in local coordinates. Output is placed into point.

Implements Mercator::TerrainMod.

Definition at line 74 of file TerrainMod_impl.h.

References Mercator::TerrainMod::m_function, and Mercator::ShapeTerrainMod< Shape >::m_shape.

◆ bbox()

const WFMath::AxisBox<2>& Mercator::Effector::bbox ( ) const
inlineinherited

Accessor for the bounding box of the geometric shape.

Definition at line 37 of file Effector.h.

References Mercator::Effector::Effector(), Mercator::Effector::m_box, and Mercator::Effector::operator=().

Referenced by Mercator::Segment::clearMods(), and Mercator::Forest::populate().

◆ setFunction()

void Mercator::TerrainMod::setFunction ( effector_func  f)
inlineinherited

Change the function used to apply this mod to existing points.

Definition at line 36 of file TerrainMod.h.

References Mercator::TerrainMod::apply().

Member Data Documentation

◆ m_box

WFMath::AxisBox<2> Mercator::Effector::m_box
protectedinherited

◆ m_context

std::unique_ptr<Context> Mercator::Effector::m_context
protectedinherited

The application context of this effector.

Definition at line 60 of file Effector.h.

Referenced by Mercator::Effector::operator=().

◆ m_dx

template<template< int > class Shape>
float Mercator::SlopeTerrainMod< Shape >::m_dx
protected

The rate of change of the height along X.

Definition at line 160 of file TerrainMod.h.

◆ m_dz

template<template< int > class Shape>
float Mercator::SlopeTerrainMod< Shape >::m_dz
protected

The rate of change of the height along Z.

Definition at line 162 of file TerrainMod.h.

◆ m_function

effector_func Mercator::TerrainMod::m_function
protectedinherited

Function used to apply this mod to existing points.

This makes the basic mods much more powerful without the need for extra classes. It completely obsoletes AdjustTerrainMod, which is now the same as LevelTerrainMod with this function changed from set() to sum()

Definition at line 29 of file TerrainMod.h.

Referenced by Mercator::LevelTerrainMod< Shape >::apply(), and Mercator::SlopeTerrainMod< Shape >::apply().

◆ m_level

template<template< int > class Shape>
float Mercator::SlopeTerrainMod< Shape >::m_level
protected

The height of the centre point.

Definition at line 158 of file TerrainMod.h.

◆ m_shape


The documentation for this class was generated from the following files: