Project Chrono: chrono::opengl::ChVisualSystemOpenGL Class Reference

Public Member Functions | Static Public Member Functions | Friends | List of all members
chrono::opengl::ChVisualSystemOpenGL Class Reference

## Description

OpenGL-based Chrono run-time visualization system.

`#include <ChVisualSystemOpenGL.h>`

Inheritance diagram for chrono::opengl::ChVisualSystemOpenGL:
[legend]
Collaboration diagram for chrono::opengl::ChVisualSystemOpenGL:
[legend]

## Public Member Functions
void | SetWindowSize (unsigned int width, unsigned int height)
| Set the window size (default 640x480).
void | SetWindowTitle (const std::string &win_title)
| Set the window title (default "").
void | SetCameraVertical (CameraVerticalDir vert)
| Set camera vertical direction (default CameraVerticalDir::Z).
void | SetCameraVertical (const ChVector3d &up)
| Set camera vertical direction (default (0,0,1)).
void | SetCameraProperties (float scale=0.5f, float near_clip_dist=0.1f, float far_clip_dist=1000.0f)
| Set camera scale and clip distances.
void | SetRenderMode (RenderMode mode)
| Set render mode for solid objects (default: SOLID).
void | SetParticleRenderMode (RenderMode mode, float radius)
| Set render mode for particle systems (default: POINTS) and size.
virtual void | AttachSystem (ChSystem *sys) override
| Attach a Chrono system to the run-time visualization system.
void | AttachStatsRenderer (std::shared_ptr< ChOpenGLStats > renderer)
| Attach a user-defined text renderer for stats overlay.
void | EnableStats (bool state)
| Enable/disable stats overlay display (default: true).
void | SetVerbose (bool verbose)
| Enable/disable OpenGL information terminal output during initialization (default: true).
virtual void | Initialize () override
| Initialize the visualization system.
virtual int | AddCamera (const ChVector3d &pos, ChVector3d targ=VNULL) override
| Add a camera to the 3d scene.
virtual void | SetCameraPosition (int id, const ChVector3d &pos) override
| Set the location of the specified camera.
virtual void | SetCameraTarget (int id, const ChVector3d &target) override
| Set the target (look-at) point of the specified camera.
virtual void | SetCameraPosition (const ChVector3d &pos) override
| Set the location of the current (active) camera.
virtual void | SetCameraTarget (const ChVector3d &target) override
| Set the target (look-at) point of the current (active) camera.
void | AddUserEventReceiver (std::shared_ptr< ChOpenGLEventCB > receiver)
| Attach a custom event receiver to the application.
void | AttachParticleSelector (std::shared_ptr< ChOpenGLParticleCB > selector)
| Attach a custom particle rendering selector.
virtual void | BindAll () override
| Process all visual assets in the associated ChSystem.
virtual void | BindItem (std::shared_ptr< ChPhysicsItem > item) override
| Process the visual assets for the spcified physics item.
virtual bool | Run () override
| Run the Irrlicht device.
virtual void | Quit () override
| Terminate the visualization system.
virtual void | BeginScene () override
| Perform any necessary operations at the beginning of each rendering frame.
virtual void | Render () override
| Draw all 3D shapes and GUI elements at the current frame.
virtual void | EndScene () override
| End the scene draw at the end of each animation frame.
virtual void | WriteImageToFile (const std::string &filename) override
| Create a snapshot of the last rendered frame and save it to the provided file.
Public Member Functions inherited from chrono::ChVisualSystem
virtual void | UnbindItem (std::shared_ptr< ChPhysicsItem > item)
| Remove the visual assets for the specified physics item from this visualization system.
virtual void | AddGrid (double x_step, double y_step, int nx, int ny, ChCoordsys<> pos=CSYSNORM, ChColor col=ChColor(0.1f, 0.1f, 0.1f))
| Add a grid with specified parameters in the x-y plane of the given frame.
virtual ChVector3d | GetCameraPosition () const
| Get the location of the current (active) camera.
virtual ChVector3d | GetCameraTarget () const
| Get the target (look-at) point of the current (active) camera.
void | UpdateCamera (int id, const ChVector3d &pos, ChVector3d target)
| Update the location and/or target points of the specified camera.
void | UpdateCamera (const ChVector3d &pos, ChVector3d target)
virtual int | AddVisualModel (std::shared_ptr< ChVisualModel > model, const ChFrame<> &frame)
| Add a visual model not associated with a physical item.
virtual int | AddVisualModel (std::shared_ptr< ChVisualShape > shape, const ChFrame<> &frame)
| Add a visual model not associated with a physical item.
virtual void | UpdateVisualModel (int id, const ChFrame<> &frame)
| Update the position of the specified visualization-only model.
virtual void | RenderFrame (const ChFrame<> &frame, double axis_length=1)
| Render the specified reference frame.
virtual void | RenderCOGFrames (double axis_length=1)
| Render COG frames for all bodies in the system.
virtual double | GetSimulationRTF () const
| Return the simulation real-time factor (simulation time / simulated time).
virtual double | GetSimulationTime () const
| Return the current simulated time.
void | SetImageOutputDirectory (const std::string &dir)
| Set output directory for saving frame snapshots (default: ".").
void | SetImageOutput (bool val)
| Enable/disable writing of frame snapshots to file.
virtual void | EnableModalAnalysis (bool val)
| Enable modal analysis visualization.
virtual void | SetModalModeNumber (int val)
| Set the mode to be shown (only if some ChModalAssembly is found).
virtual void | SetModalAmplitude (double val)
| Set the amplitude of the shown mode (only if some ChModalAssembly is found).
virtual void | SetModalSpeed (double val)
| Set the speed of the shown mode (only if some ChModalAssembly is found).
virtual void | SetModalModesMax (int maxModes)
| Set the maximum number of modes selectable (only if some ChModalAssembly is found).
std::vector< ChSystem * > | GetSystems () const
| Get the list of associated Chrono systems.
ChSystem & | GetSystem (int i) const
| Get the specified associated Chrono system.

