demosys.geometry

The geometry module is a collection of functions generating simple geometry / VAOs.

Functions

demosys.geometry.quad_fs() → demosys.opengl.vao.VAO

Creates a screen aligned quad using two triangles with normals and texture coordiantes.

Returns:A demosys.opengl.vao.VAO instance.
demosys.geometry.quad_2d(width, height, xpos=0.0, ypos=0.0) → demosys.opengl.vao.VAO

Creates a 2D quad VAO using 2 triangles with normals and texture coordinates.

Parameters:
  • width (float) – Width of the quad
  • height (float) – Height of the quad
Keyword Arguments:
 
  • xpos (float) – Center position x
  • ypos (float) – Center position y
Returns:

A demosys.opengl.vao.VAO instance.

demosys.geometry.cube(width, height, depth, center=(0.0, 0.0, 0.0), normals=True, uvs=True) → demosys.opengl.vao.VAO

Creates a cube VAO with normals and texture coordinates

Parameters:
  • width (float) – Width of the cube
  • height (float) – Height of the cube
  • depth (float) – Depth of the cube
Keyword Arguments:
 
  • center – center of the cube as a 3-component tuple
  • normals – (bool) Include normals
  • uvs – (bool) include uv coordinates
Returns:

A demosys.opengl.vao.VAO instance

demosys.geometry.bbox(width=1.0, height=1.0, depth=1.0)

Generates a bounding box with (0.0, 0.0, 0.0) as the center. This is simply a box with LINE_STRIP as draw mode.

Keyword Arguments:
 
  • width (float) – Width of the box
  • height (float) – Height of the box
  • depth (float) – Depth of the box
Returns:

A demosys.opengl.vao.VAO instance

demosys.geometry.plane_xz(size=(10, 10), resolution=(10, 10)) → demosys.opengl.vao.VAO

Generates a plane on the xz axis of a specific size and resolution. Normals and texture coordinates are also included.

Parameters:
  • size – (x, y) tuple
  • resolution – (x, y) tuple
Returns:

A demosys.opengl.vao.VAO instance

demosys.geometry.points_random_3d(count, range_x=(-10.0, 10.0), range_y=(-10.0, 10.0), range_z=(-10.0, 10.0), seed=None) → demosys.opengl.vao.VAO

Generates random positions inside a confied box.

Parameters:

count (int) – Number of points to generate

Keyword Arguments:
 
  • range_x (tuple) – min-max range for x axis: Example (-10.0. 10.0)
  • range_y (tuple) – min-max range for y axis: Example (-10.0. 10.0)
  • range_z (tuple) – min-max range for z axis: Example (-10.0. 10.0)
  • seed (int) – The random seed
Returns:

A demosys.opengl.vao.VAO instance

demosys.geometry.sphere(radius=0.5, sectors=32, rings=16) → demosys.opengl.vao.VAO

Creates a sphere.

Keyword Arguments:
 
  • radius (float) – Radius or the sphere
  • rings (int) – number or horizontal rings
  • sectors (int) – number of vertical segments
Returns:

A demosys.opengl.vao.VAO instance