VoxelBlur
Depth-of-field volume rendering
 All Classes Files Functions Variables Enumerations Enumerator
Public Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
Cube Class Referencefinal

Describes a equilateral cube, centered on the origin. More...

#include <geometry.h>

Public Types

enum  Corner {
  MinMinMin = 0, MaxMinMin, MinMaxMin, MaxMaxMin,
  MinMinMax, MaxMinMax, MinMaxMax, MaxMaxMax,
  COUNT
}
 Defines the 8 corner points of the cube, in XYZ format. More...
 

Public Member Functions

 Cube (float sideLength=1.0f)
 Creates a cube with the specified side length. More...
 
const QVector3D *const getVertices () const
 Returns the 8 vertices of the cube. More...
 
QVector< QVector4D > transform (const QMatrix4x4 &mat) const
 Multiplies the vertices with the given matrix and returns the result. More...
 
QVector< QVector4D > transform (const QMatrix4x4 &mat, QVector4D &minPos, QVector4D &maxPos) const
 Multiplies the vertices with the given matrix and returns the result. More...
 
QVector< QVector3D > transform3D (const QMatrix4x4 &mat, QVector3D &minPos, QVector3D &maxPos) const
 Same as transform, but with the w components omitted.
 

Static Public Attributes

static const ushort triangleIndices [36]
 6 * 2 * 3 = 36 indices for a triangle representation of the cube, vertices ordered CCW. More...
 
static const ushort triangleCount = 12
 Number of triangles in triangleIndices (=12)
 
static const ushort quadIndices [24]
 6 * 4 = 24 indices for a quad representation of the cube (faces), vertices ordered CCW. More...
 
static const ushort quadCount = 6
 Number of quads in quadIndices (=6)
 
static const ushort lineIndices [24]
 12 * 2 = 24 indices for a line representation of the cube (edges) More...
 
static const ushort lineCount =12
 Number of lines in lineIndices (=12)
 

Private Attributes

float m_sidelength
 The side length of the cube.
 
QVector3D * m_vertices
 The 8 vertices of the cube, in the order defined by Corner.
 

Detailed Description

Describes a equilateral cube, centered on the origin.

Note that this is not a QObject. The constructor takes the side length of the cube

Member Enumeration Documentation

Defines the 8 corner points of the cube, in XYZ format.

The vertices returned by this class are in exactly the order as specified in this array.

Constructor & Destructor Documentation

Cube::Cube ( float  sideLength = 1.0f)
explicit

Creates a cube with the specified side length.

The default side length is 1.0. The resulting vertices have coordinates equivalent to \( \pm \frac{sideLength}{2} \) on each axis.

Parameters
sideLengthThe side length of the cube.

Member Function Documentation

const QVector3D *const Cube::getVertices ( ) const

Returns the 8 vertices of the cube.

This array must not be modified.

Returns
an 8-element array that contains the vertices of this cube.

Here is the caller graph for this function:

QVector< QVector4D > Cube::transform ( const QMatrix4x4 &  mat) const

Multiplies the vertices with the given matrix and returns the result.

The returned values can be freely used.

The vectors with indices 0-7 are the transformed vertices corresponding to the original vertices with indices 0-7.

Parameters
matThe matrix to multiply with
Returns
a QVector of size 8, can be used as required.

Here is the caller graph for this function:

QVector< QVector4D > Cube::transform ( const QMatrix4x4 &  mat,
QVector4D &  minPos,
QVector4D &  maxPos 
) const

Multiplies the vertices with the given matrix and returns the result.

The returned values can be freely used.

The vectors with indices 0-7 are the transformed vertices corresponding to the original vertices with indices 0-7. The other parameters contain the minmal and maximal values on each axis.

Parameters
matThe matrix to multiply with
minPoscontains the minimal value of the transformed points in each axis
maxPoscontains the maximal value of the transformed points in each axis
Returns
a QVector of size 8, can be used as required.

Member Data Documentation

const ushort Cube::lineIndices
static
Initial value:
=
{
0,1,1,3,3,2,2,0,
0,4,2,6,1,5,3,7,
4,5,5,7,7,6,6,4,
}

12 * 2 = 24 indices for a line representation of the cube (edges)

const ushort Cube::quadIndices
static
Initial value:
=
{
0,1,3,2,
1,5,7,3,
5,4,6,7,
4,0,2,6,
0,4,5,1,
2,3,7,6
}

6 * 4 = 24 indices for a quad representation of the cube (faces), vertices ordered CCW.

const ushort Cube::triangleIndices
static
Initial value:
=
{
0,3,1, 0,2,3,
7,5,1, 7,1,3,
4,5,6, 5,7,6,
2,0,4, 2,4,6,
4,1,5, 4,0,1,
2,7,3, 2,6,7
}

6 * 2 * 3 = 36 indices for a triangle representation of the cube, vertices ordered CCW.


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