Drawing a debug sphere?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
dart_theg
Posts: 87
Joined: Sun Dec 29, 2024 3:13 am

Drawing a debug sphere?

Post by dart_theg »

If anyone is familiar with Unreal Engine, you can draw debug spheres much like how in Irrlicht you can draw boxes. Right now, I use boxes for my projects, but I would like to draw a sphere/capsule for spherical detections (combat stuff...) but I'm not sure how to really go about that. It can be as simple as the outline of a sphere/capsule or basically drawing a meshed capsule. I used to do the latter, but I would like to avoid if possible...
CuteAlien
Admin
Posts: 10021
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Drawing a debug sphere?

Post by CuteAlien »

One solution - use addSphereSceneNode and move it to the place you want to draw. I sometimes use a second scenemanager for this which draws after the first one.

The other - create debug meshes with IGeometryCreator::createSphereMesh. Probaby best to use radius 1 or 0.5 (for easy "standard" size).
Then draw it directly with IVideoDriver::drawMeshBuffer. Don't for get to set the material and transformation matrix first. Basially - creating your own "node" with your own wrapper code. And then I draw it after the normal scenemanager has done it's drawing.
Note: You only need 1 such mesh - you can draw it lots of times with different transformation matrices (so for debug stuff this tends to be easier than using nodes).

The trick for nice drawing now is in the SMaterial you set for the mesh. For wireframe set SMaterial::Wireframe to true.
For debug I often also set Lighting to true and then set only the EmissiveColor and all other colors to 0. That way you set the exact color you want. Also for debug-meshes I often set ZBuffer to irr::video::ECFN_DISABLED so it always renders.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply