goo.cell¶
- class goo.cell.Cell[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 – Blender object to be used as the representation of the cell.
- Variables:
celltype (CellType) – The cell type to which the cell belongs.
homo_adhesion_strength (float) – The homotypic adhesion strength for this cell. If set, overrides the cell type’s default adhesion strength.
- COM(local_coords: bool = False) Vector [source]¶
Calculates the center of mass of the 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.
- add_force(force: Force)[source]¶
Add a force that affects this cell.
- Parameters:
force (Force) – The force to add.
- area() float [source]¶
Calculates the surface area of the cell.
- Returns:
The surface area of the cell.
- Return type:
float
- aspect_ratio() float [source]¶
Calculates the aspect ratio of the cell.
The aspect ratio is the ratio of the major axis to the minor axis of the cell.
- Returns:
The aspect ration value for a cell.
- 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
- compactness() float [source]¶
Calculates the compactness of the cell.
Compactness provides a measure of how efficiently the volume is enclosed by the surface area, calculated as .
- Returns:
The compactness value for the cell.
- Return type:
float
- 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.
Note
If physics is already disabled, this function will do nothing.
- 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.
- property gene_concs¶
- 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_strength: float¶
Get the homotypic adhesion strength for this cell. If not set, returns the cell type’s default adhesion strength. If cell type is not set, returns None.
- is_collapsed() bool [source]¶
Checks if the cell has collapsed or is in an invalid state.
A cell is considered collapsed if: 1. It has no vertices 2. Its volume is zero or negative 3. Its mesh is invalid
- Returns:
True if the cell is collapsed, False otherwise
- Return type:
bool
- link_gene_to_property(gene: Gene, property, gscale=(0, 1), pscale=(0, 1))[source]¶
Link gene to property, so that changes in the gene levels will cause changes in the physical property.
- Parameters:
gene (Gene)
- link_molecule_to_property(molecule: Molecule, property)[source]¶
Link molecule to property, so that changes in the extracellular concentrations of the molecule will cause changes in the physical property.
- Parameters:
molecule (Molecule)
- property mat¶
- property molecule_concs¶
Get the concentrations of the molecules around the cell radius.
- move(direction: tuple | None = None, strength=None)[source]¶
Set move location. If direction is not specified, then use previous direction as reference.
- Parameters:
direction (tuple | None)
- property name¶
- property obj_eval: ID¶
The evaluated object.
Note
See the Blender API Documentation for evaluated_get(depsgraph).
- property pressure: float¶
Internal pressure of the cell.
- recenter(origin=True, forces=True)[source]¶
Recenter cell origin to center of mass of cell, and center forces to that same origin.
- recolor(color: tuple[float, float, float]) None [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.
- Return type:
None
- remesh(voxel_size: float = 0.7, smooth: bool = True) None [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.
- Return type:
None
Note
The voxel_remesh() operator is used to remesh the cell. This operator is faster than using the remesh modifier, but it can only be used on objects with a mesh data type.
- 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.
- sav_ratio() float [source]¶
Calculates the surface area: volume (SA:V) ratio of the cell.
- Returns:
V ratio of the cell.
- Return type:
The SA
- sphericity() float [source]¶
Calculates the sphericity of the cell.
The sphericity is a measure of how closely a cell resembles a perfect sphere. It is calculated as the ratio of the surface area of a sphere with the same volume as the cell to the surface area of the cell.
- Returns:
The sphericity value for the cell.
- Return type:
float
- step_grn(dt=1)[source]¶
Calculate and update the gene concentrations of the gene regulatory network after 1 time step.
- property stiffness: float¶
Stiffness of the membrane of the cell.
- update_physics_with_molecules(mol: Molecule)[source]¶
Step the extracellular molecules of the cell.
- Parameters:
mol (Molecule)
- 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]
- property viscosity¶
- volume() float [source]¶
Calculates the volume of the cell.
- Returns:
The signed volume of the cell (with physics evaluated).
- Return type:
float
- property voxel_size¶
- class goo.cell.CellPattern[source]¶
Bases:
object
Builders of different cell parts. The CellType class takes these patterns in order to create new cells.
- build_forces(homo_adhesion_strength: int, homo_adhesion_collection: ForceCollection, motion_strength: int, hetero_adhesion_strengths: dict[CellType, int], hetero_adhesion_collections: dict[CellType, tuple[ForceCollection]])[source]¶
- Parameters:
homo_adhesion_strength (int)
homo_adhesion_collection (ForceCollection)
motion_strength (int)
hetero_adhesion_strengths (dict[CellType, int])
hetero_adhesion_collections (dict[CellType, tuple[ForceCollection]])
- build_growth_controller(growth_type: Growth, growth_rate: float = 1, target_volume=30)[source]¶
- Parameters:
growth_type (Growth)
growth_rate (float)
- build_physics(physics_constructor=None, viscosity: float = 25)[source]¶
- Parameters:
viscosity (float)
- color: ClassVar[tuple | None] = None¶
- initial_pressure: ClassVar[float | None] = None¶
- mesh_kwargs: ClassVar[dict] = {}¶
- physics_constructor: ClassVar[PhysicsConstructor | None] = None¶
- class goo.cell.CellType(name, pattern='standard', target_volume=30, homo_adhesion_strength=2000, hetero_adhesion_strengths={}, motion_strength=0, **kwargs)[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 – The name of the cell type.
physics_enabled – 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.
- create_cell(name, loc, voxel_size: float = 0.7, viscosity: float = 25, color: tuple | None = None, physics_enabled: bool = True, physics_constructor: PhysicsConstructor = None, growth_enabled: bool = True, growth_type: Growth = Growth.LINEAR, growth_rate: float = 1, target_volume: float | None = None, genes_enabled: bool = True, circuits: list[Circuit] | None = None, genes: dict[str, float] = {}, obj: Object = None, **mesh_kwargs)[source]¶
- Parameters:
voxel_size (float)
viscosity (float)
color (tuple | None)
physics_enabled (bool)
physics_constructor (PhysicsConstructor)
growth_enabled (bool)
growth_type (Growth)
growth_rate (float)
target_volume (float | None)
genes_enabled (bool)
circuits (list[Circuit] | None)
genes (dict[str, float])
obj (Object)
- property diffsys¶
Get the diffusion system for this cell type.
- link_molecule_to_property(molecule: Molecule, property)[source]¶
Link molecule to property for all cells of this type.
This will set up the link for all existing cells and any new cells created from this cell type.
- Parameters:
molecule (Molecule) – The molecule to link
property – The property to link the molecule to
- class goo.cell.PropertyUpdater(getter, transformer, setter)[source]¶
Bases:
object
A class that updates a property of a cell based on a gene value.
- Parameters:
getter – The getter function.
transformer – The transformer function.
setter – The setter function.
- Variables:
getter – A function that retrieves the gene value from a diffusion system.
transformer – A function that transforms the gene value into a property value.
setter – A function that sets the property value of a cell.
- class goo.cell.SimplePattern[source]¶
Bases:
CellPattern
A cell type that is reduced in complexity for faster rendering.
- color: ClassVar[tuple[float, float, float]] = (0.5, 0.5, 0.5)¶
- mesh_kwargs: ClassVar[dict] = {}¶
- physics_constructor: ClassVar[PhysicsConstructor] = <goo.utils.PhysicsConstructor object>¶
- Parameters:
bobj (BlenderObject)
- class goo.cell.StandardPattern[source]¶
Bases:
CellPattern
- color: ClassVar[tuple[float, float, float]] = (0.007, 0.021, 0.3)¶
- initial_pressure: ClassVar[float] = 12¶
- mesh_kwargs: ClassVar[dict] = {}¶
- physics_constructor: ClassVar[PhysicsConstructor] = <goo.utils.PhysicsConstructor object>¶
- Parameters:
bobj (BlenderObject)
- class goo.cell.YolkPattern[source]¶
Bases:
CellPattern
A larger cell type used for modeling embryonic yolks.
- color: ClassVar[tuple[float, float, float]] = (0.64, 0.64, 0.64)¶
- mesh_kwargs: ClassVar[dict] = {'size': 10, 'subdivisions': 4}¶
- physics_constructor: ClassVar[PhysicsConstructor] = <goo.utils.PhysicsConstructor object>¶
- Parameters:
bobj (BlenderObject)
- goo.cell.create_direction_updater(cell: Cell, metabolite: Gene | Molecule)[source]¶
Create a direction updater that links a gene or molecule to the direction of a cell.
- goo.cell.create_motion_strength_updater(cell: Cell, metabolite: Gene | Molecule, gscale=(0.5, 2), pscale=(0, 1))[source]¶
Create a motion strength updater that links a gene to the motion strength of a cell.
- goo.cell.create_scalar_updater(cell: Cell, metabolite: Gene | Molecule, property, relationship='linear', gscale=(0, 1), pscale=(0, 1))[source]¶
Create a scalar updater that links a gene to a scalar property of a cell.
- Parameters:
cell (Cell) – The cell object.
gene – The gene that is linked to the property.
property – The property that is linked to the gene.
relationship – The relationship between the gene and the property.
gscale – The scale of the gene values.
pscale – The scale of the property values.
- Returns:
A PropertyUpdater object that can be used to update the property.