Node

moderngl_window.scene.Node[source]

A generic scene node containing a mesh or camera and/or a container for other nodes. Nodes and their children represents the scene tree.

Methods

Node.__init__(name=None, camera=None, mesh=None, matrix=None)[source]

Create a node.

Keyword Arguments:
  • name – Name of the node

  • camera – Camera to store in the node

  • mesh – Mesh to store in the node

  • matrix – The node’s matrix

Node.add_child(node)[source]

Add a child to this node

Parameters:

node (Node) – Node to add as a child

Node.draw(projection_matrix=None, camera_matrix=None, time=0)[source]

Draw node and children.

Keyword Arguments:
  • projection_matrix (bytes) – projection matrix

  • camera_matrix (bytes) – camera_matrix

  • time (float) – The current time

Node.draw_bbox(projection_matrix, camera_matrix, program, vao)[source]

Draw bounding box around the node and children.

Keyword Arguments:
  • projection_matrix (bytes) – projection matrix

  • camera_matrix (bytes) – camera_matrix

  • program (moderngl.Program) – The program to render the bbox

  • vao – The vertex array representing the bounding box

Node.draw_wireframe(projection_matrix, camera_matrix, program)[source]

Render the node as wireframe.

Keyword Arguments:
  • projection_matrix (bytes) – projection matrix

  • camera_matrix (bytes) – camera_matrix

  • program (moderngl.Program) – The program to render wireframe

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

Recursive calculation of scene bbox.

Keyword Arguments:
  • view_matrix (numpy.ndarray) – view matrix

  • bbox_min – min bbox values

  • bbox_max – max bbox values

Node.calc_model_mat(model_matrix)[source]

Calculate the model matrix related to all parents.

Parameters:

model_matrix (numpy.ndarray) – model matrix

Attributes

Node.name

Get or set the node name

Type:

str

Node.mesh

The mesh if present

Type:

Mesh

Node.camera

The camera if present

Type:

Camera

Node.matrix

Note matrix (local)

Type:

numpy.ndarray

Node.matrix_global

The global node matrix containing transformations from parent nodes

Type:

numpy.ndarray

Node.children

List of children

Type:

list