, Jr. Member
I am actually doing the exact same thing. Being a big fan of minecraft and doing an independent study at school for Game Programming in Flash I chose to create a game similar to minecraft. I’m actually in a similar situation to you. Trying to figure out how to draw many cubes to the screen and have it run on my graphically weak laptop (so far nothing much).
So far I look something like this:
var x:int = 0;
var y:int = 0;
var z:int = 0;
for (x = 0; x < 50; x++){
for (y = 0; y < 1; y++){
for (z = 0; z < 50; z++){
mesh = new Mesh();
//wfs = new WireframeCube(5,5,5,0xFFFFFF, 5);
//wfs = new WireframeSphere(5, 3, 3, 0xFFFFFF, 1); //_view.scene.addChild(wfs); //wfs.positi wfs.positi Vector3D(0 + (cubeG.width * x),0 + (cubeG.height * y),0 + (cubeG.depth * z)); //wfs.positi Vector3D(0 + (cubeG.width * x),0 + (cubeG.height * y),0 + (cubeG.depth * z));
//wfs.y = terrain.getHeightAt(wfs.x, wfs.z);
//wfs.y = wfs.y - (wfs.y % 20);
//wfs.y = terrain.getHeightAt(body.x, body.z);
//wfs.y = body.y - (body.y % 20);
// mesh = new Mesh();
mesh.geometry = cubeG; //mesh.positi Vector3D(15, 15 + 15*i, 15);
mesh.positi Vector3D(-1000 + (x * cubeG.width), 400 - (terrain.getHeightAt(x * cubeG.width, 300 + (z * cubeG.height)-(cubeG.height * y)), 0 + z * cubeG.depth));
Create the mesh, postion the mesh, add the mesh to the screen. Some things I was thinking about:
How to tell what meshes are actually visible. Say my camera is in the sky looking down, it will draw all the cubes underneath the first visible layer, because they are in the perspective of view but not necessarly visible. I was also thinking about finding out which meshes are closest and then set only those visible to true.
I don’t really know.