Custom mesh becoming invisible

Hello,



I’ve been trying to make my own mesh using the Custom mesh shapes documentation.

Instead of a quad I tried to make a triangle which gets displayed as I wanted. However, when I move the camera so that point (0,0,0) is not in the view anymore, my triangle will just become invisible. I guess I did some mistake transforming the mesh into a triangle, but what is it?



This is how I create the mesh:



[java]Mesh m = new Mesh();



Vector3f[] vertices = new Vector3f[3];

vertices[0] = new Vector3f(1, 1, 0);

vertices[1] = new Vector3f(2, 1, 0);

vertices[2] = new Vector3f(1, 2, 0);



Vector2f[] texCoord = new Vector2f[3];

texCoord[0] = new Vector2f(0, 0);

texCoord[1] = new Vector2f(1, 0);

texCoord[2] = new Vector2f(0, 1);



int[] indexes = { 0, 1, 2 };



m.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(vertices));

m.setBuffer(Type.TexCoord, 2, BufferUtils.createFloatBuffer(texCoord));

m.setBuffer(Type.Index, 1, BufferUtils.createIntBuffer(indexes));



Geometry geom = new Geometry(“Tri”, m);

Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

mat.setColor(“Color”, ColorRGBA.Blue);

geom.setMaterial(mat);[/java]

Try calling m.updateBound(); after setting the buffers.

Thank you, for some reason I didnt see that in the full code sample, sorry. Maybe it should be added in the documentation.

What exactly does that method do?

It updates the bounding info so that the culling mechanism knows the extent of the object and can cull it correctly when its out of the cameras view. Before it was like a point and so when only its center wasn’t visible it would be culled.