General

Callback Functions

Simulation core and result access functions

Global Variables

General

During the simulation process the user is allowed to directly access the simulator's content using functions exported by the plugin. These functions can't be called at any point, they will work properly only when the simulator is in the appropriate internal state. The moments of time when the content can be manipulated properly are signaled by calling several callback functions, and the user is allowed to access the simulator's content only inside them. Every single Phoenix FD object has its own script code that is kept in the scene file. When the simulation starts the script is compiled and its callback function overrides the callback functions of any previous simulation. During the simulation the user is allowed to change the script, by executing the "Evaluate all" command from the File menu of the script editor. If a shared script for all simulator instances is desired, the user has to delete the individual scripts for each simulator and deliver the callback functions as an ordinary MAXScript file.

Callback functions

Function Description
OnSimulationBegin Called after all the initialization of the simulator is done and before first execution.
OnSimulationStep Called before each simulation step, after the interaction with the scene.
OnSimulationEnd Called after the end of the simulation just before destroying the simulation core.
OnNewFrame Called after each frame export.

 

Simulation core and result access functions

Each of the simulation channels (temperature, velocity, smoke etc.) exists in two instances - in the simulation core and in the simulation result. The functions in this section can access both the simulation core and result. If the first argument passed to the function specifies a Phoenix FD node, then the function accesses the simulation result. If there is no explicit Phoenix FD node specified, the function accesses the simulation core. In this case the target node is delivered internally. All the functions are exported as global functions beginning with "A_".

 

It should be noted that the simulation core exists only during the simulation and can be accessed only in the Callback functions.

 

 

 

Functions Description

A_SetSystem

Parameters:

system:<integer>

Available options are:

0 - Object space

1 - World space

2 - Grid space

Return value:

none

Specifies which coordinate system to be used...

A_Inject

Parameters:

where:<point3>

amount:<float>

[temperature:<float>]

[smoke:<float>]

[velocity:<point3>]

[UVW:<point3>]

Return value :

none

 

 

 

Injects fluid in given point. Using this function the user can create its own procedural sources. The result of the function CAN NOT be achieved by calling one or more A_SetX functions, because they do not affect the quantity of the fluid, but only the parameters carried by the fluid. The injection of fluid in some point causes changes in the content only of the nearest 8 cells, but produces an outgoing flow in the entire grid. Nevertheless the function is not slower than the ordinary A_SetX function, because the outgoing flow appears later, when the simulation is executed. If A_GetV function is executed immediately after A_Inject in some near point, the velocity will not be changed.

A_SetV

Parameters:

x:<integer>

y:<integer>

z:<integer>

velocity:<point3>

Return value :

none

Sets the velocity of a cell

A_SetUVW

Parameters:

x:<integer>

y:<integer>

z:<integer>

UVW:<point3>

Return value :

none

Sets the UVW of a cell

A_SetT

Parameters:

x:<integer>

y:<integer>

z:<integer>

temperature:<float>

Return value :

none

Sets the Temperature of a cell

A_SetSm

Parameters:

x:<integer>

y:<integer>

z:<integer>

smoke:<float>

Return value :

none

Sets the Smoke of a cell

A_SetFl

Parameters:

x:<integer>

y:<integer>

z:<integer>

fuel:<float>

Return value :

none

Sets the Fuel of a cell

A_GetFl

Parameters

where:<Point3>

Return Value:

<float>

Gets the Fuel in a given point

A_GetV

Parameters

where:<Point3>

Return Value:

<point3>

Gets the Velocity in a given point

A_GetUVW

Parameters

where:<Point3>

Return Value:

<point3>

Gets the UVW in a given point

A_GetT

Parameters

where:<Point3>

Return Value:

<float>

Gets the Temperature in a given point

A_GetSm

Parameters

where:<Point3>

Return Value:

<float>

Gets the Smoke value

A_StartSim

Parameters

node:<Simulator>

[cache: <String>]

[startframe: <integer>]

Starts the simulation

A_StopSim

Parameters

node:<Simulator>

Stops the simulation

A_Wait

Parameters

node:<Simulator>

This function holds the execution of the script until the specified simulator has finished running. Usually this function is used along A_StartSim when the user wants to run certain actions after the simulation is finished. Warning - use this function extremely carefully because it does not block the GUI of 3ds Max.

A_CreateParticle

Parameters

Particle group:<string>

where:<Point3>

[Radius:<float>]

[Velocity:<Point3>]

Return Value:

none

Creates particle in given position with given properties.

A_Freeze

Parameters:

x:<integer>

y:<integer>

z:<integer>

 

Freezes given cell. The frozen cell act as a solid object

A_Unfreeze

Parameters:

x:<integer>

y:<integer>

z:<integer>

Unfreeze given cell. Keep in mind that the simulator counts the freezing and you have to execute the same count of unfreezing operation to successfully unfreeze a cell

 

Global Variables

The following global variables are initialized before entry in the callback functions:

 

Variable Description
this:<simulator> Points to the simulator that calls the callback function
t:<float> The simulator's internal time
dt:<float> The simulator's internal step