chrono::opengl::ChVisualSystemOpenGL Class Reference

Description

OpenGL-based Chrono run-time visualization system.

#include <ChVisualSystemOpenGL.h>

Inheritance diagram for chrono::opengl::ChVisualSystemOpenGL:
Collaboration diagram for chrono::opengl::ChVisualSystemOpenGL:

Public Member Functions

void SetWindowSize (unsigned int width, unsigned int height)
 Set the window size (default 640x480). More...
 
void SetWindowTitle (const std::string &win_title)
 Set the window title (default ""). More...
 
void SetCameraVertical (CameraVerticalDir vert)
 Set camera vertical direction (default CameraVerticalDir::Z).
 
void SetCameraVertical (const ChVector<> &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. More...
 
void SetRenderMode (RenderMode mode)
 Set render mode for solid objects (default: SOLID)
 
void SetParticleRenderMode (float radius, RenderMode mode)
 Set render mode for particle systems (default: POINTS)
 
virtual void AttachSystem (ChSystem *sys) override
 Attach a Chrono system to the run-time visualization system. More...
 
void SetStatsRenderer (std::shared_ptr< ChOpenGLStats > renderer)
 Set a user-defined text renderer for stats overlay. More...
 
void EnableStats (bool state)
 Enable/disable stats overlay display (default: true).
 
virtual void Initialize ()
 Initialize the visualization system. More...
 
void SetCameraPosition (const ChVector<> &pos, ChVector<> targ=VNULL)
 Set camera positino and look-at point. More...
 
void AddUserEventReceiver (ChOpenGLEventCB *receiver)
 Attach a custom event receiver to the application.
 
virtual void BindAll () override
 Process all visual assets in the associated ChSystem. More...
 
virtual void BindItem (std::shared_ptr< ChPhysicsItem > item) override
 Process the visual assets for the spcified physics item. More...
 
bool Run ()
 Run the Irrlicht device. More...
 
virtual void BeginScene (bool backBuffer=true, bool zBuffer=true, ChColor color=ChColor(0, 0, 0))
 Clean the canvas at the beginning of each animation frame.
 
virtual void Render ()
 Draw all 3D shapes and GUI elements at the current frame. More...
 
virtual void EndScene ()
 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. More...
 
- Public Member Functions inherited from chrono::ChVisualSystem
virtual void EnableModalAnalysis (bool val)
 Enable modal analysis visualization. More...
 
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).
 
std::vector< ChSystem * > GetSystems () const
 Get the list of associated Chrono systems.
 
ChSystemGetSystem (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

- Protected Attributes inherited from chrono::ChVisualSystem
std::vector< ChSystem * > m_systems
 associated Chrono system(s)
 

Member Function Documentation

◆ 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.

◆ 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.

◆ Initialize()

void chrono::opengl::ChVisualSystemOpenGL::Initialize ( )
virtual

Initialize the visualization system.

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

◆ Render()

void chrono::opengl::ChVisualSystemOpenGL::Render ( )
virtual

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

This function is typically called inside a loop such as

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

◆ Run()

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

Run the Irrlicht device.

Returns false if the device wants to be deleted.

◆ SetCameraPosition()

void chrono::opengl::ChVisualSystemOpenGL::SetCameraPosition ( const ChVector<> &  pos,
ChVector<>  targ = VNULL 
)

Set camera positino and look-at point.

The camera rotation/pan is controlled by mouse left and right buttons, the zoom is controlled by mouse wheel or rmb+lmb+mouse, the position can be changed also with keyboard up/down/left/right arrows, the height can be changed with keyboard 'PgUp' and 'PgDn' keys. Optional parameters are position and target.

◆ 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
scalezoom level (default 0.5)
near_clip_distnear clipping distance (default 0.1)
far_clip_distfar clipping distance (default 1000)

◆ SetStatsRenderer()

void chrono::opengl::ChVisualSystemOpenGL::SetStatsRenderer ( std::shared_ptr< ChOpenGLStats renderer)

Set a user-defined text renderer for stats overlay.

This overwrites the default stats overlay renderer.

◆ 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:
  • /builds/uwsbel/chrono/src/chrono_opengl/ChVisualSystemOpenGL.h
  • /builds/uwsbel/chrono/src/chrono_opengl/ChVisualSystemOpenGL.cpp