Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# `Hydra.utils.model`

Module responsible for VAO creation and mesh operations.

## Module Contents

Hydra.utils.model.createVAO(ctx: moderngl.Context, program: moderngl.Program, vertices: list[tuple[float]] = None, indices: list[int] = None)

  Creates a `moderngl.VertexArray` object.

  Parameters:

    - ctx (`moderngl.Context`) – ModernGL context.

    - program (`moderngl.Program`) – Program to bind to the VAO.

    - vertices (`list[tuple[float, float, float]]`) – Optional list of 3D vertex position.

    - indices (`list[int]`) – Optional list of vertex indices.

  Returns:

    Created VAO object.

  Return type:

    `moderngl.VertexArray`

Hydra.utils.model.evaluateMesh(obj: bpy.types.Object) → tuple[any, any]

  Evaluates an object as a mesh.

  Parameters:

    obj (`bpy.types.Object`) – Object to be evaluated.

  Returns:

    Created BMesh and a list of vertices.

  Return type:

    `tuple[BMesh, list[Vertex]]`

Hydra.utils.model.getResizeMatrix(obj: bpy.types.Object) → tuple[float]

  Creates a resizing matrix that scales the input object into normalized device coordinates, so that 1-Z is the normalized surface height. Also sets `hydra.scale_ratio` and `hydra.height_scale` for the object.

  Parameters:

    obj (`bpy.types.Object`) – Object to be evaluated.

  Returns:

    Created resizing matrix.

  Return type:

    `tuple[float]`

Hydra.utils.model.createLandscape(txt: moderngl.Texture, name: str) → bpy.types.Object

  Creates a grid object of the given texture resolution. Divides the resolution by global settings. Doesn’t write height data!

  Parameters:

    - txt (`moderngl.Texture`) – Texture of the intended resolution.

    - name (`str`) – Owner name.

  Returns:

    Created grid object.

  Return type:

    `bpy.types.Object`