scene: model nodes

To use this module, require it in a generator script (see Geometry modules):

require scene

A tree of named model nodes for a csg model: each node has a solid and a frame (its pivot). Return the root Node from a [model_generator]. Each node becomes a node of the model, and collider of engine.gen_geometry.model_structures gives it collider shapes.

Structures

Node

A node of a csg model: a name, a solid, a frame and collider shapes.

Fields:
  • id : int - The index of the node in the model; 0 is the root

Pivot

The frame of a child node, made by pivot, pivot_y or pivot_z.

Fields:
  • p : float3 - The origin of the frame in model space, in meters

  • axis : float3 - The direction of the local axis that kind names

  • kind : int - 0: the axes of the model, 1: local Y along axis, 2: local Z along axis

Nodes

child(n: Node; name: string; mesh: Solid; pivot: Pivot): Node

Adds a child node to n and returns it. The solid is in model space; the pivot is the frame of the node.

Arguments:
  • n : Node - the parent node

  • name : string - the node name, 1 to 64 characters of A-Z, a-z, 0-9 and _, unique in the model

  • mesh : Solid - the solid of the node in model space, empty() for a node with no mesh

  • pivot : Pivot - the frame of the node, in model space, pivot, pivot_y or pivot_z

find(n: Node; name: string): Node

The first node named name at or below n; no such node fails the generation.

Arguments:
  • n : Node

  • name : string

node(name: string; mesh: Solid): Node

The root node of the model, with a solid in model space; the frame of the root is the model frame.

Arguments:
  • name : string - the node name, 1 to 64 characters of A-Z, a-z, 0-9 and _, unique in the model

  • mesh : Solid - the solid of the node in model space, empty() for a node with no mesh

set_mesh(n: Node; mesh: Solid): Node

Replaces the solid of the node, in model space; returns n.

Arguments:

Pivots

pivot(p: float3): Pivot

A node frame at the point p (model space) with the axes of the model.

Arguments:
  • p : float3

pivot_y(p: float3; axis: float3): Pivot

A node frame at the point p whose local Y runs along axis, as a wheel axle; local X comes from the model axis least parallel to axis.

Arguments:
  • p : float3

  • axis : float3

pivot_z(p: float3; axis: float3): Pivot

A node frame at the point p whose local Z runs along axis; local X comes from the model axis least parallel to axis.

Arguments:
  • p : float3

  • axis : float3