Hello,
I’m actually developing an application that has to deal with points clouds and line sets. In order to render the two components, i’m using underlying meshes as follows:
Points cloud:
Material mat = new Material(application.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.setBoolean("VertexColor", true);
mat.getAdditionalRenderState().setBlendMode(BlendMode.Off);
mat.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);
Mesh m = new Mesh();
m.setMode(Mode.Points);
m.setBuffer(VertexBuffer.Type.Position, 3, coords);
m.setBuffer(VertexBuffer.Type.Color, 4, colors);
m.setBuffer(VertexBuffer.Type.Size, 1, sizes);
m.setStatic();
m.updateBound();
geometry = new Geometry("Point Cloud", m);
geometry.setShadowMode(ShadowMode.Off);
geometry.setQueueBucket(Bucket.Opaque);
geometry.setMaterial(mat);
geometry.updateModelBound();
Line set:
Mesh line = new Mesh();
line.setMode(Mesh.Mode.Lines);
// Line from 0,0,0 to 0,1,0
line.setBuffer(Type.Position, 3, new float[]{ (float)pos.getX(), (float)pos.getY(), (float)pos.getZ(), (float)orus3dTrajectoryPreviousPos.getX(), (float)orus3dTrajectoryPreviousPos.getY(), (float)orus3dTrajectoryPreviousPos.getZ()});
line.setBuffer(Type.Index, 2, new short[]{ 0, 1 });
line.updateBound();
Material trajectoryMat = new Material(viewer.getJMEApplication().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
trajectoryMat.getAdditionalRenderState().setWireframe(true);
trajectoryMat.getAdditionalRenderState().setLineWidth(3.0f);
com.jme3.scene.Geometry lineGeom = new com.jme3.scene.Geometry();
lineGeom.setMesh(line);
lineGeom.setMaterial(trajectoryMat);
My two concerns are about the size on points an lines. I would like to dynamically set the point size and the line width oh the displayed meshes. However, the methods related to points size and line width are deprecated within the JMonkey documentation.
For the point size, it is recommended to use shaders properties to deal with the point size I also tried another solution that was to set GL11 values as follows:
if (GL11.glIsEnabled(GL32.GL_PROGRAM_POINT_SIZE)) {
GL11.glDisable(GL32.GL_PROGRAM_POINT_SIZE);
}
GL11.glPointSize(getPointDisplaySize());
This method work for the first call to GL11 bu throws an access violation exception if i try to run it another time.
According to the mesh line width, the previous code (related to mesh line) does just do nothing (the mesh lines are always 1 pixel width.)
Can someone tell me how to handle dynamic points size and line width for meshes ?
Thanks a lot,
Julien