Hello all,
I’m working on some very simple code, and I’ve noticed a problem I’m having. Whenever I turn the camera too much to one side or the other, lines that I’ve drawn between sphere disappear. Please see images here for what I mean. http://imgur.com/a/6Wp7v
Lines are created by the following code:
Mesh lineMesh = new Mesh();
lineMesh.setMode(Mesh.Mode.Lines);
lineMesh.setBuffer(VertexBuffer.Type.Position, 3, new float[]{x0, y0, z0, x1, y1, z1});
lineMesh.setBuffer(VertexBuffer.Type.Index, 2, new short[]{0, 1});
Geometry lineGeometry = new Geometry(“line”, lineMesh);
Material lineMaterial = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
lineMaterial.setColor(“Color”, ColorRGBA.White);
lineGeometry.setMaterial(lineMaterial);
return lineGeometry;
and attached to the root node like so:
rootNode.attachChild(makeLineFunction( [parmaters] ));
Does anyone know why they’re not rendered? A more significant problem being that the whole grouping of lines suddenly disappears, even when some should still be visible.
1 Like
[java]
Mesh lineMesh = new Mesh();
lineMesh.setMode(Mesh.Mode.Lines);
lineMesh.setBuffer(VertexBuffer.Type.Position, 3, new float[]{x0, y0, z0, x1, y1, z1});
lineMesh.setBuffer(VertexBuffer.Type.Index, 2, new short[]{0, 1});
Geometry lineGeometry = new Geometry(“line”, lineMesh);
Material lineMaterial = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
lineMaterial.setColor(“Color”, ColorRGBA.White);
lineGeometry.setMaterial(lineMaterial);
return lineGeometry;
[/java]
The code, again, sorry I didn’t know about the java tags.
1 Like
Try: http://hub.jmonkeyengine.org/javadoc/com/jme3/scene/Mesh.html#updateBound()
It acts like the bounding shape is incorrect.
1 Like
That was precisely it, thank you very much!
1 Like