Configuring a Visualisation
To create a FLAME GPU visualisation, you must configure and activate the visualisation by calling getVisualisation()
.
// Create CUDASimulation as normal
flamegpu::CUDASimulation cudaSimulation(model);
// Only enable vis if visualisation support is present
#ifdef FLAMEGPU_VISUALISATION
// Configure the visualisation
flamegpu::visualiser::ModelVis visualisation = cudaSimulation.getVisualisation();
...
// Activate the visualisation
visualisation.activate();
#endif
# Create CUDASimulation as normal
cudaSimulation = pyflamegpu.CUDASimulation(model);
# Only enable vis if visualisation support is present
if pyflamegpu.VISUALISATION:
# Configure the visualisation
visualisation = cudaSimulation.getVisualisation();
...
# Activate the visualisation
visualisation.activate();
Visualisation Options
There are many options available within ModelVis
to control how the visualisation works.
The most important of these settings are presented below:
Method |
Arguments |
Description |
---|---|---|
|
Sets the string displayed in the visualisation window’s title bar. (Defaults to the model name) |
|
|
Sets the initial dimensions of the visualisation window. (Defaults to 1280x720) |
|
|
Sets the background colour of the visualisation. (Defaults to black [0,0,0]) |
|
|
Sets the initial location for the visualisation’s ‘camera’. (Defaults to the [1.5, 1.5, 1.5]) |
|
|
Sets the initial target that the visualisation’s ‘camera’ faces. (Defaults to the origin [0,0,0]) |
|
|
Sets the initial roll angle of the camera in radians. (Defaults to 0) |
|
|
Sets the speed of camera movement, in units travelled per millisecond. (Defaults to 0.05) |
|
|
Sets a limit for the speed at which the model being visualised executes. The visualisation executes in a separate thread, so this will not affect the framerate. (Defaults to 0, which disables the limit) |
|
|
If true, the model begins in a paused state and must be unpaused to continue execution (Defaults to false) |
|
|
If true, the visualisation starts in Orthographic projection mode (Defaults to false) |
|
|
Sets the initial orthographic zoom level. This has no effect if orthographic projection mode is not enabled. |
More advanced settings are also available, full documentation can be found in the ModelVis
API documentation.
Visualising After Simulation Exit
By default, when the CUDASimulation
returns from the call to simulate()
after the model has completed, the program will continue and likely exit.
If you would prefer to prevent this, and keep the visualisation open, so the final state of the model can be explored, the visualisation can be joined to prevent program execution continuing until the visualisation window has been closed.
// Execute simulation
cudaSimulation.simulate();
// Join the visualisation after simulation returns to prevent the window closing
#ifdef FLAMEGPU_VISUALISATION
visualisation.join();
#endif
# Execute simulation
cudaSimulation.simulate();
# Join the visualisation after simulation returns to prevent the window closing
if pyflamegpu.VISUALISATION:
visualisation.join();