Graphics generators (GGens) that can be composed together in a scene graph.
Base class for all Gens. Can be extended to create your own, or initialized as an empty group container.
GGen()
Default constructor for GGen.
GGen child(int n)
Get the n'th child of this GGen.
GGen child()
Get the 0th child of this GGen.
vec3 forward()
Get the forward vector of this GGen in world space.
int id()
Internal debug. Get the unique ChuGL ID of this GGen.
GGen lookAt(vec3 pos)
Look at the given position in world space.
vec3 lookAtDir()
Get the direction this GGen is looking, i.e. the forward vector of this GGen in world space.
string name()
Get the custom name of this GGen.
string name(string name)
Set the custom name of this GGen.
int numChildren()
Get the number of children for this GGen.
GGen parent()
Get the parent of this GGen.
vec3 pos()
Get object position in local space.
vec3 pos(vec3 pos)
Set object position in local space.
vec3 posLocalToWorld(vec3 localPos)
Transform a position in local space to world space.
vec3 posWorld()
Get object position in world space.
vec3 posWorld(vec3 pos)
Set object position in world space.
float posX()
Get X position of this GGen in local space.
float posX(float pos)
Set X position of this GGen in local space.
float posY()
Get Y position of this GGen in local space.
float posY(float pos)
Set Y position of this GGen in local space.
float posZ()
Get Z position of this GGen in local space.
float posZ(float pos)
Set Z position of this GGen in local space.
vec3 right()
Get the right vector of this GGen in world space.
vec3 rot()
Get object rotation in local space as euler angles in radians.
vec3 rot(vec3 eulers)
Set rotation of this GGen in local space as euler angles.
float rotX()
Get the rotation of this GGen on the X axis in local space.
float rotX(float radians)
Set the rotation of this GGen on the X axis in local space to the given radians.
float rotY()
Get the rotation of this GGen on the Y axis in local space.
float rotY(float radians)
Set the rotation of this GGen on the Y axis in local space to the given radians.
float rotZ()
Get the rotation of this GGen on the Z axis in local space.
float rotZ(float radians)
Set the rotation of this GGen on the Z axis in local space to the given radians.
GGen rotate(vec3 eulers)
Rotate this GGen by the given euler angles in local space.
GGen rotateOnLocalAxis(vec3 axis, float radians)
Rotate this GGen by the given radians on the given axis in local space.
GGen rotateOnWorldAxis(vec3 axis, float radians)
Rotate this GGen by the given radians on the given axis in world space.
GGen rotateX(float radians)
Rotate this GGen by the given radians on the X axis in local space.
GGen rotateY(float radians)
Rotate this GGen by the given radians on the Y axis in local space.
GGen rotateZ(float radians)
Rotate this GGen by the given radians on the Z axis in local space.
vec3 sca()
Get object scale in local space.
vec3 sca(vec3 scale)
Set object scale in local space.
vec3 sca(float scale)
Set object scale in local space uniformly across all axes.
vec3 scaWorld()
Get object scale in world space.
vec3 scaWorld(vec3 scale)
Set object scale in world space.
float scaX()
Get X scale of this GGen in local space.
float scaX(float scale)
Set X scale of this GGen in local space.
float scaY()
Get Y scale of this GGen in local space.
float scaY(float scale)
Set Y scale of this GGen in local space.
float scaZ()
Get Z scale of this GGen in local space.
float scaZ(float scale)
Set Z scale of this GGen in local space.
GGen translate(vec3 translation)
Translate this GGen by the given vector.
GGen translateX(float amt)
Translate this GGen by given amount on the X axis in local space.
GGen translateY(float amt)
Translate this GGen by given amount on the Y axis in local space.
GGen translateZ(float amt)
Translate this GGen by given amount on the Z axis in local space.
vec3 up()
Get the up vector of this GGen in world space.
void update(float dt)
This method is automatically invoked once per frame for all GGens connected to the scene graph.Override this method in custom GGen classes to implement your own update logic.
[ top ]
Scene class. Static--all instances point to the same underlying ChuGL main scene. GGens must be added to a scene to be rendered.
GScene()
Default constructor for GScene.
vec3 backgroundColor(vec3 color)
Set the background color of the scene.
vec3 backgroundColor()
Get the background color of the scene.
void disableFog()
Disable fog for the scene.
void enableFog()
Enable fog for the scene.
vec3 fogColor(vec3 color)
Set the fog color of the scene.
vec3 fogColor()
Get the fog color of the scene.
float fogDensity(float density)
Set fog density. typically between 0.0 and 0.1.
float fogDensity()
Get fog density.
int fogType(int type)
Set fog type. Use one of the static constants: FOG_EXP or FOG_EXP2.
int fogType()
Get fog type. Can be FOG_EXP or FOG_EXP2.
GLight light()
Get the default directional light of the scene.
int numLights()
Get the number of instantiated lights.
CubeTexture skybox(CubeTexture cubemap)
Set the skybox of the scene. Pass in a cubemap texture. Will enable the skybox.
CubeTexture skybox()
Get the skybox of the scene.
int skyboxEnabled(int enabled)
Enable or disable the skybox.
int skyboxEnabled()
Get whether the skybox is enabled or disabled.
int FOG_EXP
Fog type: exponential.
int FOG_EXP2
Fog type: exponential-squared. more aggressive.
[ top ]
Creates a Mesh that uses CustomGeometry and PointMaterial.
GPoints()
Default constructor for GPoints.
[ top ]
Creates a Mesh that uses CustomGeometry and LineMaterial.
GLines()
Default constructor for GLines.
[ top ]
Mesh class. A mesh is a geometry and a material. It can be added to a scene to be rendered. Parent class of GCube, GSphere, GCircle, etc.
GMesh()
Default constructor for GMesh.
GMesh dup()
Clone both the mesh geometry and material and set it to this mesh.
Geometry dupGeo()
Clone the mesh geometry and set it to this mesh.
Material dupMat()
Clone the mesh material and set it to this mesh.
Geometry geo(Geometry geo)
Set the mesh geometry.
Geometry geo()
Get the mesh geometry.
Material mat(Material mat)
Set the mesh material.
Material mat()
Get the mesh material.
void set(Geometry geo, Material mat)
Set the geometry and material of the mesh.
[ top ]
Creates a Mesh that uses TriangleGeometry and PhongMaterial.
GTriangle()
Default constructor for GTriangle.
[ top ]
Creates a Mesh that uses CircleGeometry and PhongMaterial.
GCircle()
Default constructor for GCircle.
[ top ]
Creates a Mesh that uses PlaneGeometry and PhongMaterial.
GPlane()
Default constructor for GPlane.
[ top ]
Creates a Mesh that uses BoxGeometry and PhongMaterial.
GCube()
Default constructor for GCube.
[ top ]
Creates a Mesh that uses SphereGeometry and PhongMaterial.
GSphere()
Default constructor for GSphere.
[ top ]
Creates a Mesh that uses TorusGeometry and PhongMaterial.
GTorus()
Default constructor for GTorus.
[ top ]
Creates a Mesh that uses CylinderGeometry and PhongMaterial.
GCylinder()
Default constructor for GCylinder.
[ top ]
Light class. Parent class of GPointLight and GDirectionalLight. Don't instantiate this class directly.
GLight()
Default constructor for GLight.
vec3 ambient(vec3 a)
Set ambient color. Ambient color is multiplied by the material ambient color, and will be visible even when no light is directly shining on the object.
vec3 ambient()
Get the light ambient color.
vec3 diffuse(vec3 d)
Set diffuse color. Diffuse color is multiplied by the material diffuse color.
vec3 diffuse()
Get the light diffuse color.
float intensity(float i)
Set intensity from 0-1. 0 is off, 1 is full intensity.
float intensity()
Get light intensity.
vec3 specular(vec3 s)
Set specular color. Specular color is multiplied by the material specular color.
vec3 specular()
Get the light specular color.
[ top ]
Point light class.
GPointLight()
Default constructor for GPointLight.
void falloff(float linear, float quadratic)
Set point light falloff. See https://learnopengl.com/Lighting/Light-casters for a falloff chart.
[ top ]
Directional class. Position of this light has no affect, only rotation.
GDirLight()
Default constructor for GDirLight.
[ top ]
Camera class. Static--all instances point to the same underlying ChuGL main camera.
GCamera()
Default constructor for GCamera.
void clip(float near, float far)
Set camera clipping planes.
float clipFar()
Get far clipping plane.
float clipNear()
Get near clipping plane.
float fov(float f)
(perspective mode) set the field of view in degrees.
float fov()
(perspective mode) get the field of view in degrees.
int mode()
Get camera mode. Can be GCamera.MODE_PERSP or GCamera.MODE_ORTHO.
void orthographic()
Set camera to orthographic mode.
void perspective()
Set camera to perspective mode.
vec3 screenCoordToWorldRay(float screenX, float screenY)
Get a ray in world space representing the normalized directional vector from camera world position to screen coordinatescreenX and screenY are screen coordinates, which you can get from GG.mouseX() and GG.mouseY() or you can pass coordinates directlyuseful if you want to do mouse picking or raycasting.
float viewSize(float s)
(orthographic mode) set the height of the view in world space units. Width is automatically calculated based on aspect ratio.
float viewSize()
(orthographic mode) get the height of the view in world space units.
vec3 worldPosToScreenCoord(vec3 worldPos)
Get a screen coordinate from a world position by casting a ray from worldPos back to the camera and finding the intersection with the near clipping planeworldPos is a vec3 representing a world positionreturns a vec3. X and Y are screen coordinates, Z is the depth-value of the worldPosRemember, screen coordinates have origin at the top-left corner of the window.
int ORTHO
No description available
int PERSPECTIVE
No description available
[ top ]
No description available
GText()
Default constructor for GText.
vec3 color(vec3 color)
Set text color. supports HDR values.
vec3 color()
Get text color.
vec2 controlPoints(vec2 controlPoints)
Set control points for text. x = horizontal, y = verticalThe control point is a ratio within the text's bounding box that determines where its origin isFor example, (0.5, 0.5) will place the origin at the center the text(0.0, 0.0) will place the origin at the top-left of the text(1.0, 1.0) will place the origin at the bottom-right of the text.
vec2 controlPoints()
Get control points.
string font(string font)
Set path to a font file (supported types: .otf and .ttf)If not provided, will default to the font set via GG.font()
string font()
Get font path.
float lineSpacing(float lineSpacing)
Set vertical line spacing. Default is 1.0.
float lineSpacing()
Get vertical line spacing.
string text(string text)
Set text.
string text()
Get text.
[ top ]