voxel_4_c Class Reference

voxel space class for tetra-octa grid. More...

#include <voxel_4.h>

Inheritance diagram for voxel_4_c:

Inheritance graph
[legend]
Collaboration diagram for voxel_4_c:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 voxel_4_c (unsigned int x, unsigned int y, unsigned int z, const gridType_c *gt, voxel_type init=0)
 voxel_4_c (xmlParser_c &pars, const gridType_c *gt)
 voxel_4_c (const voxel_c &orig)
 voxel_4_c (const voxel_c *orig)
virtual bool transform (unsigned int nr)
 special transformation function for this grid.
bool getNeighbor (unsigned int idx, unsigned int typ, int x, int y, int z, int *xn, int *yn, int *zn) const
 returns the coordinates for a neighbour to the given voxel
void scale (unsigned int amount, bool grid)
 scale up.
bool scaleDown (unsigned char by, bool action)
 Scale down voxel space.
void resizeInclude (int &px, int &py, int &pz)
 resize space to include a certain coordinate.
void minimizePiece (void)
 changes the size of the voxel space to the smallest size so that all voxels whose value is not 0 can be contained.
virtual bool validCoordinate (int x, int y, int z) const
 Return if a given coordinate is valid to use.
bool identicalInBB (const voxel_c *op, bool includeColors=true) const
 Comparison of two voxel spaces.
bool onGrid (int x, int y, int z) const
 this function is used to find out if the given position is of the same voxel type as the voxel at position 0.
virtual bool meshParamsValid (double bevel, double offset) const
void getConnectionFace (int x, int y, int z, int n, double bevel, double offset, std::vector< float > &faceCorners) const
 this function must return a polygon that is the connecting face to the neighbor n for the voxel at position x, y, z The function is used by the default implementation of getMesh to generate the default basis mesh it is also used by the 3D cursor drawing code
void calculateSize (float *x, float *y, float *z) const
 calculate the size, that the returned mesh has
void recalcSpaceCoordinates (float *x, float *y, float *z) const

Private Member Functions

void operator= (const voxel_4_c &)


Detailed Description

voxel space class for tetra-octa grid.

This builds on top of the brick grid as this grid is implemented using the normal bricks. So this class can use many of the brick functions it just has to ensure certain alignments.

The emulation is working like this: Imagine a tetrahedron enscribed into a cube so that 2 corners of the tetrahedron are in the opposite 2 top corners of the cube and the other 2 corners of the tetrahedron are in the other bottom 2 corners. This leaves 4 little irregular tetrahedrons to complete the cube. 4 of those smaller tetrahedron can be assembled into an octahedron.

There are 2 possible orientations for this cube. The complete space is filled with a checkerboard pattern of those 2 cubes.

Each of these cubes is represented as one 3x3x3 cube in the normal cube grid. The regular tetrahedron is the center cube and the 4 irregular tetrahedrons are represented by voxels in the corresponding corners of the 3x3x3 cube

To better unserstand this grid, it is best best is to play a bit with it in the GUI.


Constructor & Destructor Documentation

voxel_4_c::voxel_4_c ( unsigned int  x,
unsigned int  y,
unsigned int  z,
const gridType_c gt,
voxel_type  init = 0 
) [inline]

voxel_4_c::voxel_4_c ( xmlParser_c pars,
const gridType_c gt 
) [inline]

voxel_4_c::voxel_4_c ( const voxel_c orig  )  [inline]

voxel_4_c::voxel_4_c ( const voxel_c orig  )  [inline]


Member Function Documentation

void voxel_4_c::calculateSize ( float *  x,
float *  y,
float *  z 
) const [virtual]

calculate the size, that the returned mesh has

Reimplemented from voxel_0_c.

References voxel_c::getX(), voxel_c::getY(), and voxel_c::getZ().

void voxel_4_c::getConnectionFace ( int  ,
int  ,
int  ,
int  ,
double  ,
double  ,
std::vector< float > &   
) const [virtual]

this function must return a polygon that is the connecting face to the neighbor n for the voxel at position x, y, z The function is used by the default implementation of getMesh to generate the default basis mesh it is also used by the 3D cursor drawing code

Reimplemented from voxel_0_c.

References bt_assert, intdiv_inf(), and voxel_c::voxels.

bool voxel_4_c::getNeighbor ( unsigned int  idx,
unsigned int  typ,
int  x,
int  y,
int  z,
int *  xn,
int *  yn,
int *  zn 
) const [virtual]

