Description

Base class for a Chrono run-time visualization system.

#include <ChVisualSystem.h>

Inheritance diagram for chrono::ChVisualSystem:

Public Types

enum  Type {
  Type::IRRLICHT, Type::VSG, Type::OpenGL, Type::OptiX,
  NONE
}
 Supported run-time visualization systems. More...
 

Public Member Functions

void SetVerbose (bool verbose)
 Enable/disable information terminal output during initialization (default: false).
 
virtual void AttachSystem (ChSystem *sys)
 Attach a Chrono system to this visualization system.
 
virtual void Initialize ()=0
 Initialize the visualization system. More...
 
virtual void BindAll ()
 Process all visual assets in the associated Chrono systems. More...
 
virtual void BindItem (std::shared_ptr< ChPhysicsItem > item)
 Process the visual assets for the specified physics item. More...
 
virtual void UnbindItem (std::shared_ptr< ChPhysicsItem > item)
 Remove the visual assets for the specified physics item from this visualization system.
 
virtual int AddCamera (const ChVector3d &pos, ChVector3d targ=VNULL)
 Add a camera to the 3D scene. More...
 
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. More...
 
virtual void SetCameraPosition (int id, const ChVector3d &pos)
 Set the location of the specified camera.
 
virtual void SetCameraTarget (int id, const ChVector3d &target)
 Set the target (look-at) point of the specified camera.
 
virtual void SetCameraPosition (const ChVector3d &pos)
 Set the location of the current (active) camera.
 
virtual void SetCameraTarget (const ChVector3d &target)
 Set the target (look-at) point of the current (active) camera.
 
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. More...
 
virtual int AddVisualModel (std::shared_ptr< ChVisualShape > shape, const ChFrame<> &frame)
 Add a visual model not associated with a physical item. More...
 
virtual void UpdateVisualModel (int id, const ChFrame<> &frame)
 Update the position of the specified visualization-only model.
 
virtual bool Run ()=0
 Run the visualization system. More...
 
virtual void Quit ()=0
 Terminate the visualization system.
 
virtual void BeginScene ()=0
 Perform any necessary operations at the beginning of each rendering frame.
 
virtual void Render ()=0
 Draw all 3D shapes and GUI elements at the current frame. More...
 
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 void EndScene ()=0
 Perform any necessary operations ar the end of each rendering frame.
 
virtual double GetSimulationRTF () const
 Return the simulation real-time factor (simulation time / simulated time). More...
 
virtual double GetSimulationTime () const
 Return the current simulated time. More...
 
virtual void WriteImageToFile (const std::string &filename)
 Create a snapshot of the last rendered frame and save it to the provided file. More...
 
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.
 
std::vector< ChSystem * > GetSystems () const
 Get the list of associated Chrono systems.
 
ChSystemGetSystem (int i) const
 Get the specified associated Chrono system.
 

Protected Member Functions

virtual void OnSetup (ChSystem *sys)
 Perform any necessary setup operations at the beginning of a time step. More...
 
virtual void OnUpdate (ChSystem *sys)
 Perform any necessary update operations at the end of a time step. More...
 
virtual void OnClear (ChSystem *sys)
 Remove all visualization objects from this visualization system. More...
 

Protected Attributes

bool m_verbose
 terminal output
 
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
 

Friends

class ChSystem
 

Member Enumeration Documentation

◆ Type

Supported run-time visualization systems.

Enumerator
IRRLICHT 

Irrlicht.

VSG 

Vulkan Scene Graph.

OpenGL 

OpenGL.

OptiX 

OptiX.

Member Function Documentation

◆ AddCamera()

virtual int chrono::ChVisualSystem::AddCamera ( const ChVector3d pos,
ChVector3d  targ = VNULL 
)
inlinevirtual

Add a camera to the 3D scene.

Return an ID which can be used later to modify camera location and/or target points. A concrete visualization system may or may not support multiuple cameras.

Reimplemented in chrono::vsg3d::ChVisualSystemVSG, chrono::irrlicht::ChVisualSystemIrrlicht, and chrono::opengl::ChVisualSystemOpenGL.

◆ AddGrid()

virtual void chrono::ChVisualSystem::AddGrid ( double  x_step,
double  y_step,
int  nx,
int  ny,
ChCoordsys<>  pos = CSYSNORM,
ChColor  col = ChColor(0.1f, 0.1f, 0.1f) 
)
inlinevirtual

Add a grid with specified parameters in the x-y plane of the given frame.

Parameters
x_stepgrid cell size in X direction
y_stepgrid cell size in Y direction
nxnumber of cells in X direction
nynumber of cells in Y direction
posgrid reference frame
colgrid line color

Reimplemented in chrono::vsg3d::ChVisualSystemVSG, and chrono::irrlicht::ChVisualSystemIrrlicht.

◆ AddVisualModel() [1/2]

