WindSource

July 25, 2023 ยท View on GitHub

from tdw.obi_data.wind_source import WindSource

A source of wind: An invisible Obi fluid that can dynamically adjust its rotation, speed, etc.


Fields

  • wind_id The ID of this wind source.

Functions

__init__

WindSource(wind_id, position, rotation)

WindSource(wind_id, position, rotation, capacity=2000, speed=1, lifespan=0.5, smoothing=0.5, resolution=1, vorticity=0.5, random_velocity=0.125, minimum_pool_size=0.5, visible=False, emitter_radius=0.25, solver_id=0)

ParameterTypeDefaultDescription
wind_idintThe ID of this wind source.
positionPOSITIONThe position of the wind source.
rotationROTATIONThe rotation of the wind in Euler angles.
capacityint2000The maximum amount of emitted particles.
speedfloat1The emission speed in meters per second.
lifespanfloat0.5The particle lifespan in seconds. A higher lifespan will result in "gustier" wind because particles will linger in the scene and prevent new particles from being created.
smoothingfloat0.5A percentage of the particle radius used to define the radius of the zone around each particle when calculating fluid density. A lower value will create a more scattered fluid.
resolutionfloat1The size and amount of particles in 1 cubic meter. A value of 1 will use 1000 particles per cubic meter. For larger wind sources, consider lowering this value.
vorticityfloat0.5Amount of vorticity confinement, it will contribute to maintain vortical details in the fluid. This value should always be between approximately 0 and 0.5. This will increase turbulence, although the difference is relatively minor.
random_velocityfloat0.125The maximum random speed in meters per second that can be applied to a particle. This will increase turbulence.
minimum_pool_sizefloat0.5The minimum amount of inactive particles available before the emitter is allowed to resume emission.
visibleboolFalseIf True, make the fluid visible. This is useful for debugging.
emitter_radiusfloat0.25The radius of the wind source.
solver_idint0The ID of the Obi solver.

set_speed

self.set_speed(speed, ds)

Set a target wind speed.

ParameterTypeDefaultDescription
speedfloatThe target speed in meters per second.
dsfloatThe current speed will increase/decrease by this delta per communicate() call until it is at the target.

get_speed

self.get_speed()

Returns: The current wind speed.

is_accelerating

self.is_accelerating()

Returns: True if the speed is accelerating or decelerating.

set_gustiness

self.set_gustiness(capacity, dc, lifespan, dl)

Set the "gustiness" of the wind i.e. the duration of pauses between emitted particles.

This tends to "override" the wind speed, which merely controls the velocity of particles in the scene.

The resulting gusts will always be periodic. If you want gusts to be more random, call this function with different values every n communicate() calls.

ParameterTypeDefaultDescription
capacityintThe target maximum number of particles. A higher particle count will create a steadier stream of particles but can significantly impact simulation performance.
dcintThe current capacity will increase/decrease by this delta per communicate() call until it is at the target.
lifespanfloatThe particle lifespan in seconds. A higher lifespan will result in "gustier" wind because particles will linger in the scene and prevent new particles from being created.
dlfloatThe current lifespan will increase/decrease by this delta per communicate() call until it is at the target.

is_gusting

self.is_gusting()

Returns: Tuple: True if we're at the target capacity, True if we're at the target lifespan.

set_spread

self.set_spread(smoothing, ds, resolution, dr)

Set how far the wind fluid can spread.

ParameterTypeDefaultDescription
smoothingfloatA percentage of the particle radius used to define the radius of the zone around each particle when calculating fluid density. A lower value will create a more scattered fluid.
dsfloatThe current smoothing will increase/decrease by this delta per communicate() call until it is at the target.
resolutionfloatThe size and amount of particles in 1 cubic meter. A value of 1 will use 1000 particles per cubic meter. For larger wind sources, consider lowering this value.
drfloatThe current resolution will increase/decrease by this delta per communicate() call until it is at the target.

is_spreading

self.is_spreading()

Returns: Tuple: True if the smoothing value is at the target, True if the resolution value is at the target.

set_turbulence

self.set_turbulence(vorticity, dv, random_velocity, dr)

Set the wind turbulence.

ParameterTypeDefaultDescription
vorticityfloatAmount of vorticity confinement, it will contribute to maintain vortical details in the fluid. This value should always be between approximately 0 and 0.5. This will increase turbulence, although the difference is relatively minor.
dvfloatThe current vorticity will increase/decrease by this delta per communicate() call until it is at the target.
random_velocityfloatThe maximum random speed in meters per second that can be applied to a particle. This will increase turbulence.
drfloatThe current random velocity will increase/decrease by this delta per communicate() call until it is at the target.

is_turbulating

self.is_turbulating()

Returns: Tuple: True if the vorticity value is at the target, True if the random velocity value is at the target.

move_to

self.move_to(position, dp)

Start moving to the target position.

ParameterTypeDefaultDescription
positionPOSITIONThe new position.
dpfloatMove this many meters per communicate() call.

get_position

self.get_position()

Returns: The position of the wind source.

is_moving

self.is_moving()

Returns: True if the wind source is moving.

rotate_by

self.rotate_by(angle, da)

self.rotate_by(angle, da, axis="yaw")

Rotate the wind fluid emitter with an angle and an axis.

ParameterTypeDefaultDescription
anglefloatThe target angle in degrees.
dafloatIncrement angle by this many degrees per communicate() call.
axisstr"yaw"The axis of rotation: "pitch", "yaw", or "roll".

get_rotation

self.get_rotation()

Returns: Tuple: The angle of rotation in degrees, the axis of rotation.

is_rotating

self.is_rotating()

Returns: True if the wind source is rotating.

update

self.update()

Don't call this in your controller. This is called internally by the Obi add-on.

Update the wind. Create the fluid actor if it doesn't exist. Lerp all values that need lerping.

Returns: A list of commands.