mercator  0.4.0
A terrain generation library for the Worldforge system.
Mercator::Surface Class Reference

Data store for terrain surface data. More...

#include <Surface.h>

Inheritance diagram for Mercator::Surface:
Collaboration diagram for Mercator::Surface:

Public Member Functions

 Surface (const Segment &segment, const Shader &shader, bool colors=true, bool alpha=true)
 Constructor. More...
 
void populate ()
 Populate the data buffer using the correct shader. More...
 
const SegmentgetSegment () const
 Accessor for the terrain height segment this surface is associated with. More...
 
ColorT & operator() (unsigned int x, unsigned int y, unsigned int channel)
 Retrieve the data value at a given point. More...
 
const ColorT & operator() (unsigned int x, unsigned int y, unsigned int channel) const
 Retrieve the data value at a given point. More...
 
unsigned int getSize () const
 Accessor for the size of segment, m_res + 1. More...
 
unsigned int getChannels () const
 Accessor for the number of data values per height point. More...
 
ColorT * getData ()
 Accessor for a pointer to buffer containing data values. More...
 
const ColorT * getData () const
 Accessor for a pointer to buffer containing data values. More...
 
void allocate ()
 Allocate the storage required by the buffer. More...
 
bool isValid () const
 Determine if this buffer has valid allocated storage. More...
 
void invalidate ()
 De-allocate the storage for this buffer. More...
 

Public Attributes

const Shaderm_shader
 The shader that populates this surface. More...
 
const Segmentm_segment
 The terrain height segment this buffer is associated with. More...
 

Protected Attributes

const unsigned int m_channels
 The number of data values per height point. More...
 
const unsigned int m_size
 The size of segment, m_res + 1. More...
 
std::vector< ColorT > m_data
 Pointer to buffer containing data values. More...
 

Detailed Description

Data store for terrain surface data.

Definition at line 23 of file Surface.h.

Constructor & Destructor Documentation

◆ Surface()

Mercator::Surface::Surface ( const Segment seg,
const Shader sh,
bool  color = true,
bool  alpha = true 
)
explicit

Constructor.

Parameters
segthe terrain height segment this surface maps on to.
shthe shader used to generate the surface data.
colortrue if this shader contains color data.
alphatrue if this shader contains alpha data.

Definition at line 18 of file Surface.cpp.

Member Function Documentation

◆ allocate()

void Mercator::Buffer< ColorT >::allocate ( )
inlineinherited

Allocate the storage required by the buffer.

Allocate memory based on the size and number of channels required by the buffer.

Definition at line 76 of file Buffer.h.

◆ getChannels()

unsigned int Mercator::Buffer< ColorT >::getChannels ( ) const
inlineinherited

Accessor for the number of data values per height point.

Definition at line 58 of file Buffer.h.

◆ getData() [1/2]

ColorT * Mercator::Buffer< ColorT >::getData ( )
inlineinherited

Accessor for a pointer to buffer containing data values.

Definition at line 63 of file Buffer.h.

◆ getData() [2/2]

const ColorT * Mercator::Buffer< ColorT >::getData ( ) const
inlineinherited

Accessor for a pointer to buffer containing data values.

Definition at line 68 of file Buffer.h.

◆ getSegment()

const Segment& Mercator::Surface::getSegment ( ) const
inline

◆ getSize()

unsigned int Mercator::Buffer< ColorT >::getSize ( ) const
inlineinherited

Accessor for the size of segment, m_res + 1.

Definition at line 53 of file Buffer.h.

◆ invalidate()

void Mercator::Buffer< ColorT >::invalidate ( )
inlineinherited

De-allocate the storage for this buffer.

Free the storage allocate for this buffer.

Definition at line 90 of file Buffer.h.

◆ isValid()

bool Mercator::Buffer< ColorT >::isValid ( ) const
inlineinherited

Determine if this buffer has valid allocated storage.

Returns
true if storage is allocated.

Definition at line 83 of file Buffer.h.

◆ operator()() [1/2]

ColorT & Mercator::Buffer< ColorT >::operator() ( unsigned int  x,
unsigned int  y,
unsigned int  channel 
)
inlineinherited

Retrieve the data value at a given point.

Access the data value associated with given point in the segment in a given channel in this buffer.

Returns
a reference to the value at the point requested.

Definition at line 36 of file Buffer.h.

◆ operator()() [2/2]

const ColorT & Mercator::Buffer< ColorT >::operator() ( unsigned int  x,
unsigned int  y,
unsigned int  channel 
) const
inlineinherited

Retrieve the data value at a given point.

Return the data value associated with given point in the segment in a given channel in this buffer.

Returns
the value at the point requested.

Definition at line 45 of file Buffer.h.

◆ populate()

void Mercator::Surface::populate ( )

Populate the data buffer using the correct shader.

Call the shader to full this surface buffer with surface data.

Definition at line 27 of file Surface.cpp.

References Mercator::Buffer< ColorT >::allocate(), Mercator::Buffer< ColorT >::isValid(), m_shader, and Mercator::Shader::shade().

Member Data Documentation

◆ m_channels

const unsigned int Mercator::Buffer< ColorT >::m_channels
protectedinherited

The number of data values per height point.

Definition at line 17 of file Buffer.h.

◆ m_data

std::vector<ColorT > Mercator::Buffer< ColorT >::m_data
protectedinherited

Pointer to buffer containing data values.

Definition at line 21 of file Buffer.h.

◆ m_segment

const Segment& Mercator::Surface::m_segment

The terrain height segment this buffer is associated with.

Definition at line 28 of file Surface.h.

Referenced by getSegment(), and Mercator::AreaShader::shade().

◆ m_shader

const Shader& Mercator::Surface::m_shader

The shader that populates this surface.

Definition at line 26 of file Surface.h.

Referenced by populate().

◆ m_size

const unsigned int Mercator::Buffer< ColorT >::m_size
protectedinherited

The size of segment, m_res + 1.

Definition at line 19 of file Buffer.h.


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