Class ModelVis

Class Documentation

class ModelVis

This provides an interface for managing the render options for a specific CUDASimulation

Public Functions

explicit ModelVis(std::shared_ptr<ModelVisData> data, bool _isSWIG)
~ModelVis() = default

Default destructor behaviour Defined explicitly, so that header include does not require including FLAMEGPU_Visualisation for std::unique_ptr destruction.

void setAutoPalette(const Palette &palette)

Sets the palette to automatically give color to agent added to the model This can be overriden at an agent level or disabled Similarly, individual agent-states can have their colour overriden

void clearAutoPalette()

Disables the auto-palette, subsequently created AgentVis/AgentStateVis will not take colors from it

Note

AgentVis/AgentStateVis which have already sampled a color will not lose their existing color

AgentVis addAgent(const std::string &agent_name)

Enables visualisation of the named agent and returns the configuration handler

AgentVis Agent(const std::string &agent_name)

Returns the configuration handler if the agent has been marked for visualisation

void setWindowTitle(const std::string &title)

Set the title for the visualisation window This value defaults to the model’s name

Parameters:

title – The title for the viusalisation window

void setWindowDimensions(const unsigned int &width, const unsigned int &height)

Set the dimensions of the visualisation window This value defaults to 1280x720 (720p)

Parameters:
  • width – Window width

  • height – Window height

void setClearColor(const float &red, const float &green, const float &blue)

Set the clear color (the background color) of the visualisation This value defaults to black (0,0,0)

Parameters:
  • red – Red color value 0.0f-1.0f

  • green – Green color value 0.0f-1.0f

  • blue – Blue color value 0.0f-1.0f

void setFPSVisible(const bool &showFPS)

Sets the FPS overlay as visible or not This value defaults to true

Note

The visualisation executes in an independent thread to the simulation, so the FPS does not correspond to the speed of the simulation’s execution

Parameters:

showFPS – True if the FPS should be shown

void setFPSColor(const float &red, const float &green, const float &blue)

Sets the color of the FPS overlay’s text This value defaults to white (1,1,1) This may be useful if you have changed the clear color

Parameters:
  • red – Red color value 0.0f-1.0f

  • green – Green color value 0.0f-1.0f

  • blue – Blue color value 0.0f-1.0f

void setInitialCameraLocation(const float &x, const float &y, const float &z)

The location at which the camera of the visualisation ‘camera’ begins This value defaults to (1.5, 1.5, 1.5)

Parameters:
  • x – The x coordinate

  • y – The y coordinate

  • z – The z coordinate

void setInitialCameraTarget(const float &x, const float &y, const float &z)

The location at which the camera of the visualisation initially looks towards This is used with the camera location to derive the direction This value defaults to (0,0,0)

Parameters:
  • x – The x coordinate

  • y – The y coordinate

  • z – The z coordinate

void setCameraSpeed(const float &speed, const float &shiftMultiplier = 5.0f)

The speed of camera movement, in units travelled per millisecond This value defaults to (0.05, 5.0)

Parameters:
  • speed – The camera speed

  • shiftMultiplier – The multiplier applied to the speed when shift is pressed

void setViewClips(const float &nearClip, const float &farClip)

Sets the near and far clipping planes of the view frustum This value defaults to (0.05 5000.0)

Note

This is for advanced configuration of the visualisation and the default values likely suffice

void setOrthographic(const bool &isOrtho)

Sets whether the visualisation should use an orthographic (or perspective) projection This value defaults to false

Orthographic projection can be toggled during the visualisation by pressing ‘F9’ Orthographic projection is used for 2D models, whereby depth should not affect scale

Parameters:

isOrtho – True if the visualisation should use an orthographic projection

void setOrthographicZoomModifier(const float &zoomMod)

Sets initial zoom modifier for the orthographic projection This value defaults to 1.0 This setting has no impact on perspective projection mode This value must be greater than 0.001, which is the maximum/closest zoom supported.

Parameters:

zoomMod – The initial zoom modifier

void setStepVisible(const bool &showStep)

Sets the Step count overlay as visible or not This value defaults to true

Note

This uses the FPSColor

Parameters:

showStep – True if the count should be shown

void setSimulationSpeed(const unsigned int &stepsPerSecond)

Sets a limit on the rate of simulation A value of 0 leaves the rate unlimited This value defaults to 0

Parameters:

stepsPerSecond – The number of simulation steps to execute per second

void setBeginPaused(const bool &beginPaused)

Sets whether the simulation should begin in a paused state or not This value defaults to false The simulation can be resumed (or re-paused) by pressing ‘p’

Parameters:

beginPaused – True if the simulation should begin paused

StaticModelVis newStaticModel(const std::string &modelPath, const std::string &texturePath = "")

Adds a static model to the visualisation

Parameters:
  • modelPath – Path of the model on disk

  • texturePath – Optional path to a texture fore the model on disk

LineVis newLineSketch(float r, float g, float b, float a = 1.0f)

Create a new sketch constructed from individual line segments to the visualisation

Parameters:
  • r – Initial color’s red component

  • g – Initial color’s green component

  • b – Initial color’s blue component

  • a – Initial color’s alpha component

LineVis newPolylineSketch(float r, float g, float b, float a = 1.0f)

Create a new sketch constructed from a single line of connected vertices to the visualisation

Parameters:
  • r – Initial color’s red component

  • g – Initial color’s green component

  • b – Initial color’s blue component

  • a – Initial color’s alpha component

PanelVis newUIPanel(const std::string &panel_title)

Add a customisable user interface panel to the visualisation

Each panel can be moved around the screen/minimised with custom elements representing environment properties added

Parameters:

panel_title – The string that will be visible in the title of the panel

void activate()

Sets the visualisation running in a background thread

void deactivate()

Kills the background thread Does nothing visualisation is not running

void join()

Blocks the main thread until the background visualisation thread has returned Does nothing visualisation is not running

Note

It is expected that you will close the visualiser window with the cross in the corner if join is called

bool isRunning() const

Returns whether the background thread is active or not