/  ChuGL Geometries

Geometry

BoxGeometry

SphereGeometry

TriangleGeometry

CircleGeometry

LatheGeometry

PlaneGeometry

TorusGeometry

CylinderGeometry

CustomGeometry

ChuGL geometries contain vertex data such as positions, normals, and UV coordinates.

Geometry

inherits : Object

Base geometry class, do not instantiate directly.

examples

constructors

Geometry()

Default constructor for Geometry.

member functions

Geometry clone()

Clone the geometry, including all attributes.

void colors(float[] colors)

Set color attribute data from an array of floats; every 4 floats corresdpond to (r, g, b, a) values of a vertex color);.

void colors(vec3[] colors)

Set color attribute data from an array of vec3 (r, g, b); alpha is assumed to be 1.0.

void colors(vec4[] colors)

Set color attribute data from an array of vec4 (r, g, b, a)

void indices(int[] indices)

Sets vertex indices for indexed drawing. If not set, renderer will default to non-indexed drawing.

void normals(float[] normals)

Set normal attribute data from an array of floats; every 3 floats corresdpond to (x, y, z) values of a vertex normal.

void normals(vec3[] normals)

Set normal attribute data from an array of vec3 (x, y, z)

void positions(float[] positions)

Set position attribute data from an array of floats; every 3 floats correspond to (x, y, z) values of a vertex position.

void positions(vec3[] positions)

Set position attribute data from an array of vec3 (x, y, z)

void setAttribute(string name, int location, int numComponents, float[] data)

Set the attribute data for the given attribute location, to be passed into the vertex shader. Builtin attribute locations are POS_ATTRIB_LOC, NORM_ATTRIB_LOC, COL_ATTRIB_LOC, UV0_ATTRIB_LOC.

void uvs(float[] uvs)

Set UV attribute data from an array of floats; every pair of floats corresponds to (u, v) values (used for texture mapping)

void uvs(vec2[] uvs)

Set UV attribute data from an array of vec2 (u,v) or (s,t)

static member variables

int COL_ATTRIB_LOC

No description available

int NORM_ATTRIB_LOC

No description available

int POS_ATTRIB_LOC

No description available

int UV0_ATTRIB_LOC

No description available


BoxGeometry

inherits : Geometry : Object

Geometry class for constructing vertex data for boxes aka cubes.

constructors

BoxGeometry()

Default constructor for BoxGeometry.

member functions

void set(float width, float height, float depth, int widthSeg, int heightSeg, int depthSeg)

Set box dimensions and subdivisions.


SphereGeometry

inherits : Geometry : Object

Geometry class for constructing vertex data for spheres.

constructors

SphereGeometry()

Default constructor for SphereGeometry.

member functions

void set(float radius, int widthSeg, int heightSeg, float phiStart, float phiLength, float thetaStart, float thetaLength)

Set sphere dimensions and subdivisions.


TriangleGeometry

inherits : Geometry : Object

Geometry class for constructing vertex data for triangles.

examples

constructors

TriangleGeometry()

Default constructor for TriangleGeometry.

member functions

void set(float theta, float width, float height)

Set triangle construction params.Theta is the angle in radians betweeen the base and the hypotenuseWidth is the length of the baseHeight is distance from base to the opposite vertex.


CircleGeometry

inherits : Geometry : Object

Geometry class for constructing vertex data for circles.

constructors

CircleGeometry()

Default constructor for CircleGeometry.

member functions

void set(float radius, int segments, float thetaStart, float thetaLength)

Set circle dimensions and subdivisions.


LatheGeometry

inherits : Geometry : Object

Geometry class for constructing vertex data for lathes (i.e. rotated curves)

examples

constructors

LatheGeometry()

Default constructor for LatheGeometry.

member functions

void set(float[] path, int segments, float phiStart, float phiLength)

Set lathe curve, dimensions and subdivisions. Path is rotated phiLength to form a curved surfaceNOTE: path takes a float[] of alternating x,y values, describing a 2D curve in the x,y planeThese values are rotated around the y-axis to form a 3D surface.

void set(int segments, float phiStart, float phiLength)

Set lathe dimensions and subdivisions while maintaining the previously set curve.


PlaneGeometry

inherits : Geometry : Object

Geometry class for constructing vertex data for planes.

constructors

PlaneGeometry()

Default constructor for PlaneGeometry.

member functions

void set(float width, float height, int widthSegments, int heightSegments)

Set plane dimensions and subdivisions.


TorusGeometry

inherits : Geometry : Object

Geometry class for constructing vertex data for toruses.

constructors

TorusGeometry()

Default constructor for TorusGeometry.

member functions

void set(float radius, float tubeRadius, int radialSegments, int tubularSegments, float arcLength)

Set torus dimensions and subdivisions.


CylinderGeometry

inherits : Geometry : Object

Geometry class for constructing vertex data for cylinders.

examples

constructors

CylinderGeometry()

Default constructor for CylinderGeometry.

member functions

void set(float radiusTop, float radiusBottom, float height, int radialSegments, int heightSegments, int openEnded, float thetaStart, float thetaLength)

Set cylinder dimensions and subdivisions.


CustomGeometry

inherits : Geometry : Object

Geometry class for providing your own vertex data. Used implicitly by GLines and GPoints.

examples

constructors

CustomGeometry()

Default constructor for CustomGeometry.