goo.cell¶
- class goo.cell.Cell(obj: Object, mat=None)[source]¶
Bases:
BlenderObject
A cell.
Cells are represented in Blender by mesh objects. They can interact with physics by adding Blender modifiers, and the forces that influence its motion is determined by an associated collection.
- Parameters:
obj (Object) – Blender object to be used as the representation of the cell.
- Variables:
celltype (CellType) – The cell type to which the cell belongs.
- COM(local_coords: bool = False) Vector [source]¶
Calculates the center of mass of a cell.
- Parameters:
local_coords (bool) – if True, coordinates are returned in local object space rather than world space.
- Returns:
The vector representing the center of mass of the cell.
- Return type:
Vector
- add_effector(force: Force | ForceCollection)[source]¶
Add a force or a collection of forces that affects this cell.
- Parameters:
force (Force | ForceCollection) – The force or collection of forces to add.
- property adhesion_forces: list[AdhesionForce]¶
Heterotypic adhesion forces of the cell.
- calculate_dist_to_voxel(voxel_loc: Vector) float [source]¶
Calculate the distance from a cell to a voxel.
- Parameters:
voxel_loc (Vector) – The location of the voxel.
- Return type:
float
- property cloth_mod: ClothModifier | None¶
The cloth modifier of the cell if it exists, otherwise None.
- property collision_mod: CollisionModifier | None¶
The collision modifier of the cell if it exists, otherwise None.
- property color: tuple[float, float, float]¶
Color of the cell.
- copy() Cell [source]¶
Copies the cell.
The underlying Blender object, object data, and material if applicable.
Warning
Any settings that use custom collections will not be updated. It is advised that physics modifiers are set up again for the daughter cell after calling copy().
- Returns:
A new cell with copied object and mesh data.
- Return type:
- disable_physics()[source]¶
Disable the physics simulation for the cell.
This function disables the physics simulation for the cell by storing the current modifier settings, removing all modifiers, and disabling any adhesion forces.
- Raises:
RuntimeError – If physics is not enabled.
- divide(division_logic) tuple[Cell, Cell] [source]¶
Cause the cell to divide into two daughter cells.
This function causes the cell to divide into two daughter cells according to the provided division logic. The daughter cells inherit the cell type of the mother cell.
- enable_physics()[source]¶
Enable the physics simulation for the cell.
This function re-enables the physics simulation for the cell by recreating the modifier stack from stored settings, updating the cloth modifier, and enabling any adhesion forces.
- Raises:
RuntimeError – If physics is already enabled.
- get_modifier(type) Modifier | None [source]¶
Retrieves the first modifier of the specified type from the underlying object representation of the cell.
- Parameters:
type – The type of the modifier to search for.
- Returns:
The first modifier of the specified type if found, otherwise None.
- Return type:
Modifier | None
- property homo_adhesion: AdhesionForce¶
Homotypic adhesion force of the cell.
- link_adhesion_force(force: AdhesionForce)[source]¶
Set this cell as the origin of an adhesion force.
- Parameters:
force (AdhesionForce) – The adhesion force which originates from this cell.
- property molecules_conc¶
- move_towards(dir: Vector)[source]¶
Sets the motion force to move the cell in a specified direction.
This function sets the motion force to move the cell in the specified direction. If the cell does not have an associated motion force, it raises a RuntimeError.
- Parameters:
dir (Vector) – The direction in which to set the motion force.
- Raises:
RuntimeError – If the cell does not have an associated motion force.
- property name: str¶
Name of the cell. Also defines the name of related forces and collections of effectors.
- property obj_eval: ID¶
The evaluated object.
Note
See the Blender API Documentation for evaluated_get(depsgraph).
- property physics_enabled: bool¶
Whether physics is enabled for this cell.
- property pressure: float¶
Internal pressure of the cell.
- recolor(color: tuple[float, float, float])[source]¶
Recolors the material of the cell.
This function changes the diffuse color of the cell’s material to the specified color while preserving the alpha value. If the material uses nodes, it also updates the ‘Base Color’ input of any nodes that have it.
- Parameters:
color (tuple[float, float, float]) – A tuple (r, g, b) representing the new color to apply.
- remesh(voxel_size: float = 0.55, smooth: bool = False)[source]¶
Remesh the underlying mesh representation of the cell.
Remeshing is done using the built-in voxel_remesh().
- Parameters:
voxel_size (float) – The resolution used for the remesher (smaller means more
smooth (polygons).) – If true, the final cell faces will appear
smooth.
- remove_effector(force: Force | ForceCollection)[source]¶
Remove a force or a collection of forces that affects this cell.
- Parameters:
force (Force | ForceCollection) – The force or collection of forces to remove.
- setup_physics(physics_constructor: PhysicsConstructor)[source]¶
Set up the physics properties for the cell.
This function initializes the physics properties of the cell using the given physics constructor. It then marks the physics as enabled.
- Parameters:
physics_constructor (PhysicsConstructor) – A function or callable that sets up the physics properties for the object.
- property stiffness: float¶
Stiffness of the membrane of the cell.
- vertices(local_coords: bool = False) list[Vector] [source]¶
Returns the vertices of the mesh representation of the cell.
- Parameters:
local_coords (bool) – if True, coordinates are returned in local object space
space. (rather than world)
- Returns:
List of coordinates of vertices.
- Return type:
list[Vector]
- class goo.cell.CellType(name: str, physics_enabled: bool = True)[source]¶
Bases:
object
A cell type.
Cell types are represented in Blender by collection. Cells of the same cell type interact through homotypic adhesion forces, and interact with cells of different cell types through heterotypic adhesion forces. Cell types have default mesh creation settings (including color) and default physics settings (including cloth, collision, homotypic adhesion forces, and motion forces).
- Parameters:
name (str) – The name of the cell type.
physics_enabled (bool) – Whether cells of this cell type are responsive to physics.
- Variables:
homo_adhesion_strength (int) – Default homotypic adhesion strength between cells of this type.
motion_strength (int) – Default motion strength of cells of this type.
- add_cell(cell: Cell)[source]¶
Add a cell to the cell type, activating its physics and constructing appropriate forces.
This method sets the cell type of the added cell to this cell type and activates physics for the cell. It constructs and adds homotypic adhesion forces, heterotypic adhesion forces, and motion forces defined for this cell type.
- Parameters:
cell (Cell) – The cell to add to the cell type.
- color = (0.007, 0.021, 0.3)¶
- create_cell(name: str, loc: tuple, color: tuple = None, physics_constructor: PhysicsConstructor = None, physics_on: bool = True, **mesh_kwargs) Cell [source]¶
Creates a new cell, then adds it to this cell type.
- Parameters:
name (str) – The name of the cell.
loc (tuple) – The location of the cell.
color (tuple) – The color of the cell.
physics_constructor (PhysicsConstructor) – A generator of physics properties of the cell.
physics_on (bool) – Whether to enable physics for the cell.
**mesh_kwargs – keyword arguments passed to the Blender mesh generator function.
- Returns:
The newly created cell.
- Return type:
Note
create_cell does not directly activate physics, which is handled by the add_cell function. This is significant for division, which will use the default CellType settings to set up cell physics, rather than any custom settings of the dividing cell.
- property name: str¶
Name of the cell type.
- set_hetero_adhesion(other_celltype: CellType, strength: float)[source]¶
Set the default strength of heterotypic adhesion forces between this cell type and another.
- Parameters:
other_celltype (CellType) – The other cell type in relation to which heterotypic adhesion forces will be defined.
strength (float) – The force of the adhesion forces.
- class goo.cell.SimpleType(name: str, physics_enabled: bool = True)[source]¶
Bases:
CellType
A cell type that is reduced in complexity for faster rendering.
- Parameters:
name (str)
physics_enabled (bool)
- color = None¶
- physics_constructor = <goo.utils.PhysicsConstructor object>¶
- Parameters:
obj (Object)
- class goo.cell.YolkType(name: str, physics_enabled: bool = True)[source]¶
Bases:
CellType
A larger cell type used for modeling embryonic yolks.
- Parameters:
name (str)
physics_enabled (bool)
- color = (0.64, 0.64, 0.64)¶
- mesh_kwargs = {'size': 10, 'subdivisions': 4}¶
- physics_constructor = <goo.utils.PhysicsConstructor object>¶
- Parameters:
obj (Object)
- goo.cell.create_cell(name: str, loc: tuple, color: tuple = None, physics_constructor: PhysicsConstructor = None, physics_on: bool = True, **kwargs) Cell [source]¶
Creates a new cell using the default cell type.
- Parameters:
name (str) – The name of the cell.
loc (tuple) – The location of the cell.
color (tuple) – The color of the cell.
physics_constructor (PhysicsConstructor) – A generator of physics properties of the cell.
physics_on (bool) – Whether to enable physics for the cell.
**kwargs – keyword arguments passed to the Blender mesh generator function.
- Returns:
The newly created cell.
- Return type: