WaterSpaceWarp : SpacewarpObject

WaterSpaceWarp - superclass: SpacewarpObject; super-superclass:Node - classID: #(1192955369, 72894388)

Description:

You can use the WaterSpaceWarp to simulate the behavior of a body of liquid. You can specify a size for the water, and physical properties such as density, wave speed, and viscosity.

Constructors:

WaterSpaceWarp ...

rctWaterWSMObject ...

Properties:

.sizeX (Size_X) : float

.sizeY (Size_Y) : float

Get/Set the dimensions for the water

.subdivisionsX (Subdivisions_X) : integer

.subdivisionsY (Subdivisions_Y) : integer

Get/Set the subdivisions for the water

.useLandscape (Landscape) : boolean

When set to true, the landscape rigid body will be considered.

.landscape : node

Get/Set the landscape rigid body.

.waveSpeed (Wave_Speed) : float

Get/Set the speed at which wave crests propagate across the surface of the water.

.minRipple (Min_Ripple) : float

.maxRipple (Max_Ripple) : float

Get/Set the bounds on the size of the waves generated in the water.

.density : float

Get/Set the density of the liquid. This determines which objects will sink into the water, and at what height objects of a lesser density will float. The default density is that of real-world water: 1.0.

.viscosity : float

Get/Set the resistance to flow, in other words how difficult it is for objects to move through the liquid. A large value means that the motion of objects through the water is highly damped.

.showText (Show_Text) : boolean

When set to true (default), a label "Water" will appear beside the space warp in the viewport.

.useCurrentState (Use_Current_State) : boolean

.disabled : boolean

When set to true, the space warp will not be considered by the simulation.

.useDepth (Use_Depth) : boolean

When set to true, the depth value will be considered by the simulation.

.depth (Density) : float

Get/Set the depth of the water. Buoyancy is only applied to objects that are inside the water's depth.

Interfaces:

Interface: rctWaterInterface

Methods:

<float>getNumKeyframes()

Returns the number of keyframes.

<time by value array>getKeyframeTimes()

Returns an array of keyframe times.

<float by value array>getWaterHeightsAtTime <time>time

Returns an array of height values at the specified time.

<boolean>setWaterHeightsAtTime <time>time <&float array>heights

heights is In and Out parameter

Sets the height values at the specified time to the values supplied with the by-reference array.

<void>clearStoredKeyframes()

Clears the stored keyframes.

<integer>getPointIndex <integer>xIndex <integer>yIndex

Returns the index of the point at row xIndex and column yIndex.

Example:

w = $Water01 --get an existing WaterSpaceWarp

w.clearStoredKeyframes() --clear any existing keyframes

for t = 0 to 100 by 2 do --animate from frame 0 to 100 with step 2

(

heights = #() --init. an array to store heights

for x = 0 to w.subdivisionsX do --loop through X subdivisions

(

for y = 0 to w.subdivisionsY do --loop through Y subdivisions

(

--get the index of the vertex at the specified X and Y subdivision:

index = w.getPointIndex x y

--calculate a height value based on sine of time and X position:

newheight = 10 * sin ((10.0*t+x*20.0))

append heights newheight --add height to the array

)--end y loop

)--end x loop 

w.setWaterHeightsAtTime t &heights --assign heights at current time

sliderTime = t --watch the process in viewport

)--end t loop

 

w.getNumKeyframes() --show the number of keyframes

print ( w.getWaterHeightsAtTime 0 ) --print the heights on frame 0

See also

MAXScript Extensions for Reactor