## Static Public Member Functions
static void | WrapRenderStep (void *stepFunction)
| Callback wrapper for steps of the render loop. Works with Emscripten.

## Friends
class | ChOpenGLViewer

## Additional Inherited Members
Public Types inherited from chrono::ChVisualSystem
enum class | Type { IRRLICHT , VSG , OpenGL , OptiX , NONE }
| Supported run-time visualization systems. More...
Protected Attributes inherited from chrono::ChVisualSystem
bool | m_initialized
std::vector< ChSystem * > | m_systems
| associated Chrono system(s)
bool | m_write_images
| if true, save snapshots
std::string | m_image_dir
| directory for image files

## Member Function Documentation

## ◆ AddCamera()

int chrono::opengl::ChVisualSystemOpenGL::AddCamera | ( | const ChVector3d & | pos,
|  | ChVector3d | targ = VNULL )
| overridevirtual

Add a camera to the 3d scene.

Reimplemented from chrono::ChVisualSystem.

## ◆ AttachStatsRenderer()

void chrono::opengl::ChVisualSystemOpenGL::AttachStatsRenderer | ( | std::shared_ptr< ChOpenGLStats > | renderer | ) |

Attach a user-defined text renderer for stats overlay.

This overwrites the default stats overlay renderer.

## ◆ AttachSystem()

void chrono::opengl::ChVisualSystemOpenGL::AttachSystem | ( | ChSystem * | sys | ) |
| overridevirtual

Attach a Chrono system to the run-time visualization system.

ChVisualSystemOpenGL allows simultaneous rendering of multiple Chrono systems.

Reimplemented from chrono::ChVisualSystem.

## ◆ BeginScene()

virtual void chrono::opengl::ChVisualSystemOpenGL::BeginScene | ( |  | ) |
| inlineoverridevirtual

Perform any necessary operations at the beginning of each rendering frame.

Implements chrono::ChVisualSystem.

## ◆ BindAll()

void chrono::opengl::ChVisualSystemOpenGL::BindAll | ( |  | ) |
| overridevirtual

Process all visual assets in the associated ChSystem.

This function is called by default by Initialize(), but can also be called later if further modifications to visualization assets occur.

Reimplemented from chrono::ChVisualSystem.

## ◆ BindItem()

void chrono::opengl::ChVisualSystemOpenGL::BindItem | ( | std::shared_ptr< ChPhysicsItem > | item | ) |
| overridevirtual

