DunGen  1.1
Dungeongenerator library for Irrlicht
Public Member Functions | List of all members
DunGen::CDunGen Class Reference

Interfaceclass for the DunGen-DungeonGenerator. More...

#include <DunGen.h>

Public Member Functions

 CDunGen (irr::IrrlichtDevice *irrDevice)
 
 ~CDunGen ()
 Destructor. More...
 
void StartUp ()
 Start up the Dungeongenerator. More...
 
void ShutDown ()
 Shut down the Dungeongenerator. Deletes all unnecessary objects. More...
 
void ClearRoomsAndCorridors ()
 
unsigned int CreateLSystemDerivation (unsigned int desiredIteration)
 
void CreateVoxelCave ()
 Creates the voxel cave from the currently generated L-system iteration. More...
 
void ErodeVoxelCave (double erosionLikelihood)
 
void RemoveHoveringVoxelFragments ()
 Removes all hovering fragments. More...
 
void CreateMeshCave ()
 Creates the mesh cave from the currently generated voxel cave. More...
 
bool CreateRoom (unsigned int roompatternIndex, const irr::core::vector3d< double > &position, const irr::core::vector3d< double > &rotation, const irr::core::vector3d< double > &scaleFactor)
 
bool CreateCorridorRoomRoom (unsigned int room0, unsigned int dockingSite0, double distance0, double strenght0, unsigned int room1, unsigned int dockingSite1, double distance1, double strenght1, bool &sightBlocking)
 
bool CreateCorridorRoomCave (unsigned int room0, unsigned int dockingSite0, double distance0, double strenght0, const irr::core::vector3d< unsigned int > &minVox1, const irr::core::vector3d< unsigned int > &maxVox1, EDirection::Enum direction1, double distance1, double strenght1, bool &sightBlocking)
 
bool CreateCorridorCaveCave (const irr::core::vector3d< unsigned int > &minVox0, const irr::core::vector3d< unsigned int > &maxVox0, EDirection::Enum direction0, double distance0, double strenght0, const irr::core::vector3d< unsigned int > &minVox1, const irr::core::vector3d< unsigned int > &maxVox1, EDirection::Enum direction1, double distance1, double strenght1, bool &sightBlocking)
 
bool ReadDungeonFromFile (const irr::io::path &filename)
 
void AddDungeon (irr::scene::ISceneNode *parentNode, irr::scene::ISceneManager *sceneManager)
 
void RandomGeneratorSetParameters (unsigned int seed, unsigned int a, unsigned int c, unsigned int m)
 
void LSystemAddRule (char symbol, const std::string &substitution)
 
void LSystemDeleteRules ()
 Deletes all substitution rules for the L-system. More...
 
void LSystemSetStart (const std::string &start)
 
void LSystemSetParameter (ELSystemParameter::Enum parameter, double value)
 
void VoxelCaveSetParameters (unsigned int border, unsigned int mindrawradius)
 
unsigned int VoxelCaveEstimateMeshComplexity () const
 
void MeshCaveSetWarpParameters (bool warpEnabled, bool smoothEnabled, unsigned int warpRandomSeed, double warpStrength)
 
void MeshCaveSetNormalWeightMethod (ENormalWeightMethod::Enum value)
 
void CorridorSetDistances (double distance, double textureDistance)
 
void CorrdidorAddPoint (double x, double y, double textureX)
 
void CorrdidorRemovePoints ()
 Removes all points from the corridor profile. More...
 
void CorrdidorAddDetailObject (const SDetailobjectParameters &parameters)
 
void CorrdidorRemoveDetailobjects ()
 Removes all detail object templates. More...
 
void RoomPatternLoad (const irr::io::path filename)
 
void MaterialSetCorridor (const irr::io::path &textureFilename, bool backFaceCulling, bool antiAliasing)
 
void MaterialSetCaveSingleColor (const irr::video::SColorf &color, bool backFaceCulling, bool antiAliasing)
 
void MaterialSetCaveMultiColor (bool backFaceCulling, bool antiAliasing)
 
void SetPrintToConsole (bool value)
 

Detailed Description

Interfaceclass for the DunGen-DungeonGenerator.

Constructor & Destructor Documentation

