I just started out with the Cubes plugin. although i ran in to some issues. I tried to make a few walls but the wall got positioned really weirdly. Maybe you guys can tell me what i’m doing wrong.
package com.shooter.main;
import com.cubes.*;
import com.cubes.test.CubesTestAssets;
import com.jme3.app.SimpleApplication;
import com.jme3.collision.CollisionResults;
import com.jme3.font.BitmapText;
import com.jme3.input.MouseInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.MouseButtonTrigger;
import com.jme3.math.Ray;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
public class BlockWorld extends SimpleApplication {
Node terrainNode = new Node();
public static void main(String[] args) {
// TODO Auto-generated method stub
BlockWorld app = new BlockWorld();
app.start(); // start the game
}
public void simpleInitApp(){
CubesTestAssets.registerBlocks();
CubesSettings settings = new CubesSettings(this);
settings.setChunkSizeX(10);
settings.setChunkSizeY(10);
settings.setChunkSizeZ(10);
BlockTerrainControl blockTerrain = new BlockTerrainControl(CubesTestAssets.getSettings(this), new Vector3Int(10, 10, 10));
buildHouse();
//blockTerrain.setBlockArea(new Vector3Int(0, 0, 0), new Vector3Int(10, 1, 10), CubesTestAssets.BLOCK_STONE);
//blockTerrain.setBlock(new Vector3Int(0, 0, 0), CubesTestAssets.BLOCK_WOOD);
//blockTerrain.setBlock(new Vector3Int(1, 0, 0), CubesTestAssets.BLOCK_WOOD);
//blockTerrain.setBlock(new Vector3Int(0, 1, 0), CubesTestAssets.BLOCK_WOOD);
//blockTerrain.setBlock(new Vector3Int(0, 0, 1), CubesTestAssets.BLOCK_WOOD);
//blockTerrain.setBlock(new Vector3Int(0, 2, 3), CubesTestAssets.BLOCK_GRASS);
//blockTerrain.setBlock(new Vector3Int(0, 0, 0), CubesTestAssets.BLOCK_GRASS);
//You can place whole areas of blocks too: setBlockArea(location, size, block)
//(The specified block will be cloned each time)
//The following line will set 3 blocks on top of each other
//({1,1,1}, {1,2,3} and {1,3,1})
// blockTerrain.setBlockArea(new Vector3Int(1, 1, 1), new Vector3Int(1, 3, 1), CubesTestAssets.BLOCK_STONE);
//Removing a block works in a similar way
//blockTerrain.removeBlock(new Vector3Int(1, 2, 1));
//blockTerrain.removeBlock(new Vector3Int(1, 3, 1));
terrainNode.addControl(blockTerrain);
rootNode.attachChild(terrainNode);
cam.setLocation(new Vector3f(-10, 10, 16));
cam.lookAtDirection(new Vector3f(1, -0.56f, -1), Vector3f.UNIT_Y);
flyCam.setMoveSpeed(50);
}
public void buildHouse(){
BlockTerrainControl Terrain = new BlockTerrainControl(CubesTestAssets.getSettings(this), new Vector3Int(1,1,1));
Terrain.setBlockArea(new Vector3Int(0, 0, 0), new Vector3Int(10, 1, 10), CubesTestAssets.BLOCK_STONE); //FLOOR
Terrain.setBlockArea(new Vector3Int(0, 1, 0), new Vector3Int(10, 5, 1), CubesTestAssets.BLOCK_WOOD); //WALL
Terrain.setBlockArea(new Vector3Int(0, 1, 0), new Vector3Int(1, 5, 10), CubesTestAssets.BLOCK_BRICK); //WALL
Terrain.setBlockArea(new Vector3Int(10, 1, 10), new Vector3Int(10, 5, 10), CubesTestAssets.BLOCK_STONE); //WALL but this wall is positioned really weirdly compared to the other walls
Node TerrainNode = new Node();
TerrainNode.addControl(Terrain);
rootNode.attachChild(TerrainNode);
}
}