Creating floor

I need to create a floor “the right way”. Before, I was using a Box to draw the floor. I noticed when I deleted it that my performance and fps improved dramatically. Is there a good way to draw the floor without losing performance? It is a static large floor.

I create a custom mesh (just a normal plane positioned at ground), tutorial can be found here.

Just make sure to reuse the material, you don’t want to create a new material for every piece of floor you have (if you want to remove/add floor), that would take up a lot of ram in the end. Easiest way imo is to use a public material variable with the material loaded from assetManager.

You want some code for it? Here’s mine.


private Geometry createFloorPiece(Vector2f position)


Mesh m = new Mesh();

Vector3f[] vertices = new Vector3f[4];

vertices[0] = new Vector3f(position.x - 0.5f, 0.1f, position.y - 0.5f); //–

vertices[1] = new Vector3f(position.x - 0.5f, 0.1f, position.y + 0.5f); //-+

vertices[2] = new Vector3f(position.x + 0.5f, 0.1f, position.y - 0.5f); //±

vertices[3] = new Vector3f(position.x + 0.5f, 0.1f, position.y + 0.5f); //++

Vector3f[] normals = new Vector3f[4];

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

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

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

normals[3] = new Vector3f(0, 1, 0);

Vector2f[] texCoord = new Vector2f[4];

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

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

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

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

int[] indexes = {

2, 0, 1, 1, 3, 2


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

m.setBuffer(Type.Normal, 3, BufferUtils.createFloatBuffer(normals));

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

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


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

return geom;


Keep in mind that this function is for creating a tile on a large floor, made of something like 70*50 pieces, hence the Vector2f positioning.

Just use a quad. If you want a very simple, flat, surface.

Obviously Quad is more efficient so I’d like to use it however my previous code was:

Box floor = new Box(boxCenter, boxX, boxY, boxZ);

the constructor of Quad does not take a Center and it does not contain a method setCenter. Any work around that?


quad.setLocalTranslation(x,y,z); Just shift it by half the quad size.

Also, the performance between a single box and a quad should not be noticeable. If it is, something is very wrong with your code or your machine is having issues.

If you have low fps with only 1 mesh, then your computer has a problem.

if you have 10000 boxes that create the floor, you need to use GeometryBatchFactory.optimize(); to optimize it into 1 mesh.

Use a BatchNode, it allows you to use the Geometry objects but in fact creates one big mesh of all.