Debug Visualization

21 views
Skip to first unread message

Markus S

unread,
Jan 9, 2022, 5:12:04 AMJan 9
to ProjectChrono
Hi!

Is there a guide or documentation on how I can set-up debug visualization for the physics of my game to know how the physic bodies look like?
I'm coming from Bullet and there it's quiet simple and quick to add it. You just need to inherit from a class, override a method that draws a line from point a to b given a color c, draw that line however your engine works and then just assign an instance of your custom debug visualization to the physics world.

How does it work in Chrono?

Radu Serban

unread,
Jan 9, 2022, 6:17:44 AMJan 9
to theytit...@gmail.com, ProjectChrono

Run-time visualization of Chrono modeling elements (mostly bodies, but also some connections such as linear and rotational springs) is done by attaching visual assets to these elements and then using a run-time visualization module such as Chrono::Irrlicht (which you must enable and configure during CMake configuration).

 

Once you configure and build Chrono with Irrlicht support enabled, look at any of the demos named “demo_IRR_***” for examples of attaching visual assets to your bodies and having those rendered during simulation. 

 

Look also at demo_IRR_debugDrawer_collisionModels which may be exactly what you want.  That uses a class derived from btIDebugDraw and interfaces to Irrlicht calls for the actual rendering.

 

--Radu

--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/0fe05b4c-ca67-4118-ae3d-168a08c6ed3bn%40googlegroups.com.

Markus S

unread,
Jan 9, 2022, 7:45:46 AMJan 9
to ProjectChrono
Thanks!

Please correct me if I'm wrong but that would only work if I have set Bullet for the collision system, right? If I choose Chronos collision system, how would it be done there?

Radu Serban

unread,
Jan 9, 2022, 9:11:18 AMJan 9
to theytit...@gmail.com, ProjectChrono

The visual assets are independent of the collision system.  So, you can use whatever shapes, meshes, or lines you want for each body, and they will be rendered.

Use the class derived from btIDebugDraw obviously only works with the Bullet collision system.

Markus S

unread,
Jan 9, 2022, 9:22:57 AMJan 9
to ProjectChrono

Thanks! But what I don't understand is, can I even use a visualization module (OpenGL, Irrlicht) if I want to visualize the ChBodies in the same viewport that my game runs in?

So for example if I have a cube in my game, I want Chrono to draw the outline of the physics body of the cube so I can make sure that the physics body matches the visual cube body.

Radu Serban

unread,
Jan 9, 2022, 11:22:33 AMJan 9
to theytit...@gmail.com, ProjectChrono

I see, you are using your own visualization system.  In that case, unless you have it fully interfaced to the Chrono asset system, you will not be able to use that to visualize the collision shapes (you cannot overlay Irrlicht or OpenGL on top of your rendering).

 

For now, I suggest you use the Bullet collision system (if you design your Chrono code appropriately, you can switch between the two collision systems with one flag) and use the btIDebugDraw mechanism as illustrated in that demo (replacing the underlying call to the Irrlicht line drawing function to one using your own visualization system).  In principle, it’s not all that difficult to provide a similar mechanism for rendering collision shapes when using the parallel Chrono collision; I’ll look into that at some point.

Markus S

unread,
Jan 11, 2022, 11:10:58 AMJan 11
to ProjectChrono
Thanks!
Reply all
Reply to author
Forward
0 new messages