Here, the shapes sphere, cube and plane are described. See figure 1 shows them from left to right.
Pay attention to the rounded edges of the cube. They are due to the fact, that in this dual marching cubes implementation, the preserving of sharp features is skipped in order to gain performance.
Sphere
The volume model of the sphere is calculated like this:
With this gradient:
, and are the center of the sphere, the radius.
Cube
The cube is described with his left, lower, back corner and his right, upper, front one. This way, position and size can be described, but not the orientation. The orientation just stays the same. A CSG rotation operation could fill this gap.
For determining the density, it is first checked whether the given coordinate is within the cube. This is easily done with six comparsions to the cubes planes.
If the coordinate is within the cube, the lowest distance to the planes is calculated. For the left cube plane, this would be $x – min_x$ with $\vec{min}$ as the left, lower back corner of the cube.
In case of the coordinate being outside of the cube, the specific function of Real Ogre::AxisAlignedBox::distance (const Vector3 & v) const. This function takes care whether an edge, a corner or a plane is the next element to the coordinate.
In order to get the gradient, the same method as in the discrete grid is used, the basic version of marching cubes.
Plane
The plane is defined by the distance to the origin and a normal . The following density function is derived from the formula of Farin and Hansford by determining the distance of the coordinate to the plane [FH03, S. 180 – 181].
The gradient of the plane is its normale .