[SOLVED] Why is JME culling simple models when they are still on the screen?

Hello!
I have my first experience with jm3.
This topic already existed, but I don’t manipulate anything on the camera!
I use tutorial examples. Still, I have the problem. I only defined a few points myself, nothing else.
Thank you.
My code:

public class Main1 extends SimpleApplication {
	public static void main(final String[] args) {
		final Main1 app = new Main1();
		final AppSettings settings = new AppSettings(true);
		settings.setTitle("My Awesome Game");
		app.setSettings(settings);
		app.start();
	}

	@Override
	public void simpleInitApp() {
		for (int x = 0; x < 10; x++) {
			for (int y = 0; y < 10; y++) {
				final Geometry lineGeometry = pfahlL();
				rootNode.attachChild(lineGeometry);
				final Geometry triangleGeometry = pfahlT();
				rootNode.attachChild(triangleGeometry);
				final Geometry triangleGeometry2 = sockelT();
				rootNode.attachChild(triangleGeometry2);

				lineGeometry.setLocalTranslation(x, y, 0f);
				triangleGeometry.setLocalTranslation(x, y, 0f);
				triangleGeometry2.setLocalTranslation(x, y, 0f);
			}
		}
		rootNode.updateGeometricState();
	}

	private Geometry pfahlL() {
		final short[] indexbuffer = new short[] { 0, 1, 1, 2, 2, 3, 3, 0, 0, 4, 1, 4, 2, 4, 3, 4 };
		final float[] vertexbuffer = new float[] { -0.5f, -0.5f, 0.304f, 0.5f, -0.5f, 0.004f, 0.5f, 0.5f, 0.004f, -0.5f,
				0.5f, 0.004f, 0, 0, 1.1f };
		final Mesh lineMesh = new Mesh();
		lineMesh.setMode(Mesh.Mode.Lines);
		lineMesh.setDynamic();
		lineMesh.setBuffer(VertexBuffer.Type.Position, 3, vertexbuffer);
		lineMesh.setBuffer(VertexBuffer.Type.Index, 1, indexbuffer);
		final Geometry lineGeometry = new Geometry("line", lineMesh);
		final Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); // create a simple
																								// material
		mat2.setColor("Color", ColorRGBA.Red);
		lineGeometry.setMaterial(mat2);
		return lineGeometry;
	}

	private Geometry pfahlT() {
		final short[] indexbuffer = new short[] { 0, 1, 4, 1, 2, 4, 2, 3, 4, 3, 0, 4 };
		final float[] vertexbuffer = new float[] { -0.5f, -0.5f, 0.3f, 0.5f, -0.5f, 0, 0.5f, 0.5f, 0, -0.5f, 0.5f, 0, 0,
				0, 1 };

		final Mesh triMesh = new Mesh();
		triMesh.setMode(Mesh.Mode.Triangles);
		triMesh.setDynamic();
		triMesh.setBuffer(VertexBuffer.Type.Position, 3, vertexbuffer);
		triMesh.setBuffer(VertexBuffer.Type.Index, 1, indexbuffer);
		final Geometry triGeometry = new Geometry("pfahlT", triMesh);
		final Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); // create a simple

		mat2.setColor("Color", ColorRGBA.Gray);
		triGeometry.setMaterial(mat2);

		return triGeometry;
	}

	private Geometry sockelT() {
		final short[] indexbuffer = new short[] { 1, 0, 4, 1, 4, 5, //
				2, 1, 5, 2, 5, 6, //
				3, 2, 6, 3, 6, 7, //
				0, 3, 7, 0, 7, 4 };
		final float[] vertexbuffer = new float[] { -0.5f, -0.5f, 0.3f, 0.5f, -0.5f, 0, 0.5f, 0.5f, 0, -0.5f, 0.5f, 0, //
				-0.5f, -0.5f, -6, 0.5f, -0.5f, -6, 0.5f, 0.5f, -6, -0.5f, 0.5f, -6 };
		final Mesh triMesh = new Mesh();
		triMesh.setMode(Mesh.Mode.Triangles);
		triMesh.setDynamic();
		triMesh.setBuffer(VertexBuffer.Type.Position, 3, vertexbuffer);
		triMesh.setBuffer(VertexBuffer.Type.Index, 1, indexbuffer);
		final Geometry triGeometry = new Geometry("sockelT", triMesh);
		final Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); // create a simple
																								// material
		mat2.setColor("Color", ColorRGBA.LightGray);
		triGeometry.setMaterial(mat2);
		return triGeometry;
	}

	@Override
	public void simpleUpdate(final float tpf) {
		// TODO: add update code
	}

}
2 Likes

First: How to type code blocks for next time or if you want to edit your post to make it readable.

Second: the issue is that your mesh bound is not updated. Call Mesh (jMonkeyEngine3)

…after creating your mesh.

1 Like

Please excuse the formatting, thanks for the very quick response. Post edited.

1 Like

like Paul mentioned, try updateBound on mesh.

yes, thanks, worked immediately. Beginner mistakes …

3 Likes

Yeah, but your post was almost perfect… so you got a nice quick answer. :slight_smile:

I knew what the problem was just from the title.

3 Likes