voxelTerrain
 All Classes Functions Variables Typedefs Enumerations Pages
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
blub::procedural::voxel::edit::base< configType > Class Template Referenceabstract

base class of all edits. Has various features you may wanna overwrite. If you want to write your own edit overwrite the method calculateOneVoxel() or calculateVoxel(). For most flexibility override calculateVoxel(). Because base derives enableSharedFromThis you have to write a create method that creates a shared_ptr of the class. More...

#include <base.hpp>

Inheritance diagram for blub::procedural::voxel::edit::base< configType >:
blub::enableSharedFromThis< base< configType > > blub::noncopyable blub::procedural::voxel::edit::axisAlignedBox< configType > blub::procedural::voxel::edit::noise< configType > blub::procedural::voxel::edit::sphere< configType > customEdit< configType >

Public Types

typedef configType t_config
 
typedef enableSharedFromThis
< base< t_config > > 
t_base
 
typedef sharedPointer< base
< t_config > > 
pointer
 
typedef
t_config::t_container::t_simple 
t_voxelContainerSimple
 
typedef
t_config::t_container::t_tile 
t_voxelContainerTile
 
typedef t_config::t_data t_voxel
 
- Public Types inherited from blub::enableSharedFromThis< base< configType > >
typedef
std::enable_shared_from_this
< base< configType > > 
t_base
 
typedef blub::sharedPointer
< base< configType >const > 
t_thisPtrConst
 
typedef blub::sharedPointer
< base< configType > > 
t_thisPtr
 

Public Member Functions

virtual ~base ()
 destructor
 
void calculateVoxel (const transform &trans) const
 calculates voxel in the container u have to set by setVoxelContainer() before. If setVoxelContainer() didn't get called before, method will assert. More...
 
virtual void calculateVoxel (t_voxelContainerTile *voxelContainer, const vector3int32 &voxelContainerOffset, const transform &trans) const
 calculates all voxel in getAxisAlignedBoundingBox() and inserts them into voxelContainer. Method gets called once per tile from various threads. Voxel only will get set if the interpolation is higher than the inerpoaltion before calculation. More...
 
void setCut (const bool &cut)
 Enable or disable cut. Don't change the value while active calculation. More...
 
const bool & getCut () const
 Returns if cutting is enabled. More...
 
void setVoxelContainer (t_voxelContainerSimple *toSet)
 Sets the voxelcontainer used by calculateVoxel(). More...
 
t_voxelContainerSimple * getVoxelContainer () const
 
virtual blub::axisAlignedBox getAxisAlignedBoundingBox (const transform &trans) const =0
 getAxisAlignedBoundingBox returns the transformed blub::axisAlignedBox in which the voxel have to get recalculated. More...
 
- Public Member Functions inherited from blub::enableSharedFromThis< base< configType > >
t_thisPtrConst getSharedThisPtr () const
 
t_thisPtr getSharedThisPtr ()
 

Protected Types

enum  axis { x, y, z }
 The axis enum is used by createLine() for describing the direction.
 

Protected Member Functions

virtual bool calculateOneVoxel (const vector3 &pos, t_voxel *resultVoxel) const
 Implement this method for your own edit. More...
 
virtual void createLine (t_voxelContainerTile *voxelContainer, const vector3int32 &posVoxel, const real &from, const real &len, const axis &ax, const blub::plane &planeA, const blub::plane &planeB) const
 createLine creates a voxel-line on one axis with a specific length More...
 

Protected Attributes

t_voxelContainerSimple * m_voxelContainer
 
bool m_cut
 

Detailed Description

template<class configType>
class blub::procedural::voxel::edit::base< configType >

base class of all edits. Has various features you may wanna overwrite. If you want to write your own edit overwrite the method calculateOneVoxel() or calculateVoxel(). For most flexibility override calculateVoxel(). Because base derives enableSharedFromThis you have to write a create method that creates a shared_ptr of the class.

Examples:
mesh.cpp.

Member Function Documentation

template<class configType>
virtual bool blub::procedural::voxel::edit::base< configType >::calculateOneVoxel ( const vector3 pos,
t_voxel resultVoxel 
) const
inlineprotectedvirtual

Implement this method for your own edit.

Parameters
posdescribes the voxel-position
resultVoxelif a value could get calculated, set it to resultVoxel.
Returns
true if it was possible to calculate a value.

Reimplemented in blub::procedural::voxel::edit::noise< configType >, blub::procedural::voxel::edit::axisAlignedBox< configType >, and blub::procedural::voxel::edit::sphere< configType >.

template<class configType>
void blub::procedural::voxel::edit::base< configType >::calculateVoxel ( const transform trans) const
inline

calculates voxel in the container u have to set by setVoxelContainer() before. If setVoxelContainer() didn't get called before, method will assert.

Parameters
transThe transform used on every voxel position before calling calculateOneVoxel().
template<class configType>
virtual void blub::procedural::voxel::edit::base< configType >::calculateVoxel ( t_voxelContainerTile *  voxelContainer,
const vector3int32 voxelContainerOffset,
const transform trans 
) const
inlinevirtual

calculates all voxel in getAxisAlignedBoundingBox() and inserts them into voxelContainer. Method gets called once per tile from various threads. Voxel only will get set if the interpolation is higher than the inerpoaltion before calculation.

Parameters
voxelContainerThe container where the voxel have to get set in.
voxelContainerOffsetThe absolut offset of the container
transThe transform of the edit.

Reimplemented in blub::procedural::voxel::edit::box< voxelType >.

template<class configType>
virtual void blub::procedural::voxel::edit::base< configType >::createLine ( t_voxelContainerTile *  voxelContainer,
const vector3int32 posVoxel,
const real &  from,
const real &  len,
const axis ax,
const blub::plane planeA,
const blub::plane planeB 
) const
inlineprotectedvirtual

createLine creates a voxel-line on one axis with a specific length

Parameters
voxelContainerWhere to create the line in. Must not be nullptr
posVoxelThe relative voxel position in 2d. The value definied by ax will be ignored.
fromStart value from where to start the line. Not a an integer because of interpolation.
lenlength value added to start of the line. Not a an integer because of interpolation. Must be larger/equal zero
axThe axis on which the line should get generated
planeAfirst cutPlane. See blub::procedural::voxel::edit::box for usage. Used for interpolation.
planeBsecond cutPlane. See blub::procedural::voxel::edit::box for usage. Used for interpolation.
template<class configType>
virtual blub::axisAlignedBox blub::procedural::voxel::edit::base< configType >::getAxisAlignedBoundingBox ( const transform trans) const
pure virtual
template<class configType>
const bool& blub::procedural::voxel::edit::base< configType >::getCut ( ) const
inline

Returns if cutting is enabled.

Returns
Returns the setted value by setCut() or default false.
template<class configType>
t_voxelContainerSimple* blub::procedural::voxel::edit::base< configType >::getVoxelContainer ( ) const
inline
Returns
Returns voxelContainer set by setVoxelContainer()
template<class configType>
void blub::procedural::voxel::edit::base< configType >::setCut ( const bool &  cut)
inline

Enable or disable cut. Don't change the value while active calculation.

Parameters
cutIf true voxel will get removed instead in added.
template<class configType>
void blub::procedural::voxel::edit::base< configType >::setVoxelContainer ( t_voxelContainerSimple *  toSet)
inline

Sets the voxelcontainer used by calculateVoxel().

Parameters
toSetMust not be nullptr.

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