Description

custom event receiver for chase-cam control

Customized Chrono Irrlicht application for vehicle visualization. This class implements an Irrlicht-based visualization wrapper for vehicles. This class is a wrapper around a ChIrrApp object and provides the following functionality:

  • rendering of the entire Irrlicht scene
  • implements a custom chase-camera (which can be controlled with keyboard)
  • optional rendering of links, springs, stats, etc.

#include <ChVehicleIrrApp.h>

Inheritance diagram for chrono::vehicle::ChVehicleIrrApp:
Collaboration diagram for chrono::vehicle::ChVehicleIrrApp:

Public Member Functions

 ChVehicleIrrApp (ChVehicle *vehicle, const std::wstring &title=L"Chrono::Vehicle", const irr::core::dimension2d< irr::u32 > &dims=irr::core::dimension2d< irr::u32 >(1000, 800), irrlicht::VerticalDir vert=irrlicht::VerticalDir::Z, irr::ELOG_LEVEL log_level=irr::ELL_INFORMATION)
 Construct a vehicle Irrlicht application. More...
 
void SetChaseCamera (const ChVector<> &ptOnChassis, double chaseDist, double chaseHeight)
 Set parameters for the underlying chase camera. More...
 
void SetStepsize (double val)
 Set the step size for integration of the chase-cam dynamics.
 
void SetChaseCameraState (utils::ChChaseCamera::State state)
 Set camera state (mode).
 
void SetChaseCameraPosition (const ChVector<> &pos)
 Set camera position. More...
 
void SetChaseCameraAngle (double angle)
 Set camera angle.
 
void SetChaseCameraMultipliers (double minMult, double maxMult)
 Set camera zoom multipliers.
 
void SetHUDLocation (int HUD_x, int HUD_y)
 Set the upper-left point of HUD elements.
 
void EnableStats (bool val)
 Turn on/off rendering of stats (HUD).
 
void EnableSound (bool sound)
 Turn on/off Irrklang sound generation. More...
 
virtual void DrawAll () override
 Render the Irrlicht scene and additional visual elements.
 
void RenderGrid (const ChVector<> &loc, int num_divs, double delta)
 Render a horizontal grid at the specified location.
 
void RenderFrame (const ChFrame<> &frame, double axis_length=1)
 Render the specified reference frame.
 
void Synchronize (const std::string &msg, const ChDriver::Inputs &driver_inputs)
 Update information related to driver inputs.
 
void Advance (double step)
 Advance the dynamics of the chase camera. More...
 
void WriteImageToFile (const std::string &filename)
 Save a snapshot of the last rendered frame to file. More...
 
- Public Member Functions inherited from chrono::irrlicht::ChIrrApp
 ChIrrApp (ChSystem *psystem, const std::wstring &title=L"Chrono", const irr::core::dimension2d< irr::u32 > &dimens=irr::core::dimension2d< irr::u32 >(640, 480), VerticalDir vert=VerticalDir::Y, bool do_fullscreen=false, bool do_shadows=false, bool do_antialias=true, irr::video::E_DRIVER_TYPE mydriver=irr::video::EDT_DIRECT3D9, irr::ELOG_LEVEL log_level=irr::ELL_INFORMATION)
 Create the application with Irrlicht context (3D view, device, etc.).
 
virtual ~ChIrrApp ()
 Safely delete every Irrlicht item (including the Irrlicht scene nodes).
 
ChIrrAssetConverterGetAssetConverter ()
 Gets the asset converter.
 
void AssetBind (std::shared_ptr< ChPhysicsItem > mitem)
 Shortcut to add and bind a ChIrrNodeAsset to an item, if it has not been added previously.
 
void AssetBindAll ()
 Shortcut to add and bind a ChIrrNodeAsset to all items in a ChSystem. More...
 
void AssetUpdate (std::shared_ptr< ChPhysicsItem > mitem)
 This function sets up the Irrlicht nodes corresponding to the geometric assets that are found in the ChPhysicsItem 'mitem'. More...
 
void AssetUpdateAll ()
 For all items in a ChSystem, this function sets up the Irrlicht nodes corresponding to the geometric assets that have been added to the items. More...
 
void AddShadow (std::shared_ptr< ChPhysicsItem > mitem)
 Shortcut to enable shadow maps for an item. More...
 
void AddShadowAll ()
 Shortcut to enable shadow maps for all items in scene. More...
 
- Public Member Functions inherited from chrono::irrlicht::ChIrrAppInterface
 ChIrrAppInterface (ChSystem *sys, const std::wstring &title=L"Chrono", const irr::core::dimension2d< irr::u32 > &dimens=irr::core::dimension2d< irr::u32 >(640, 480), VerticalDir vert=VerticalDir::Y, bool do_fullscreen=false, bool do_shadows=false, bool do_antialias=true, irr::video::E_DRIVER_TYPE mydriver=irr::video::EDT_DIRECT3D9, irr::ELOG_LEVEL log_level=irr::ELL_INFORMATION)
 Create the Irrlicht context (device, etc.)
 
virtual ~ChIrrAppInterface ()
 Delete all Irrlicht items (including the Irrlicht scene nodes)
 
irr::IrrlichtDevice * GetDevice ()
 
irr::video::IVideoDriver * GetVideoDriver ()
 
irr::scene::ISceneManager * GetSceneManager ()
 
irr::scene::ICameraSceneNode * GetActiveCamera ()
 
irr::gui::IGUIEnvironment * GetIGUIEnvironment ()
 
EffectHandlerGetEffects ()
 
irr::scene::ISceneNode * GetContainer ()
 
ChSystemGetSystem ()
 
void SetShowInfos (bool val)
 Show the info panel in the 3D view.
 
bool GetShowInfos ()
 
void SetInfosTab (int ntab)
 
void SetShowProfiler (bool val)
 Show the realtime profiler in the 3D view.
 
bool GetShowProfiler ()
 
void SetShowExplorer (bool val)
 Show the object explorer.
 
bool GetShowExplorer ()
 
void SetTimestep (double val)
 Set/Get the time step for time integration. More...
 
double GetTimestep ()
 
void SetStepManage (bool val)
 If set to true, you can use DoStep() in the simulation loop to advance the simulation by one timestep. More...
 
void SetTryRealtime (bool val)
 If enabled, the function DoStep() will enforce soft real-time, by spinning in place until simulation time catches up with real time.
 
void SetPaused (bool val)
 Set/Get the simulation state (running or paused)
 
bool GetPaused ()
 
void SetVideoframeSave (bool val)
 If set to true, each frame of the animation will be saved on the disk as snapshot0001.bmp, snapshot0002.bmp, etc.
 
bool GetVideoframeSave ()
 
void SetVideoframeSaveInterval (int val)
 Set to 1 if you need to save on disk all simulation steps, set to 2 for saving each 2 steps, etc.
 
int GetVideoframeSaveInterval ()
 
void SetModalShow (bool val)
 If set true, instead of doing time integration in myapplication.DoStep() it just shows an oscillatory motion of the nth mode (only if some ChModalAssembly is found)
 
bool GetModalShow ()
 
void SetModalModeNumber (int val)
 When in SetModalShow(true), use this to pick the n-th mode to show (only if some ChModalAssembly is found)
 
int GetModalModeNumber ()
 
void SetModalAmplitude (double val)
 When in SetModalShow(true), this sets the amplitude of shown mode (only if some ChModalAssembly is found)
 
double GetModalAmplitude ()
 
void SetModalSpeed (double val)
 When in SetModalShow(true), this sets the speed of shown mode (only if some ChModalAssembly is found)
 
double GetModalSpeed ()
 
void SetContactsLabelMode (IrrContactsLabelMode mm)
 Set the label mode for contacts.
 
void SetContactsDrawMode (IrrContactsDrawMode mm)
 Set the draw mode for contacts.
 
void SetLinksLabelMode (IrrLinkLabelMode mm)
 Set the label mode for links.
 
void SetLinksDrawMode (IrrLinkDrawMode mm)
 Set the draw mode for links.
 
void SetPlotAABB (bool val)
 Set if the AABB collision shapes will be plotted.
 
void SetPlotCOGFrames (bool val)
 Set if the COG frames will be plotted.
 
void SetPlotCollisionShapes (bool val)
 Set if the collision shapes will be plotted.
 
void SetPlotLinkFrames (bool val)
 Set if the link frames will be plotted.
 
void SetPlotConvergence (bool val)
 Set if the COG frames will be plotted.
 
void SetSymbolscale (double val)
 Set the scale for symbol drawing (link frames, COGs, etc.) More...
 
double GetSymbolscale ()
 
void SetUserEventReceiver (irr::IEventReceiver *mreceiver)
 Use this function to hook a custom event receiver to the application.
 
void SetFonts (const std::string &mfontdir=GetChronoDataFile("fonts/arial8.xml"))
 Set the fonts to be used from now on. More...
 
virtual void BeginScene (bool backBuffer=true, bool zBuffer=true, irr::video::SColor color=irr::video::SColor(255, 0, 0, 0))
 Call this to clean the canvas at the beginning of each animation frame.
 
virtual void DoStep ()
 Call this function inside a loop such as. More...
 
virtual void EndScene ()
 Call this to end the scene draw at the end of each animation frame.
 
void DumpSystemMatrices ()
 Dump the last used system matrices and vectors in the current directory, as 'dump_xxxx.dat' files that can be loaded with Matlab for debugging, benchmarking etc. More...
 
void AddLogo (const std::string &mlogofilename=GetChronoDataFile("logo_chronoengine_alpha.png"))
 Add a logo in a 3D scene.
 
void AddCamera (irr::core::vector3df pos=irr::core::vector3df(0, 0, -8), irr::core::vector3df targ=irr::core::vector3df(0, 0, 0))
 Add a Maya-like camera in an Irrlicht 3D scene. More...
 
void AddSkyBox (const std::string &texturedir=GetChronoDataFile("skybox/"))
 Add a sky box in a 3D scene. More...
 
irr::scene::ILightSceneNode * AddLight (irr::core::vector3df pos, double radius, irr::video::SColorf color=irr::video::SColorf(0.7f, 0.7f, 0.7f, 1.0f))
 Add a point light to the scene.
 
irr::scene::ILightSceneNode * AddLightWithShadow (irr::core::vector3df pos, irr::core::vector3df aim, double radius, double mnear, double mfar, double angle, irr::u32 resolution=512, irr::video::SColorf color=irr::video::SColorf(1.f, 1.f, 1.f, 1.f), bool directional=false, bool clipborder=true)
 Add a point light that cast shadow (using soft shadows/shadow maps) Note that the quality of the shadow strictly depends on how you set 'mnear' and 'mfar' parameters as close as possible to the bounding box of the scene. More...
 
void AddTypicalLights ()
 Simple shortcut to set two point lights in the scene. More...
 

Protected Member Functions

virtual void renderOtherGraphics ()
 Render additional graphics.
 
virtual void renderOtherStats (int left, int top)
 Render additional vehicle information.
 
void renderLinGauge (const std::string &msg, double factor, bool sym, int xpos, int ypos, int length=120, int height=15)
 
void renderTextBox (const std::string &msg, int xpos, int ypos, int length=120, int height=15, irr::video::SColor color=irr::video::SColor(255, 20, 20, 20))
 
void renderStats ()
 

Protected Attributes

ChVehiclem_vehicle
 pointer to the associated vehicle system
 
utils::ChChaseCamera m_camera
 chase camera
 
ChCameraEventReceiver * m_camera_control
 event receiver for chase-cam control
 
double m_stepsize
 integration step size for chase-cam dynamics
 
bool m_renderStats
 turn on/off rendering of stats
 
int m_HUD_x
 x-coordinate of upper-left corner of HUD elements
 
int m_HUD_y
 y-coordinate of upper-left corner of HUD elements
 
std::string m_driver_msg
 HUD message from driver system.
 
double m_steering
 driver steering input
 
double m_throttle
 driver throttle input
 
double m_braking
 driver braking input
 

Friends

class ChCameraEventReceiver
 
class ChIrrGuiDriver
 
class ChIrrGuiDriverSTR
 

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