AGL  0
3D graphics library
Shapes

Functions

Entity tetrahedron ()
 Create a tetrahedron. More...
 
Entity cube (bool calcNorm=false, bool calcUV=false)
 Create a cube. More...
 
Entity cuboid (float x=2, float y=2, float z=2, bool calcNorm=false, bool calcUV=false)
 Create a cuboid. More...
 
Entity octahedron ()
 Create an octahedron. More...
 
Entity dodecahedron ()
 Create a dodecahedron. More...
 
Entity icosahedron ()
 Create an icosahedron. More...
 
Entity sphere (int lat=20, int lng=20, bool calcNorm=false, bool calcUV=false)
 Create a unit sphere. More...
 
Entity icosphere (int subdivision=3, bool calcNorm=false)
 Create a unit sphere. More...
 
Entity cylinder (float r=1, float h=2, int strips=20)
 Create a cylinder. More...
 
Entity plane (float x=2, float z=2, bool calcNorm=false, bool calcUV=false)
 Create a plane on the xz-plane. More...
 
Entity tessellatedPlane (int l=10, int h=10)
 Create a plane on the xz-plane. More...
 

Detailed Description

These functions creates some of the common shapes, including the regular polyhedrons. All these functions returns an Entity with the appropriate vertices. Optionally, for some of the shapes, you can also get the normals and texture coordinates calculated.

Function Documentation

◆ cube()

Entity cube ( bool  calcNorm = false,
bool  calcUV = false 
)

Create a cube.

Parameters
calcNormIf true, also calculates the normals.
calcUVIf true, also calculates the texture coordinates.

The cube ranges from -1 to +1 on all the axes, ie. centered at the origin and going to unit length on all the axes.

◆ cuboid()

Entity cuboid ( float  x = 2,
float  y = 2,
float  z = 2,
bool  calcNorm = false,
bool  calcUV = false 
)

Create a cuboid.

Parameters
xLength along the x axis.
yLength along the y axis.
zLength along the z axis.
calcNormIf true, also calculates the normals.
calcUVIf true, also calculates the texture coordinates.

The cuboid is centered at the origin and ranges from \(-\frac l2\) to \(+\frac l2\) on each axis ( \(l\) is the length for that axis).

◆ cylinder()

Entity cylinder ( float  r = 1,
float  h = 2,
int  strips = 20 
)

Create a cylinder.

Parameters
rRadius of the cylinder.
hHeight of the cylinder.
stripsNumber of stripes to use for the curved surface.

◆ dodecahedron()

Entity dodecahedron ( )

Create a dodecahedron.

Each vertex of the dodecahedron is at a distance of \(\sqrt 3\) from the origin.

◆ icosahedron()

Entity icosahedron ( )

Create an icosahedron.

Each of the vertices are at a coordinate with values of 0, \(\pm1\) and \(\pm\href{https://en.wikipedia.org/wiki/Golden_ratio}\phi\) in some order.

◆ icosphere()

Entity icosphere ( int  subdivision = 3,
bool  calcNorm = false 
)

Create a unit sphere.

Parameters
subdivisionNumber of times the icosahedron is subdivided.
calcNormIf true, also calculates the normals.

Create a unit icosphere, ie. sphere created by subdividing a icosahedron. It has triangular faces. Read more here.

See also
sphere icosahedron subdivideVertices

◆ octahedron()

Entity octahedron ( )

Create an octahedron.

The vertices of the octahedron is at the center of the faces of the cube.

◆ plane()

Entity plane ( float  x = 2,
float  z = 2,
bool  calcNorm = false,
bool  calcUV = false 
)

Create a plane on the xz-plane.

Parameters
xLength along x-axis.
zLength along z-axis.
calcNormIf true, also calculates the normals.
calcUVIf true, also calculates the texture coordinates.

The plane consists of just the four corner vertices at y=0.

◆ sphere()

Entity sphere ( int  lat = 20,
int  lng = 20,
bool  calcNorm = false,
bool  calcUV = false 
)

Create a unit sphere.

Parameters
latNumber of latitudes.
lngNumber of longitudes.
calcNormIf true, also calculates the normals.
calcUVIf true, also calculates the texture coordinates.

Create a unit sphere in uv coordinates. A uv-sphere has quadrilateral faces formed with rings and segments, like the Earth's latitudes and longitudes. The sphere has lat rings and lng segments. Read more here.

See also
icosphere

◆ tessellatedPlane()

Entity tessellatedPlane ( int  l = 10,
int  h = 10 
)

Create a plane on the xz-plane.

Parameters
lNumber of segments along the x-axis.
hNumber of segments along the z-axis.

This creates a tessellated plane, ie. the plane is divided into smaller square unit segments, each at y=0.

◆ tetrahedron()

Entity tetrahedron ( )

Create a tetrahedron.

The tetrahedron is as big such that it touches the faces or vertices of a cube.