Debug Graphics: Show normals as lines

Sorry for asking this question, but: How can I show normals as little lines during graphical debugging? I can not find the forum post of the user who showed that feature and the according lines of code.

Yes, I looked here:

Yes, I know that there is a material that shows normals as colors on the surface.

But I want to see the normals as little lines poking out of the vertices.

I know that some user showed this feature half a year ago, but I can’t find it anymore. Sorry. :chimpanzee_nogood:

And how can I view the BoundingVolume as wireframe objects?
I know that jME 2 had that feature so I think jME 3 can do this too.

Thanks in advance for any useful replies,

When I need it I usually do it by myself by generating mesh for normals based on original mesh. Not very effective but it’s for debug needs anyway. Just go though all vertices, take corresponding normal and make a new mesh with double the vertex count and lines display mode where first vertex in every pair is at position of original vertex and second one is first one plus scaled normal vector. Geometry shader approach should be more flexible but it’s out of my knowledge yet.

Unfortunately I can’t share any code as it’s usually very messy - just a bunch of debug code put together in a hurry.

        //mesh is the mesh for which you wan to see tbn
        Geometry debug = new Geometry("Debug normals",  TangentBinormalGenerator.genTbnLines(mesh, 0.08f)
        Material debugMat = assetManager.loadMaterial("Common/Materials/VertexColor.j3m");

source in


Thanks, nehon, that looks very promising. Going to test it soon.

Messy code is no problem for those willing to digg into it! :chimpanzee_closedlaugh:

Share if you like or keep if you don’t, I have no problem either way.

Oh, did not know it could be done THAT easy. :chimpanzee_eek: TangentBinormalGenerator is the beast.

@nehon Do you know a little trick to show BoundingVolumes as wireframe objects too?

I used this in the past to investigate my normals :

public void showNormals(Geometry geometry, ColorRGBA color) {
    VertexBuffer position = geometry.getMesh().getBuffer(Type.Position);
    Vector3f[] positionVertexes = BufferUtils.getVector3Array((FloatBuffer) position.getData());
    VertexBuffer normal = geometry.getMesh().getBuffer(Type.Normal);
    Vector3f[] normalsVectors = BufferUtils.getVector3Array((FloatBuffer) normal.getData());
    for (int arrow = 0; arrow < normalsVectors.length; arrow++) {
        createArrow(positionVertexes[arrow], normalsVectors[arrow] , color);

private void createArrow(Vector3f location, Vector3f direction, ColorRGBA color) {
    Arrow arrow = new Arrow(direction);
    Geometry g = new Geometry("arrow", arrow);
    Material mat = new Material(application.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", color);

You could ofc batch the arrows for way better performances.
If you have a level editor or something, you could bind a key to toggle showing them. In my case, each geometry is displayed in the editor as a record in a table so it’s pretty easy to choose which to toggle the showing… for some reason, it got shafted during a refactoring :D.

NB: old code; maybe needs to be adapted for 3.1… no idea, haven’t tested.

Ok, thanks for that too.
The batching was the first thing I thought too. :chimpanzee_smile:

For the whole normals debugging in general:
I don’t know yet if the normals could easily be updated for animated models.
On the other hand - who needs that feature on a regular basis?
Maybe I just deactivate normals debugging for every Spatial that has an AnimControl.

For the bounding volumes:
I found out that there is already a WireSphere and a WireBox.
Implemented that the same way I did for normals, hope it works.
I’ve seen there is an unused type ‘Capsule’ - I wonder,
will there be a BoundingCapsule / WireCapsule in jME 3.1? :chimpanzee_smile: