moderngl_window.scene.Mesh = <class 'moderngl_window.scene.mesh.Mesh'>[source]

Mesh info and geometry


Mesh.__init__(name, vao=None, material=None, attributes=None, bbox_min=None, bbox_max=None)[source]

Initialize mesh.


name (str) – name of the mesh

Keyword Arguments:
  • vao (VAO) – geometry

  • material (Material) – material for the mesh

  • attributes (dict) – Details info about each mesh attribute (dict)

  • bbox_min – xyz min values

  • bbox_max – xyz max values

Attributes example:

    "NORMAL": {"name": "in_normal", "components": 3, "type": GL_FLOAT},
    "POSITION": {"name": "in_position", "components": 3, "type": GL_FLOAT}
Mesh.draw(projection_matrix=None, model_matrix=None, camera_matrix=None, time=0.0)[source]

Draw the mesh using the assigned mesh program

Keyword Arguments:
  • projection_matrix (bytes) – projection_matrix

  • view_matrix (bytes) – view_matrix

  • camera_matrix (bytes) – camera_matrix

Mesh.draw_bbox(proj_matrix, model_matrix, cam_matrix, program, vao)[source]

Renders the bounding box for this mesh.

  • proj_matrix – Projection matrix

  • model_matrix – View/model matrix

  • cam_matrix – Camera matrix

  • program – The moderngl.Program rendering the bounding box

  • vao – The vao mesh for the bounding box

Mesh.draw_wireframe(proj_matrix, model_matrix, program)[source]

Render the mesh as wireframe.

proj_matrix: Projection matrix model_matrix: View/model matrix program: The moderngl.Program rendering the wireframe

Mesh.add_attribute(attr_type, name, components)[source]

Add metadata about the mesh :param attr_type: POSITION, NORMAL etc :param name: The attribute name used in the program :param components: Number of floats

Mesh.calc_global_bbox(view_matrix, bbox_min, bbox_max)[source]

Calculates the global bounding.

  • view_matrix – View matrix

  • bbox_min – xyz min

  • bbox_max – xyz max


Combined bbox

Return type:

bbox_min, bbox_max

Mesh.has_normals() bool[source]

Does the mesh have a normals?

Return type:


Mesh.has_uvs(layer=0) bool[source]

Does the mesh have texture coordinates?

Return type: