Description
Base class for a Chrono run-time visualization system.
#include <ChVisualSystem.h>
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. | |
ChSystem & | GetSystem (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
|
strong |
Member Function Documentation
◆ AddCamera()
|
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()
|
inlinevirtual |
Add a grid with specified parameters in the x-y plane of the given frame.
- Parameters
-
x_step grid cell size in X direction y_step grid cell size in Y direction nx number of cells in X direction ny number of cells in Y direction pos grid reference frame col grid line color
Reimplemented in chrono::vsg3d::ChVisualSystemVSG, and chrono::irrlicht::ChVisualSystemIrrlicht.
◆ AddVisualModel() [1/2]
|
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]
|
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()
|
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()
|
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()
|
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()
|
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()
|
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()
|
inlineprotectedvirtual |
Remove all visualization objects from this visualization system.
Called by an associated ChSystem.
Reimplemented in chrono::irrlicht::ChVisualSystemIrrlicht.
◆ OnSetup()
|
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()
|
inlineprotectedvirtual |
Perform any necessary update operations at the end of a time step.
Called by an associated ChSystem.
Reimplemented in chrono::irrlicht::ChVisualSystemIrrlicht.
◆ Render()
|
pure 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()) { ... vis->Render(); ... }
Implemented in chrono::irrlicht::ChVisualSystemIrrlicht, chrono::opengl::ChVisualSystemOpenGL, chrono::modal::ChModalVisualSystemIrrlicht< ScalarType >, chrono::vsg3d::ChVisualSystemVSG, chrono::vehicle::ChVehicleVisualSystemIrrlicht, and chrono::robosimian::RoboSimianVisualSystemIrrlicht.
◆ 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()
|
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