BlockZ another Block/Voxel Engine

Hi i want to contibute my curent work.

For more information take a look here:
http://hub.jmonkeyengine.org/forum/topic/myblockz/

For the lazy ones:

I prepared some quicksetups to testout some stuff. So to get it startet just this in a simpleapplication:

[java]
Setup s;
CharacterControl chara;

@Override
public void simpleInitApp() {

    BulletAppState bulletAppState = new BulletAppState();
    stateManager.attach(bulletAppState);
   

    s = new Setup();

// chara = s.charackterSetup(inputManager, rootNode, bulletAppState.getPhysicsSpace(), assetManager, cam, this, flyCam);
// s.flyCamSetup(inputManager, rootNode, bulletAppState.getPhysicsSpace(), assetManager, cam, this, flyCam);
chara = s.charackterSimpleFloorSetup(inputManager, rootNode, bulletAppState.getPhysicsSpace(), assetManager, cam, this, flyCam, 16, 16);

}

@Override
public void simpleUpdate(float tpf) {
    s.updateMe(tpf);
    

}

[/java]

The uncommented lines can be switched for another Setup.
charackterSetup is with a heightmap and third person charactercontrol
flyCamSetup ist with a heightmap and flycam
charackterSimpleFloorSetup is just one layer of Tiles

The last ints in charackterSimpleFloorSetup are tilebuffer and tilessize.
Tilebuffer will create tilebuffer * tilebuffer * tilebuffer buffer for Tiles and limits the visible world
Tilesize sets the umber of Blocks in one Tile and will create tilesize * 1 * tilesize blocks per Tile.

To get access to to tiles/blocks call
[java]
Tilemanager tm = TileManager.getInstace();
[/java]

Before the TileManger can be used it needs to be intialized:

[java]
public static void init(PhysicsSpace physicSpace, Node tileManagerRootNode, Application app, Rowedtexture texture, Material blockMaterial, int tileBufferSize, int tilesize)
[/java]
I use one texture for all Blocks in each row there are six squares with block texture.
Which results in RowedTexture, it just needs the number of rows contained in the textures.

TileManager gives easy ways to add and remove Voxels:

[java]
public void addVoxel(VoxelType type, Vector3f position);
public Tile removeVoxel(Vector3f position);
[/java]

Note:Voxeltype is a class which holds just one int for the row to be choosen from the rowedtexture.

This both Methods will add/remove a voxel and update the geomery and collisionshape (needs some more work on that :wink: ).
They are not ment as generation Methods!
To generate a world use:
[java]
VoxelType[][] vt = new VoxelType[Tile.getSize()][Tile.getSize()];
//fill vt here
Vector3i tilePosition = new Vector3i(x, y, z);
tm.addTile(tilePosition);
Tile t = tm.getTile(tilePosition);
t.generate(vt);
t.getGeometry().setMaterial(yourRowedMaterial);
[/java]

Ok now that i have written it down it look quite more complicated that i wated it to be.
Hope you still enjoy!

Download:
https://dl.dropbox.com/u/770447/code/projects/BlockZ.jar

2 Likes