DunGen::CDunGen::CDunGen ( irr::IrrlichtDevice *  irrDevice)

Constructor.

Parameters
irrDeviceThe Irrlicht device.
DunGen::CDunGen::~CDunGen ( )

Destructor.

Member Function Documentation

void DunGen::CDunGen::StartUp ( )

Start up the Dungeongenerator.

void DunGen::CDunGen::ShutDown ( )

Shut down the Dungeongenerator. Deletes all unnecessary objects.

void DunGen::CDunGen::ClearRoomsAndCorridors ( )

Deletes all rooms, room patterns and corridors.

This is necessary, if a new dungeon shall be created without shutdown / startup usage. The voxel cave and the mesh cave need no explicit reset. They are cleared automatically when drawing a new cave.

unsigned int DunGen::CDunGen::CreateLSystemDerivation ( unsigned int  desiredIteration)

Create a derivation of the L-system.

Parameters
desiredIterationThe desired iteration. The derivation will eventually be lower if the length of the generated string would exceed 1,000,000 instructions.
Returns
The generated iteration.
void DunGen::CDunGen::CreateVoxelCave ( )

Creates the voxel cave from the currently generated L-system iteration.

void DunGen::CDunGen::ErodeVoxelCave ( double  erosionLikelihood)

Erodes the voxel cave 1 voxel deep. Can be applied muliple times.

Parameters
erosionLikelihoodThe likelihood, with which the voxels are removed.
void DunGen::CDunGen::RemoveHoveringVoxelFragments ( )

Removes all hovering fragments.

void DunGen::CDunGen::CreateMeshCave ( )

Creates the mesh cave from the currently generated voxel cave.

bool DunGen::CDunGen::CreateRoom ( unsigned int  roompatternIndex,
const irr::core::vector3d< double > &  position,
const irr::core::vector3d< double > &  rotation,
const irr::core::vector3d< double > &  scaleFactor 
)

Creates a room from a room pattern.

Parameters
roompatternIndexThe index of the room pattern. Refers to the rooms that have been added with DunGen::RoomPatternLoad, starts with 0.
positionThe position of the room.
rotationThe rotation of the room.
scaleFactorThe scale factor of the room.
Returns
Returns true, if this was successful, false otherwise.
bool DunGen::CDunGen::CreateCorridorRoomRoom ( unsigned int  room0,
unsigned int  dockingSite0,
double  distance0,
double  strenght0,
unsigned int  room1,
unsigned int  dockingSite1,
double  distance1,
double  strenght1,
bool &  sightBlocking 
)

Creates a corridor between two rooms.

Parameters
room0The index of room 0 which shall be connected. Refers the the rooms, that have been created with DunGen::roompatternIndex, starts with 0.
dockingSite0The docking site of room 0, which shall be used for connecting the corridor.
distance0The distance in which the corridor shall start from docking site 0. The space between the room and the corridor is used by an adapter.
strenght0The strength, with which the corridor direction is influenced by the docking site 0 direction.
room1The index of room 1 which shall be connected. Refers the the rooms, that have been created with DunGen::roompatternIndex, starts with 0.
dockingSite1The docking site of room 1, which shall be used for connecting the corridor.
distance1The distance in which the corridor shall start from docking site 1. The space between the room and the corridor is used by an adapter.
strenght1The strength, with which the corridor direction is influenced by the docking site 1 direction.
sightBlockingIs the corridor definitely sight blocking (can you see from one end the the other)?
Returns
Returns true, if this was successful, false otherwise.
bool DunGen::CDunGen::CreateCorridorRoomCave ( unsigned int  room0,
unsigned int  dockingSite0,
double  distance0,
double  strenght0,
const irr::core::vector3d< unsigned int > &  minVox1,
const irr::core::vector3d< unsigned int > &  maxVox1,
EDirection::Enum  direction1,
double  distance1,
double  strenght1,
bool &  sightBlocking 
)

Creates a room corridor between a room and the cave. A docking site for the cave is created automatically with direction -direction1.

