Unofficial OpenGL Software Development Kit
0.5.0
|
These functions generate glmesh::Mesh objects. These are simple functions for making reuseable mesh objects. The meshes generated may not be optimally ordered for maximum throughput.
The meshes generated by the mesh generator functions will assume at least OpenGL 3.2 is available. As such, they will use core 3.2 functionality, such as primitive restart, glDrawElementsBaseVertex
and the like.
All generated meshes use the OpenGL default for their face orientation. Namely, counter-clockwise is front. Some meshes will have options to generate two-sided objects, if you so desire.
The attribute indices used by the mesh generator functions are standardized. They are as follows:
The main VAO of each mesh includes all attributes. There will be variants generated containing fewer attributes. The naming convention for generated mesh variants is as follows:
unlit
or flat
: Position lit
: Position+Normal tex
: Position+TexCoord color
: Position+ColorThese can be combined with -
characters (except for unlit
). So lit-tex
means positions, normals, and texture coordinates. The order doesn't matter, so lit-tex
is the same as tex-lit
.
Some generator functions allow the user to provide a glmesh::gen::ColorArray, defining a sequence of colors. These colors will be applied to the vertices or faces of the object, depending on the generator.
Functions | |
Mesh * | glmesh::gen::FullScreenQuad () |
A mesh of a full-screen quad. Useful for post-processing effects. More... | |
Mesh * | glmesh::gen::GroundPlane (int numXVerts, int numYVerts, bool bDoubleSided=true) |
A mesh ground plane. Can be double-sided and arbitrarily tessellated. More... | |
Structures | |
These generators build larger, complex structures out of smaller functional units. These shapes are useful for showing off lighting and other effects. These functions are parameterized, allowing them to produce structures of arbitrary (within reason) sizes. | |
Mesh * | glmesh::gen::CubeBlock (int numCubesOnEdge, const ColorArray &colorSequence=ColorArray()) |
Creates a cubical block of cubes in an alternating pattern. More... | |
Mesh * | glmesh::gen::CubePyramid (int numCubesTall, const ColorArray &colorSequence=ColorArray()) |
Creates a pyramid made of cubes, in an alternating pattern. More... | |
Platonic Solids | |
These functions generate meshes for the 5 Platonic solids. All of them take an optional list of colors to be applied to faces. All of them provide face normals, since they are all faceted. | |
Mesh * | glmesh::gen::Tetrahedron (const ColorArray &colorSequence=ColorArray()) |
Generates a regular, unit tetrahedron. More... | |
Mesh * | glmesh::gen::Cube (const ColorArray &colorSequence=ColorArray()) |
Generates a unit cube. More... | |
Mesh * | glmesh::gen::Octahedron (const ColorArray &colorSequence=ColorArray()) |
Generates a regular, unit octahedron. More... | |
Mesh * | glmesh::gen::Dodecahedron (const ColorArray &colorSequence=ColorArray()) |
Generates a regular, (nearly) unit dodecahedron. More... | |
Mesh * | glmesh::gen::Icosahedron (const ColorArray &colorSequence=ColorArray()) |
Generates a regular, unit icosahedron. More... | |
Quadric Surfaces | |
Quadric Surfaces are curved surfaces defined by multi-dimensional quadratic equations. It is a special class of surface that includes cones, cylinders, and spheres. These functions generate unit meshes for these shapes. | |
Mesh * | glmesh::gen::UnitSphere (int numHorizSlices, int numVertSlices) |
Creates a unit sphere at the origin. More... | |
Mesh* glmesh::gen::Cube | ( | const ColorArray & | colorSequence = ColorArray() | ) |
Generates a unit cube.
A cube is... OK, do you really need me to tell you what a cube is?
The cube is on the range [-1, 1], so the lengths of its sides are 2. The cube is axis-aligned.
Available attributes:
The order of the colors is such that, if you pass a 3 element list, then each pair of faces on opposite sides of the cube will have the same color. The order of colors is: +Y, +X, +Z, -Y, -X, -Z.
Mesh* glmesh::gen::CubeBlock | ( | int | numCubesOnEdge, |
const ColorArray & | colorSequence = ColorArray() |
||
) |
Creates a cubical block of cubes in an alternating pattern.
Each cube is a cube of size 2. The entire array will be centered around it's centerpoint. The array's length on one side will be 2 * (2n - 1)
, where n
is the number of cubes on an edge.
Available attributes:
numCubesOnEdge | The number of cubes that will appear on each edge. Will be clamped to the range [1, 16384]. |
colorSequence | A series of colors used to color the faces of the objects. The order of faces is: +y, +x, -y, -x, +z, -z. The color used will wrap around, so if you provide 6 colors, then each cube will get the same six colors. |
Mesh* glmesh::gen::CubePyramid | ( | int | numCubesTall, |
const ColorArray & | colorSequence = ColorArray() |
||
) |
Creates a pyramid made of cubes, in an alternating pattern.
Each cube is a cube of size 2. The pyramid will be pointing in the positive y axis. The entire array will be centered around its X/Z centerpoint, with the zero y at the base of the pyramid. The height will be 2*n
, where n
is the number of cubes in height. The width/depth will be 2 * (2n - 1)
.
Available attributes:
numCubesTall | How many cubes in height the pyramid will be. Will be clamped to the range [1, 16383]. |
colorSequence | A series of colors used to color the faces of the objects. The order of faces is: +y, +x, -y, -x, +z, -z. The color used will wrap around, so if you provide 6 colors, then each cube will get the same six colors. |
Mesh* glmesh::gen::Dodecahedron | ( | const ColorArray & | colorSequence = ColorArray() | ) |
Generates a regular, (nearly) unit dodecahedron.
A dodecahedron is a 12-sided solid, where each face is a pentagon. It is regular in that the pentagonal faces are all equilateral.
The dodecahedron is oriented so that two opposite faces face directly in the +Y and -Y axes.
Available attributes:
Note that the color here represents the color per face, not just per triangle used to build that face. So each of the triangles in a pentagon gets the same color. The order of the colors is such that, if you provide 6 colors, then the opposite faces will all have the same color.
The first color is for the top face (+Y). The next 5 are for the faces that point in the +Y axis, starting from the one facing directly +X (with no Z in its facing). These proceed clockwise, as seen when looking down at the dodecahedron. The other 6 faces are the opposing faces for those faces.
Mesh* glmesh::gen::FullScreenQuad | ( | ) |
A mesh of a full-screen quad. Useful for post-processing effects.
This is a quad that covers the screen. Your vertex shader should pass the positions without transformation. The positions are already in clip-space.
This mesh has only the position attribute. The position's Z is always 0, and the W is 1.
Mesh* glmesh::gen::GroundPlane | ( | int | numXVerts, |
int | numYVerts, | ||
bool | bDoubleSided = true |
||
) |
A mesh ground plane. Can be double-sided and arbitrarily tessellated.
This creates a square, on the range [-1, 1] in the XY plane (faces in the +Z direction). The quad can be tessellated arbitrarily, via parameters.
Available attributes:
numXVerts | Number of vertices along the X axis. Must be 2 or greater. |
numYVerts | Number of vertices along the Y axis. Must be 2 or greater. |
bDoubleSided | Whether the ground is double-sided or not. If not, then CCW will point in the positive-Y. |
Mesh* glmesh::gen::Icosahedron | ( | const ColorArray & | colorSequence = ColorArray() | ) |
Generates a regular, unit icosahedron.
An icosahedron is a 20-sided, triangular solid. It is regular in that all of the triangles used in creating it are equilateral.
The icosahedron is oriented so that two opposite vertices are in the +Y and -Y axes.
Available attributes:
Mesh* glmesh::gen::Octahedron | ( | const ColorArray & | colorSequence = ColorArray() | ) |
Generates a regular, unit octahedron.
An octahedron is an 8-sided, triangular solid. It is regular in that all of the triangles used in creating it are equilateral.
The octahedron's 6 vertices point in the axial directions. All of the points lie in [-1, 1], and the 6 positions are all right on the border.
Available attributes:
Mesh* glmesh::gen::Tetrahedron | ( | const ColorArray & | colorSequence = ColorArray() | ) |
Generates a regular, unit tetrahedron.
A tetrahedron is a 4-sided, triangular solid. It is regular in the sense that all of the triangles used to construct it are equilateral.
The tetrahedron is generated with one vertex pointed in the +Y direction, with the flat size directly facing the -Y direction. It is a regular tetrahedron, so all of the triangles are equilateral. The geometric center of the tetrahedron is at the origin. The points of the tetrahedron are within the [-1, 1] range of the origin.
The top point of the tetrahedron is exactly at (0, 1, 0).
Available attributes:
Mesh* glmesh::gen::UnitSphere | ( | int | numHorizSlices, |
int | numVertSlices | ||
) |
Creates a unit sphere at the origin.
A unit sphere is a sphere of radius 1, so it extends from [-1, 1] in all three axes.
Available attributes:
numHorizSlices | The number of horizontal slices of the sphere. More slices make it smoother. |
numVertSlices | The number of vertical slices of the sphere. More slices make it smoother. |