Debug drawing 3D lines [SOLVED]


I’m trying to get my physics working and would like to draw some simple 3D-lines representing the forces I apply to debug my faulty math. Anyone know a nice way to visualize forces and positions for debug purposes?

I am currently using the arrow ( and that works, but, is there some even simpler way to just draw a red 3D-line (for example between two points in world coordinates)?

Why don’t you copy the arrow object, rename it “line” and remove the head of the arrow from the mesh ?

It’s quite simple to do :slight_smile:

:smiley: Yeah, of course I could do that. I was merely wishing for the magical “if you hook in here you can do the one-liner glLine(x0,y0,z0,x1,y1,z1)” instead of manipulating the ordinary scene graph.

You can render anything in the render() methods of Controls etc. Thats how the physics does its debug display.

1 Like

You can write an API on top of jME3 to draw a line or any object with function.

jME3 rendering system is based on the scene-graph concept because for most applications and games this is the preferred way of managing a 3D scene.

@jmaasing said:
:D Yeah, of course I could do that. I was merely wishing for the magical "if you hook in here you can do the one-liner glLine(x0,y0,z0,x1,y1,z1)" instead of manipulating the ordinary scene graph.

Actually you couldn't since you first have to set all needed states, then undo them after drawing it, so that jme does not find some states magically changed XD

I suggest to just follow the normal concept and use a mesh object taht you manipulate for your needs, (after all glline shoudl work similar)

For reference, this is an example of what I ended up with in my Control-class. Works nicely for my purpose.



public void render(RenderManager rm, ViewPort vp) {

if (debug) {

if (centralForceMarker == null) {

Arrow a = new Arrow(new Vector3f(0, 1, 0));

centralForceMarker = new Geometry("Debug central force", a);

Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");

material.setColor("Color", ColorRGBA.Blue);



final Vector3f physicsLocation = getPhysicsLocation();


Vector3f linearVelocity = getLinearVelocity();

final Matrix3f rotate = new Matrix3f();

rotate.fromStartEndVectors(Vector3f.UNIT_Y, linearVelocity.normalize());


centralForceMarker.setLocalScale(1, linearVelocity.length(), 1);



rm.renderScene(centralForceMarker, vp);

super.render(rm, vp);