Parameters
room0The index of room 0 which shall be connected. Refers the the rooms, that have been created with DunGen::roompatternIndex, starts with 0.
dockingSite0The docking site of room 0, which shall be used for connecting the corridor.
distance0The distance in which the corridor shall start from room 0. The space between the room and the corridor is used by an adapter.
strenght0The strength , with which the corridor direction is influenced by the docking site 0 direction.
minVox1The start voxels, where the cave search begins. Assume you have X-direction, Y and Z define the width of the docking site and have to be the same as for maxVox1. The difference of minVox1.X and maxVox1.X is carved into the cave.
maxVox1The end voxels for cave docking. Assume you have X-direction, Y and Z define the width of the docking site and have to be the same as for minVox1. The difference of minVox1.X and maxVox1.X is carved into the cave.
direction1The direction in which the corridor is connected.
distance1The distance in which the corridor shall start from docking site 1. The space between the room and the corridor is used by an adapter.
strenght1The strength , with which the corridor direction is influenced by the docking site 1 direction.
sightBlockingIs the corridor definitely sight blocking (can you see from one end the the other)?
Returns
Returns true, if this was successful, false otherwise.
bool DunGen::CDunGen::CreateCorridorCaveCave ( const irr::core::vector3d< unsigned int > &  minVox0,
const irr::core::vector3d< unsigned int > &  maxVox0,
EDirection::Enum  direction0,
double  distance0,
double  strenght0,
const irr::core::vector3d< unsigned int > &  minVox1,
const irr::core::vector3d< unsigned int > &  maxVox1,
EDirection::Enum  direction1,
double  distance1,
double  strenght1,
bool &  sightBlocking 
)

Creates a room corridor between two cave positions. A docking site for each cave position is created automatically with directions -direction0 and -direction1.

Parameters
minVox0The start voxels, where the cave search begins. Assume you have X-direction, Y and Z define the width of the docking site and have to be the same as for maxVox0. The difference of minVox0.X and maxVox0.X is carved into the cave.
maxVox0The end voxels for cave docking. Assume you have X-direction, Y and Z define the width of the docking site and have to be the same as for minVox0. The difference of minVox0.X and maxVox0.X is carved into the cave.
direction0The direction in which the corridor is connected.
distance0The distance in which the corridor shall start from docking site 0. The space between the room and the corridor is used by an adapter.
strenght0The strength, with which the corridor direction is influenced by the docking site 0 direction.
minVox1The start voxels, where the cave search begins. Assume you have X-direction, Y and Z define the width of the docking site and have to be the same as for maxVox1. The difference of minVox1.X and maxVox1.X is carved into the cave.
maxVox1The end voxels for cave docking. Assume you have X-direction, Y and Z define the width of the docking site and have to be the same as for minVox1. The difference of minVox1.X and maxVox1.X is carved into the cave.
direction1The direction in which the corridor is connected.
distance1The distance in which the corridor shall start from docking site 1. The space between the room and the corridor is used by an adapter.
strenght1The strength , with which the corridor direction is influenced by the docking site 1 direction.
sightBlockingIs the corridor definitely sight blocking (can you see from one end the the other)?
Returns
Returns true, if this was successful, false otherwise.
bool DunGen::CDunGen::ReadDungeonFromFile ( const irr::io::path &  filename)

Reads the dungeon from a file. The dungeon creation steps will be done accordingly to the XML description in this file.

Parameters
filenameThe filename of the file.
Returns
Returns true, if the file exists and can be processed, false otherwise.
void DunGen::CDunGen::AddDungeon ( irr::scene::ISceneNode *  parentNode,
irr::scene::ISceneManager *  sceneManager 
)

Assembles the dungeon and adds it under the specified node in the specified scene manager.

Parameters
parentNodeThe parent node for the dungeon.
sceneManagerThe scene manager parentNode belongs to.
void DunGen::CDunGen::RandomGeneratorSetParameters ( unsigned int  seed,
unsigned int  a,
unsigned int  c,
unsigned int  m 
)

Set the parameters for the random generator: linear congruential generator, X[i+1] = (a*X[i]+c) mod m).

Parameters
seedThe random seed.
aThe parameter a.
cThe parameter c.
mThe parameter m.
void DunGen::CDunGen::LSystemAddRule ( char  symbol,
const std::string &  substitution 
)

Adds a substitution rule for the L-system.

Parameters
symbolThe symbol, which shall be replaced.
substitutionThe substitution for the symbol.
void DunGen::CDunGen::LSystemDeleteRules ( )

