Is my mesh solution unnecessary huge?

Hi!

To create a voxel world I did like this:

I created 6 methods that creates 6 meshes for all sides of a cube.

Then to create a side/a face. I did like this:

[java]

Node world;

Mesh mesh = MeshManager.createBackFace();

Geometry geo = new Geometry (“ColoredMesh”, mesh);

Material matVC = MaterialManager.Texture(“Grass.png”);

geo.setMaterial(matVC);

geo.setLocalTranslation(position.add(new Vector3f(0,0,-.5f)));

world.attachChild(geo);[/java]

So for a cube, this line of code would have to be repeated with different methods like createFrontFace() etc.

I assume this is memory sucking peice of shit…

Because I create 4 verts for each face, whereas all verts can be combinned with another to reduce the vertcount.

But does the verts affect the cpu much or can do go with this solution?



I also tried to make it all in one mesh. Let’s just say after 30 tons of curses I quit that idea.

If each face is its own object then you will only be able to have a teeny tiny world. Not because of the vertexes but because of all of the objects.



Batching is the only way to make this work… and others have already done this and posted code.



BTW, to properly represent a cube you will need 4 vertexes per side anyway since they will need their own normals and texture coordinates.

Hum…

So your saying that I can go with this solution, I only have to call

jme3tools.optimize.GeometryBatchFactory.optimize(rootNode);

at the end to combine them all automaticly?

In theory. Try it and see what happens.

Using it will make my camera unable to see the mesh unless it’s within exacly 10 units of distance.

Even if I call:

[java]jme3tools.optimize.GeometryBatchFactory.optimize(rootNode);

rootNode.updateModelBound();

cam.setFrustumFar(100000);[/java]

It will still not change.

Not really sure whats going on if it’s not the frustumFar…

I meen, are there other variables that affects what I can and cant see?