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(position, velocity, mass, radius) |
Add one particle. |
add_particles(positions, velocities, masses, radii) |
Add a batch of particles. |
Joints and Articulations
| Method |
Purpose |
add_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(joint_indices, label="") -> int |
Group joint indices into an articulation. Returns articulation index. |
| Method |
Purpose |
begin_world(gravity=None) / end_world() |
Add subsequent bodies, joints, shapes, and particles to one world slice. |
add_world(builder, xform, ...) |
Append another builder as a world instance. |
replicate(builder, world_count, spacing) |
Replicate a builder into multiple world slices. |
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_mjcf(xml_path, options=None) |
Parse a MuJoCo XML file. Returns articulation index (or -1 if empty). |
add_mjcf_string(xml_text, options=None) |
Parse an in-memory MJCF XML string. |
MJCF coverage includes nested bodies, box / sphere / capsule / cylinder /
plane geoms, hinge / slide / ball / free joints, inertial blocks, and
world-level gravity. URDF and OpenUSD are exposed through dedicated importers
-- 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 the default world. |
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