Process the visual assets for the spcified physics item.

This function must be called if a new physics item is added to the system or if changes to its visual model occur after the call to Initialize().

Reimplemented from chrono::ChVisualSystem.

## ◆ EndScene()

virtual void chrono::opengl::ChVisualSystemOpenGL::EndScene | ( |  | ) |
| inlineoverridevirtual

End the scene draw at the end of each animation frame.

Implements chrono::ChVisualSystem.

## ◆ Initialize()

void chrono::opengl::ChVisualSystemOpenGL::Initialize | ( |  | ) |
| overridevirtual

Initialize the visualization system.

This creates the Irrlicht device using the current values for the optional device parameters.

Implements chrono::ChVisualSystem.

Reimplemented in chrono::vehicle::ChVehicleVisualSystemOpenGL.

## ◆ Quit()

void chrono::opengl::ChVisualSystemOpenGL::Quit | ( |  | ) |
| overridevirtual

Terminate the visualization system.

Implements chrono::ChVisualSystem.

## ◆ Render()

void chrono::opengl::ChVisualSystemOpenGL::Render | ( |  | ) |
| overridevirtual

Draw all 3D shapes and GUI elements at the current frame.

This function is typically called inside a loop such as

       while(vis->Run()) {...}

Implements chrono::ChVisualSystem.

## ◆ Run()

bool chrono::opengl::ChVisualSystemOpenGL::Run | ( |  | ) |
| overridevirtual

Run the Irrlicht device.

Returns false if the device wants to be deleted.

Implements chrono::ChVisualSystem.

## ◆ SetCameraPosition() [1/2]

void chrono::opengl::ChVisualSystemOpenGL::SetCameraPosition | ( | const ChVector3d & | pos | ) |
| overridevirtual

Set the location of the current (active) camera.

Reimplemented from chrono::ChVisualSystem.

## ◆ SetCameraPosition() [2/2]

void chrono::opengl::ChVisualSystemOpenGL::SetCameraPosition | ( | int | id,
|  | const ChVector3d & | pos )
| overridevirtual

Set the location of the specified camera.

Reimplemented from chrono::ChVisualSystem.

## ◆ SetCameraProperties()

void chrono::opengl::ChVisualSystemOpenGL::SetCameraProperties | ( | float | scale = 0.5f,
|  | float | near_clip_dist = 0.1f,
|  | float | far_clip_dist = 1000.0f )

Set camera scale and clip distances.

Parameters

  scale | zoom level (default 0.5)
  near_clip_dist | near clipping distance (default 0.1)
  far_clip_dist | far clipping distance (default 1000)

## ◆ SetCameraTarget() [1/2]

void chrono::opengl::ChVisualSystemOpenGL::SetCameraTarget | ( | const ChVector3d & | target | ) |
| overridevirtual

Set the target (look-at) point of the current (active) camera.

Reimplemented from chrono::ChVisualSystem.

## ◆ SetCameraTarget() [2/2]

void chrono::opengl::ChVisualSystemOpenGL::SetCameraTarget | ( | int | id,
|  | const ChVector3d & | target )
| overridevirtual

Set the target (look-at) point of the specified camera.

Reimplemented from chrono::ChVisualSystem.

## ◆ SetWindowSize()

void chrono::opengl::ChVisualSystemOpenGL::SetWindowSize | ( | unsigned int | width,
|  | unsigned int | height )

Set the window size (default 640x480).

Must be called before Initialize().

## ◆ SetWindowTitle()

void chrono::opengl::ChVisualSystemOpenGL::SetWindowTitle | ( | const std::string & | win_title | ) |

Set the window title (default "").

Must be called before Initialize().

## ◆ WriteImageToFile()

void chrono::opengl::ChVisualSystemOpenGL::WriteImageToFile | ( | const std::string & | filename | ) |
| overridevirtual

Create a snapshot of the last rendered frame and save it to the provided file.

The file extension determines the image format.

Reimplemented from chrono::ChVisualSystem.

The documentation for this class was generated from the following files:

- D:/W/B/src/chrono-9.0.1/src/chrono_opengl/ChVisualSystemOpenGL.h
- D:/W/B/src/chrono-9.0.1/src/chrono_opengl/ChVisualSystemOpenGL.cpp