returns the coordinates for a neighbour to the given voxel

idx is the index if the neighbour, if you want the next neighbour, give the next number typ is what kind of neighbour you want, face (0), edge (1) or corner (2) x, y, z coordinate for the source xn, yn, zn, coordinate for the neighbour return true, when a valid neighbour with that index exists

This function is different for different grids. There is no default implementation, so each grid has to define its own version of this function

Reimplemented from voxel_0_c.

References intdiv_inf().

bool voxel_4_c::identicalInBB ( const voxel_c op,
bool  includeColors = true 
) const [virtual]

Comparison of two voxel spaces.

2 voxel spaces are identical, if their bounding boxes have the same size and the voxels within there boxes is identical

if includeColors is true, the colours are included in the comparison, meaning when the colours differ the shapes are not equal, otherwise only the states are compared

There are special conditions to take care in different grid (e.g alignment along a bigger grid) so this function can be overloaded. The default implementation simply treats all voxels equal

Reimplemented from voxel_c.

References voxel_c::boundX1(), voxel_c::boundY1(), voxel_c::boundZ1(), voxel_c::bx1, voxel_c::by1, and voxel_c::bz1.

bool voxel_4_c::meshParamsValid ( double  bevel,
double  offset 
) const [virtual]

Reimplemented from voxel_0_c.

void voxel_4_c::minimizePiece ( void   )  [virtual]

changes the size of the voxel space to the smallest size so that all voxels whose value is not 0 can be contained.

as in some grids there are special conditions to consider when doing this operation the function can be overloaded. This default implementation will minimize to the bounding box.

Reimplemented from voxel_c.

References voxel_c::bx1, voxel_c::by1, voxel_c::bz1, voxel_c::resize(), voxel_c::sx, voxel_c::sy, voxel_c::sz, and voxel_c::translate().

bool voxel_4_c::onGrid ( int  x,
int  y,
int  z 
) const [virtual]

this function is used to find out if the given position is of the same voxel type as the voxel at position 0.

This is used to find out if a piece can be placed at a certain position in a voxel grid

Reimplemented from voxel_0_c.

void voxel_4_c::operator= ( const voxel_4_c  )  [private]

void voxel_4_c::recalcSpaceCoordinates ( float *  x,
float *  y,
float *  z 
) const [virtual]

Reimplemented from voxel_c.

void voxel_4_c::resizeInclude ( int &  px,
int &  py,
int &  pz 
) [virtual]

resize space to include a certain coordinate.

maybe changing the coordinate itself in the process. make sure that we add a multiple of 6, when we add at the base that's all there is to it

Reimplemented from voxel_0_c.

References voxel_c::getX(), voxel_c::getY(), voxel_c::getZ(), voxel_c::resize(), and voxel_c::translate().

void voxel_4_c::scale ( unsigned int  amount,
bool  grid 
) [virtual]

scale up.

The idea is to use cutting planes that cut the cube into its parts the first thing is to find out on which side of each plane a voxel is and then use the same planes scaled up for the upscaled space.

Reimplemented from voxel_0_c.

References voxel_c::get2(), voxel_c::hx, voxel_c::hy, voxel_c::hz, voxel_c::recalcBoundingBox(), voxel_c::space, voxel_c::sx, voxel_c::sy, voxel_c::sz, voxel_c::voxels, and voxel_c::VX_EMPTY.

bool voxel_4_c::scaleDown ( unsigned char  by,
bool  action 
) [virtual]

Scale down voxel space.

Not implemented

Reimplemented from voxel_0_c.

bool voxel_4_c::transform ( unsigned int  nr  )  [virtual]

special transformation function for this grid.

All the function has to do is to make sure that the grid is a multiple size of 6 and then it can use the brick transformation function

Reimplemented from voxel_0_c.

References voxel_c::getX(), voxel_c::getY(), voxel_c::getZ(), voxel_c::resize(), voxel_c::sx, voxel_c::sy, and voxel_c::sz.

bool voxel_4_c::validCoordinate ( int  x,
int  y,
int  z 
) const [virtual]

Return if a given coordinate is valid to use.

In some voxel spaces not all possible coordinates are valid. For example in the sphere grid only the coordinates with (x+y+z) % 2 == 0 are valid This function does that calculation

Reimplemented from voxel_0_c.

References intdiv_inf().


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

Generated on Sun Oct 10 10:03:16 2010 for BurrTools by  doxygen 1.5.8