Skip to content

novaphy.ModelBuilder

Mutable scene-construction API. Add bodies, shapes, joints, articulations, fluid blocks, and imported assets, then call finalize() to produce an immutable Model.

import novaphy
import numpy as np

builder = novaphy.ModelBuilder()
builder.add_ground_plane(y=0.0)

body = novaphy.RigidBody.from_box(1.0, np.array([0.5, 0.5, 0.5], dtype=np.float32))
idx = builder.add_body(body, novaphy.Transform.from_translation(np.array([0, 5, 0])))
builder.add_shape(novaphy.CollisionShape.make_box(np.array([0.5, 0.5, 0.5]), idx))

model = builder.finalize()

Body and Shape

Method Purpose
add_body(body, transform=Transform.identity()) -> int Add a rigid body. Returns body index.
add_link(...) -> int Newton-aligned link/body creation helper for articulated systems.
add_ground_plane(y=0.0, friction=0.5, restitution=0.0) -> int Add an infinite ground plane shape. Returns shape index.
add_shape(shape) -> int Add a CollisionShape. Returns shape index.
add_shape_box(...) Newton-style deferred shape creation.
add_shape_sphere(...) Newton-style deferred shape creation.
add_shape_plane(...) Add a plane shape.
add_shape_cylinder(...) Newton-style deferred cylinder shape creation.
add_shape_convex_hull(...) Add a convex hull from a Mesh or vertex list.
add_shape_convex_hull_with_inertia(...) Add a convex hull using precomputed inertia data.
add_shape_mesh(mesh=..., ...) Add a triangle-mesh shape (uses Mesh precomputed inertia when present).
add_shape_mesh_with_inertia(...) Add a triangle mesh using precomputed inertia data.
add_shape_to_body(body_index, shape) Attach an existing CollisionShape to a body.
add_shape_collision_filter_pair(shape_a, shape_b) Disable collision for a pair of finalized/eager shape indices.

Particles

Method Purpose
add_particle(pos, vel, mass, radius=None) Add one particle.
add_particles(pos, vel, mass, radius=None) Add a batch of particles.

Joints and Articulations

Method Purpose
add_joint(joint_type, parent, child, ...) Generic Newton-style joint factory.
add_joint_revolute(parent, child, axis: JointDofConfig, ...) Add a revolute joint between two body indices.
add_joint_prismatic(...) Add a 1-DOF translational joint.
add_joint_ball(...) Add a 3-DOF spherical joint.
add_joint_fixed(...) Add a 0-DOF rigid attachment.
add_joint_free(...) Add a 6-DOF floating-base joint.
add_joint_distance(...) Add a scalar distance constraint.
add_joint_d6(...) Add a configurable 0-6 DOF joint from axis configs.
add_joint_cable(...) Add a scalar cable / rope constraint.
add_articulation(joints, label="") -> int Group joint indices into an articulation. Returns articulation index.

Multiworld and Metadata

Method Purpose
begin_world(label=None, attributes=None, gravity=None) / end_world() Add subsequent bodies, joints, shapes, and particles to one world slice. Passing per-world gravity by keyword is clearest.
add_world(builder, xform, ...) Append another builder as a world instance and record xform.position as that world's physical origin.
replicate(builder, num_worlds, spacing) Replicate a builder into multiple world slices, spaced by spacing, and expose those origins through Model.world_origins. The legacy keyword world_count remains accepted as a compatibility alias for num_worlds.
set_gravity(gravity) Set default builder gravity.
add_site(...) / add_site_on_link(...) Add named attachment points for sensors and importers.
request_state_attributes(...) Request optional state-side storage.
request_contact_attributes(...) Request optional contact-side storage such as force.
set_broad_phase_mode(mode) Select default broadphase mode for finalized collision pipelines.

Asset Import

Method Purpose
add_urdf(source, **kwargs) Parse a URDF file/path or XML source through the public builder wrapper.
add_mjcf(source, *, ...) Parse a MuJoCo XML file/path or XML source. Its import controls are keyword-only. Returns articulation index (or -1 if empty).
add_mjcf_string(xml_text, options=None) Parse an in-memory MJCF XML string.
add_usd(source, *, ...) Parse a text PhysX USD articulation from a file, including bodies, supported joints, and collision shapes. Returns its root body index.

MJCF coverage includes nested bodies, box / sphere / capsule / cylinder / plane geoms, hinge / slide / ball / free joints, inertial blocks, and world-level gravity. URDF is available both through add_urdf and the dedicated I/O pipeline. add_usd is a separate, text-based PhysX articulation path; the smaller USDA snapshot pipeline uses the dedicated importer—see novaphy.io.

Finalize

Method Purpose
finalize(device=Device.cpu(), requires_grad=False) -> Model Bake into an immutable Model. Newton-aligned signature.

Properties

Property Description
num_bodies Number of currently added bodies.
num_shapes Number of currently added shapes.
num_sites Number of currently added sites.
current_world Index of the currently open world slice, or -1 for the global/no-open-world sentinel.
broad_phase Builder default broadphase mode.
default_shape_cfg Default shape configuration used by helper methods.
default_particle_radius Default particle radius for particle helpers.

See Also