Deletes all substitution rules for the L-system.

void DunGen::CDunGen::LSystemSetStart ( const std::string &  start)

Sets the start symbols for the L-system

Parameters
startThe start symbols.
void DunGen::CDunGen::LSystemSetParameter ( ELSystemParameter::Enum  parameter,
double  value 
)

Sets a parameter for the L-system.

Parameters
parameterThe parameter.
valueThe value to be set.
void DunGen::CDunGen::VoxelCaveSetParameters ( unsigned int  border,
unsigned int  mindrawradius 
)

Sets the parameters of the voxel cave.

Parameters
borderThe border of 0-voxels, which will be preserved. Will be capped to at least SVoxelSpace::MinBorder
mindrawradiusThe minimum drawing radius, which will be not deceeded.
unsigned int DunGen::CDunGen::VoxelCaveEstimateMeshComplexity ( ) const

Estimates the mesh complexity for the mesh cave which results from the current voxel cave.

Returns
The estimated number of triangles needed.
void DunGen::CDunGen::MeshCaveSetWarpParameters ( bool  warpEnabled,
bool  smoothEnabled,
unsigned int  warpRandomSeed,
double  warpStrength 
)

Sets the warp parameters for the mesh cave.

Parameters
warpEnabledShall the voxels be warped, when creating the mesh cave?
smoothEnabledShall the warping smooth the mesh?
warpRandomSeedRandom seed for the warping.
warpStrengthStrength of the warping. Will be clamped to [0,0.49].
void DunGen::CDunGen::MeshCaveSetNormalWeightMethod ( ENormalWeightMethod::Enum  value)

Sets the normal weighting method for the mesh cave.

Parameters
valueThe normal weighting method.
void DunGen::CDunGen::CorridorSetDistances ( double  distance,
double  textureDistance 
)

Sets the distances for the corridor.

Parameters
distanceThe sampling factor for computing the underlying hermite spline. Lower values will result in more triangles, but a smoother mesh.
textureDistanceThe Y texture coordinate increase per sampling point
void DunGen::CDunGen::CorrdidorAddPoint ( double  x,
double  y,
double  textureX 
)

Adds a point for the corridor profile. The profile has to have at least 3 points and enclose (0,0), which is the center.

Parameters
xX coordinate.
yY coordinate.
textureXX texture coordinate.
void DunGen::CDunGen::CorrdidorRemovePoints ( )

Removes all points from the corridor profile.

void DunGen::CDunGen::CorrdidorAddDetailObject ( const SDetailobjectParameters parameters)

Adds a detail object template, which shall be placed along the corridor.

Parameters
parametersThe parameters of the detail object.
void DunGen::CDunGen::CorrdidorRemoveDetailobjects ( )

Removes all detail object templates.

void DunGen::CDunGen::RoomPatternLoad ( const irr::io::path  filename)

Loads a room pattern, which has to be a .irr file. See mainpage of documentation of requirements for room patterns.

Parameters
filenameThe filename of the room pattern.
void DunGen::CDunGen::MaterialSetCorridor ( const irr::io::path &  textureFilename,
bool  backFaceCulling,
bool  antiAliasing 
)

Sets material parameters for the corridor.

Parameters
textureFilenameThe filename of the texture that shall be used.
backFaceCullingShall backface culling be enabled?
antiAliasingShall anti aliasing culling be enabled?
void DunGen::CDunGen::MaterialSetCaveSingleColor ( const irr::video::SColorf &  color,
bool  backFaceCulling,
bool  antiAliasing 
)

Chooses the single color material for the mesh cave and sets the parameters for it.

Parameters
colorThe color of the cave.
backFaceCullingShall backface culling be enabled?
antiAliasingShall anti aliasing culling be enabled?
void DunGen::CDunGen::MaterialSetCaveMultiColor ( bool  backFaceCulling,
bool  antiAliasing 
)

Chooses the multi color material for the mesh cave and sets the parameters for it.

Parameters
backFaceCullingShall backface culling be enabled?
antiAliasingShall anti aliasing culling be enabled?
void DunGen::CDunGen::SetPrintToConsole ( bool  value)

Sets if status reports shall be printed to the console.

Parameters
valueIf true, status reports will be printed to the console.