virtual int chrono::ChVisualSystem::AddVisualModel ( std::shared_ptr< ChVisualModel model,
const ChFrame<> &  frame 
)
inlinevirtual

Add a visual model not associated with a physical item.

Return an ID which can be used later to modify the position of this visual model.

Reimplemented in chrono::irrlicht::ChVisualSystemIrrlicht, and chrono::vsg3d::ChVisualSystemVSG.

◆ AddVisualModel() [2/2]

virtual int chrono::ChVisualSystem::AddVisualModel ( std::shared_ptr< ChVisualShape shape,
const ChFrame<> &  frame 
)
inlinevirtual

Add a visual model not associated with a physical item.

This version constructs a visual model consisting of the single specified shape Return an ID which can be used later to modify the position of this visual model.

Reimplemented in chrono::irrlicht::ChVisualSystemIrrlicht, and chrono::vsg3d::ChVisualSystemVSG.

◆ BindAll()

virtual void chrono::ChVisualSystem::BindAll ( )
inlinevirtual

Process all visual assets in the associated Chrono systems.

This function is called by default for a Chrono system attached to this visualization system during initialization, but can also be called later if further modifications to visualization assets occur.

Reimplemented in chrono::irrlicht::ChVisualSystemIrrlicht, chrono::opengl::ChVisualSystemOpenGL, and chrono::vsg3d::ChVisualSystemVSG.

◆ BindItem()

virtual void chrono::ChVisualSystem::BindItem ( std::shared_ptr< ChPhysicsItem item)
inlinevirtual

Process the visual assets for the specified 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 visualization system was attached to the Chrono system.

Reimplemented in chrono::irrlicht::ChVisualSystemIrrlicht, chrono::opengl::ChVisualSystemOpenGL, and chrono::vsg3d::ChVisualSystemVSG.

◆ GetSimulationRTF()

double chrono::ChVisualSystem::GetSimulationRTF ( ) const
virtual

Return the simulation real-time factor (simulation time / simulated time).

The default value returned by this base class is the RTF value from the first associated system (if any). See ChSystem::GetRTF

◆ GetSimulationTime()

double chrono::ChVisualSystem::GetSimulationTime ( ) const
virtual

Return the current simulated time.

The default value returned by this base class is the time from the first associated system (if any).

◆ Initialize()

virtual void chrono::ChVisualSystem::Initialize ( )
pure virtual

Initialize the visualization system.

This call must trigger a parsing of the associated Chrono systems to process all visual models. A derived class must ensure that this function is called only once (use the m_initialized flag).

Implemented in chrono::irrlicht::ChVisualSystemIrrlicht, chrono::modal::ChModalVisualSystemIrrlicht< ScalarType >, chrono::opengl::ChVisualSystemOpenGL, chrono::vehicle::ChVehicleVisualSystemIrrlicht, chrono::vsg3d::ChVisualSystemVSG, chrono::vehicle::ChVehicleVisualSystemOpenGL, and chrono::vehicle::ChVehicleVisualSystemVSG.

◆ OnClear()

virtual void chrono::ChVisualSystem::OnClear ( ChSystem sys)
inlineprotectedvirtual

Remove all visualization objects from this visualization system.

Called by an associated ChSystem.

Reimplemented in chrono::irrlicht::ChVisualSystemIrrlicht.

◆ OnSetup()

virtual void chrono::ChVisualSystem::OnSetup ( ChSystem sys)
inlineprotectedvirtual

Perform any necessary setup operations at the beginning of a time step.

Called by an associated ChSystem.

Reimplemented in chrono::irrlicht::ChVisualSystemIrrlicht, and chrono::vsg3d::ChVisualSystemVSG.

◆ OnUpdate()

virtual void chrono::ChVisualSystem::OnUpdate ( ChSystem sys)
inlineprotectedvirtual

Perform any necessary update operations at the end of a time step.

Called by an associated ChSystem.

Reimplemented in chrono::irrlicht::ChVisualSystemIrrlicht.

◆ Render()

virtual void chrono::ChVisualSystem::Render ( )
pure virtual

◆ Run()

virtual bool chrono::ChVisualSystem::Run ( )
pure virtual

Run the visualization system.

Returns false if the system must shut down.

Implemented in chrono::irrlicht::ChVisualSystemIrrlicht, chrono::opengl::ChVisualSystemOpenGL, and chrono::vsg3d::ChVisualSystemVSG.

◆ WriteImageToFile()

virtual void chrono::ChVisualSystem::WriteImageToFile ( const std::string &  filename)
inlinevirtual

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

The file extension determines the image format.

Reimplemented in chrono::irrlicht::ChVisualSystemIrrlicht, chrono::opengl::ChVisualSystemOpenGL, and chrono::vsg3d::ChVisualSystemVSG.


The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono/assets/ChVisualSystem.h
  • /builds/uwsbel/chrono/src/chrono/assets/ChVisualSystem.cpp