goo.simulator

class goo.simulator.Render(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

MP4 = 3
PNG = 1
TIFF = 2
class goo.simulator.Simulator(celltypes: list[CellType | Cell] = [], diffsystems: DiffusionSystem = [], time: int = 250, physics_dt: int = 1, molecular_dt: int = 1, max_cells: int | None = None)[source]

Bases: object

A simulator for cell-based simulations in Blender.

Parameters:
  • cells (List[Cell]) – List of cells.

  • time (List[int]) – Start and end frames.

  • physics_dt (int) – Time step for physics simulation.

  • molecular_dt (int) – Time step for molecular simulation.

  • max_cells (Optional[int]) – Maximum number of cells to include in the simulation.

  • celltypes (list[CellType | Cell])

  • diffsystems (DiffusionSystem)

add_handler(handler: Handler, celltypes: list[CellType] | None = None, diffsystem: DiffusionSystem = None)[source]

Add a handler to the simulation.

Parameters:
add_handlers(handlers: list[Handler])[source]

Add multiple handlers to the simulation.

Parameters:

handlers (list[Handler])

enable_addon(addon)[source]

Enable an addon in Blender.

extend_scene()[source]

Extend the scene to allow cloth physics to pass the default 250 frames.

get_cells(celltypes=None)[source]

Get all cells in the simulation.

get_cells_func(celltypes=None) Callable[[], list[Cell]][source]

Get a function that returns all cells in the simulation.

Return type:

Callable[[], list[Cell]]

get_diffsystem_func(diffsystem=None) Callable[[], DiffusionSystem][source]

Get a function that returns the diffusion system.

Return type:

Callable[[], DiffusionSystem]

render(frames: list[int] | range | None = None, path: str | None = None, camera=False, format: Render = Render.PNG)[source]

Render specific frames of the simulation.

Parameters:
  • frames (list[int] | range | None) – List of frames to render. If None, renders all frames.

  • path (str | None) – Path to save rendered frames. If None, uses default path.

  • camera (bool) – Whether to use camera view (True) or viewport (False).

  • format (Render) – Format to save rendered frames in.

Returns:

True if rendering completed normally, False if it was stopped due to instability

Return type:

bool

render_animation(path=None, end=250, camera=False)[source]

Render the simulation as an animation.

run(end=250)[source]

Run the simulation in the background without updating the 3D Viewport in real time.

Parameters:

end (int) – End frame. Defaults to the last frame of the scene.

Returns:

True if simulation completed normally, False if it was stopped due to instability

Return type:

bool

set_seed(seed)[source]

Set the random seed for the simulation.

setup_world(seed=1)[source]

Set up the Blender scene for the simulation.

toggle_gravity(on)[source]

Toggle gravity in the scene.