# Mesh

moderngl_window.scene.Mesh = <class 'moderngl_window.scene.mesh.Mesh'>

  Mesh info and geometry

## Methods

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

  Initialize mesh.

  Parameters:

    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)

  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)

  Renders the bounding box for this mesh.

  Parameters:

    - 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)

  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)

  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)

  Calculates the global bounding.

  Parameters:

    - view_matrix – View matrix

    - bbox_min – xyz min

    - bbox_max – xyz max

  Returns:

    Combined bbox

  Return type:

    bbox_min, bbox_max

Mesh.has_normals() → bool
  Returns:

    Does the mesh have a normals?

  Return type:

    bool

Mesh.has_uvs(layer=0) → bool
  Returns:

    Does the mesh have texture coordinates?

  Return type:

    bool