Let's Play With Cubes!

I have recently started to create a voxel engine to learn more about 3d and LibGDX. I thought I would post my discoveries, as well as questions here to hopefully help future LibGDX/3D users on their journey.

Well I started simple, just rendering a small 1x1x1 cube using a MeshPartBuilder:


http://i1173.photobucket.com/albums/r594/Slyth2727/Screenshotfrom2013-08-15220633.png

Then I decided to render a simple “chunk” just using 3 for loops:


http://i1173.photobucket.com/albums/r594/Slyth2727/Screenshotfrom2013-08-15220717.png

Why not make them smaller? Remind you of a particular minecraft map?


http://i1173.photobucket.com/albums/r594/Slyth2727/Screenshotfrom2013-08-15221135.png

Do you like candy?


http://i1173.photobucket.com/albums/r594/Slyth2727/Screenshotfrom2013-08-15221213.png

Next I would like to optimize, make a chunk system, as well as implement noise of some sort.(I’m running at 10-20 FPS and I have a rather nice computer :wink: )

Here is my current create and render code:

Create:


		ModelBuilder modelBuilder = new ModelBuilder();
		MeshPartBuilder builder;
		for (float x = GRID_MIN; x <= GRID_MAX; x += 1) {
			for (float y = GRID_MIN; y <= GRID_MAX; y += 1) {
				for (float z = GRID_MIN; z <= GRID_MAX; z += 1) {
					modelBuilder.begin();

					builder = modelBuilder.part("grid", GL10.GL_TRIANGLES, Usage.Position | Usage.Normal, new Material(ColorAttribute.createDiffuse(new Color(MathUtils.random(0, 1), MathUtils.random(0, 1), MathUtils.random(0, 1), 0))));
					builder.setColor(Color.GREEN);
					builder.box(x, y, z, .1f, .1f, .1f);
					models.add(modelBuilder.end());

					instances.add(new ModelInstance(models.get(models.size() - 1)));
				}
			}
		}

Render:


		logger.log();
		if (loading && assets.update()) {
			loading = false;
			onLoaded();
		}

		if (Gdx.input.isKeyPressed(Keys.CONTROL_LEFT)) {
			inputController.setVelocity(25);
		} else {
			inputController.setVelocity(5);
		}

		inputController.update();

		Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

		modelBatch.begin(cam);
		modelBatch.render(instances, lights);
		modelBatch.end();

What do you think I can do for optimization?