Workspace 6.21.5
|
Creates a mesh for a superquadric. More...
#include <Rendering/SceneComponents/Models/superquadricmesher.h>
Public Types | |
enum | TextureCoords { NoTextureCoords , Natural , Spherical } |
Public Member Functions | |
SuperquadricMesher (const QString &sStateName="textureS", const QString &tStateName="textureT") | |
~SuperquadricMesher () | |
void | meshSuperquadric (double e, double n, int subdivisions, const Mesh::Vector3d &radius, TextureCoords textureCoordType, Mesh::MeshModel &model) |
Create a mesh of a supequadric satisyfing the implicit equation
[(x/r.x)^(2/e) + (y/r.y)^(2/e)]^(e/n) + (z/r.z)^(2/n) = 1
where (r.x,r.y,r.z) is the radius of the superquadric and the values 0 < e and 0 < n are the east-west and north-south shape parameters respectively. This range of shape parameters describes star-like shapes (for e,n > 1), a sphere (for e = n = 1) and convex shapes (for e,n < 1) such as those used in DEM simulations.
The algorithm is such that the vertices of the resultant mesh are automatically concentrated near regions of high curvature.
enum TextureCoords |
Specifies the method to use for assigning texture co-ordinates to the superquadric mesh nodes.
SuperquadricMesher | ( | const QString & | sStateName = "textureS" , |
const QString & | tStateName = "textureT" |
||
) |
sStateName | The name of the node state for the s texture co-ordinate. |
tStateName | The name of the node state for the t texture co-ordinate. |
~SuperquadricMesher | ( | ) |
void meshSuperquadric | ( | double | e, |
double | n, | ||
int | subdivisions, | ||
const Mesh::Vector3d & | radius, | ||
TextureCoords | textureCoordType, | ||
Mesh::MeshModel & | model | ||
) |
e | The superquadric power parameter related to the co-ordinate around the equator (which we refer to as theta in some parts of this documentation). |
n | The superquadric power parameter related to the vertical co-ordinate (which we refer to as phi in some parts of this documentation). |
subdivisions | The number of rows/columns of elements in one quadrant, which is the same meaning as used for the sphere glypher. |
radius | The scaling in each of the three axis directions. |
textureCoordType | This specifies how the texture co-ordinates are to be computed. Using a value of Spherical will result in more evenly spaced texture co-ordinates at the expense of slight distortion of horizontal and vertical lines that originally appeared parallel in the texture image. On the other hand, if this parameter is Natural, then the texture co-ordinates will be the same as the theta/phi co-ordinates used to generate the superquadric. This will preserve parallel horizontal and vertical lines, but the texture image will still suffer distortion. Texture co-ordinates will be more closely spaced in regions of higher curvature using Natural. |
model | This will hold the superquadric model upon exit. Any previous contents will be discarded and all existing node and element states will be removed. Upon exit, node states for the texture co-ordinates will have been set. The names of these node states are set in the constructor. |
Superquadric formulae used:
x(theta,phi) = radius.x (cos phi)^n (cos theta)^e y(theta,phi) = radius.y (cos phi)^n (sin theta)^e z(theta,phi) = radius.z (sin phi)^n
where the powers are understood as a^p = sign(a) |a|^p and the parameters have the following ranges:
0 <= theta <= 2*pi
-pi/2 <= phi <= pi/2
For reference, the POVray documentation specifies the full superquadric formula as a superellipsoid and at time of writing this can be found at: