#include <voxel_0.h>
Public Member Functions | |
voxel_0_c (unsigned int x, unsigned int y, unsigned int z, const gridType_c *gt, voxel_type init=0) | |
voxel_0_c (xmlParser_c &pars, const gridType_c *gt) | |
voxel_0_c (const voxel_c &orig) | |
voxel_0_c (const voxel_c *orig) | |
void | transformPoint (int *x, int *y, int *z, unsigned int trans) const |
this function transforms the given point by the given transformation around the origin | |
bool | transform (unsigned int nr) |
the transformation function for cubic grids | |
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 | |
virtual void | scale (unsigned int amount, bool grid) |
scale the space, making x by x by x cubes out of single cubes | |
bool | scaleDown (unsigned char by, bool action) |
Scale down voxel space by a certain amount. | |
void | resizeInclude (int &px, int &py, int &pz) |
resizes and translates the space so that the the given voxel can be included the function returns the new coordinate of the point. | |
bool | validCoordinate (int x, int y, int z) const |
Return if a given coordinate is valid to use. | |
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 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 | |
virtual void | calculateSize (float *x, float *y, float *z) const |
calculate the size, that the returned mesh has | |
virtual bool | meshParamsValid (double bevel, double offset) const |
Private Member Functions | |
void | operator= (const voxel_0_c &) |
that are cubes themselfes but also grid like the rhombic grid, which use functionality of this class (mainly the transform methods)
The additional function comments contain mainly implementation details
Compared to the other 2 basic voxel grids (triangles and spheres) this grid is special as it implements many functions in a more efficient way because the cubic grid is so simple
voxel_0_c::voxel_0_c | ( | unsigned int | x, | |
unsigned int | y, | |||
unsigned int | z, | |||
const gridType_c * | gt, | |||
voxel_type | init = 0 | |||
) | [inline] |
voxel_0_c::voxel_0_c | ( | xmlParser_c & | pars, | |
const gridType_c * | gt | |||
) | [inline] |
voxel_0_c::voxel_0_c | ( | const voxel_c & | orig | ) | [inline] |
voxel_0_c::voxel_0_c | ( | const voxel_c * | orig | ) | [inline] |
void voxel_0_c::calculateSize | ( | float * | x, | |
float * | y, | |||
float * | z | |||
) | const [virtual] |
calculate the size, that the returned mesh has
Reimplemented from voxel_c.
Reimplemented in voxel_3_c, and voxel_4_c.
References voxel_c::getX(), voxel_c::getY(), and voxel_c::getZ().
void voxel_0_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_c.
bool voxel_0_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
Implements voxel_c.
bool voxel_0_c::meshParamsValid | ( | double | bevel, | |
double | offset | |||
) | const [virtual] |
bool voxel_0_c::onGrid | ( | int | x, | |
int | y, | |||
int | z | |||
) | const [virtual] |
void voxel_0_c::operator= | ( | const voxel_0_c & | ) | [private] |
void voxel_0_c::resizeInclude | ( | int & | px, | |
int & | py, | |||
int & | pz | |||
) | [virtual] |
resizes and translates the space so that the the given voxel can be included the function returns the new coordinate of the point.
Each grid has to implement it's own version because there are different kinds of supergrids that are imposed on the normal grid
Implements voxel_c.
Reimplemented in voxel_3_c, and voxel_4_c.
References voxel_c::getX(), voxel_c::getY(), voxel_c::getZ(), voxel_c::resize(), and voxel_c::translate().
void voxel_0_c::scale | ( | unsigned int | amount, | |
bool | grid | |||
) | [virtual] |
scale the space, making x by x by x cubes out of single cubes
This must be done differently by all grids. The default implementation doesn't do anything. It's just there to allow grids without scaling as not all grid have such a possibility (e.g. spheres can't be scaled) if grid is true (not all functions need to support this) the result it not filled, but rather a grid with only the outer edges filled
Reimplemented from voxel_c.
Reimplemented in voxel_3_c, and voxel_4_c.
References voxel_c::hx, voxel_c::hy, voxel_c::hz, voxel_c::isEmpty(), voxel_c::isEmpty2(), voxel_c::recalcBoundingBox(), voxel_c::space, voxel_c::sx, voxel_c::sy, voxel_c::sz, and voxel_c::voxels.
bool voxel_0_c::scaleDown | ( | unsigned char | by, | |
bool | action | |||
) | [virtual] |
Scale down voxel space by a certain amount.
for the minimize scale function applied to all shapes we need to first check, if all shapes can be scaled down by a certain factor and then do it. If action is true, then the shape is really scaled, otherwise you only get the fact if it is scalable by the given amount
This must be done differently by all grids. The default implementation doesn't do anything. It's just there to allow grids without scaling as not all grid have such a possibility (e.g. spheres can't be scaled)
Reimplemented from voxel_c.
Reimplemented in voxel_3_c, and voxel_4_c.
References voxel_c::get2(), voxel_c::recalcBoundingBox(), voxel_c::space, voxel_c::sx, voxel_c::sy, voxel_c::sz, and voxel_c::voxels.
bool voxel_0_c::transform | ( | unsigned int | nr | ) | [virtual] |
the transformation function for cubic grids
The nice thing about the cubic grid is that we can easily calculate how big the grid will be after the transformation, we can also easily calculate the new bounding box and the now position for the hotspot.
This makes this transformation function faster than the other 2 variations for spheres and triangles
Implements voxel_c.
Reimplemented in voxel_3_c, and voxel_4_c.
References bt_assert, voxel_c::bx1, voxel_c::bx2, voxel_c::by1, voxel_c::by2, voxel_c::bz1, voxel_c::bz2, voxel_c::hx, voxel_c::hy, voxel_c::hz, MAX, MIN, rotationMatrices, voxel_c::space, voxel_c::sx, voxel_c::sy, voxel_c::symmetries, symmetryInvalid, voxel_c::sz, and voxel_c::VX_EMPTY.
void voxel_0_c::transformPoint | ( | int * | x, | |
int * | y, | |||
int * | z, | |||
unsigned int | trans | |||
) | const [virtual] |
this function transforms the given point by the given transformation around the origin
Implements voxel_c.
References bt_assert, rotationMatrices, voxel_c::sx, voxel_c::sy, and voxel_c::sz.
bool voxel_0_c::validCoordinate | ( | int | x, | |
int | y, | |||
int | z | |||
) | const [virtual] |