private void initBlockTerrain() { CubesTestAssets.registerBlocks(); CubesTestAssets.initializeEnvironment(this); cubesSettings = CubesTestAssets.getSettings(this); blockTerrain = new BlockTerrainControl(cubesSettings, new Vector3Int(7, 1, 7)); blockTerrain.setBlocksFromNoise( new Vector3Int(), terrainSize, 0.8f, CubesTestAssets.BLOCK_GRASS); blockTerrain.addChunkListener( new BlockChunkListener() { @Override public void onSpatialUpdated(BlockChunkControl blockChunk) { Geometry optimizedGeometry = blockChunk.getOptimizedGeometry_Opaque(); RigidBodyControl rigidBodyControl = optimizedGeometry.getControl(RigidBodyControl.class); if (rigidBodyControl == null) { rigidBodyControl = new RigidBodyControl(0); optimizedGeometry.addControl(rigidBodyControl); bulletAppState.getPhysicsSpace().add(rigidBodyControl); } rigidBodyControl.setCollisionShape(new MeshCollisionShape(optimizedGeometry.getMesh())); } }); terrainNode.addControl(blockTerrain); terrainNode.setShadowMode(RenderQueue.ShadowMode.CastAndReceive); rootNode.attachChild(terrainNode); }
@Override public void simpleInitApp() { CubesTestAssets.registerBlocks(); BlockTerrainControl blockTerrain = new BlockTerrainControl(CubesTestAssets.getSettings(this), new Vector3Int(1, 1, 1)); blockTerrain.setBlockArea( new Vector3Int(0, 0, 0), new Vector3Int(3, 1, 1), CubesTestAssets.BLOCK_STONE); blockTerrain.setBlock(new Vector3Int(0, 0, 2), CubesTestAssets.BLOCK_GRASS); blockTerrain.setBlock(new Vector3Int(0, 0, 1), CubesTestAssets.BLOCK_GRASS); blockTerrain.setBlock(new Vector3Int(1, 0, 1), CubesTestAssets.BLOCK_GRASS); blockTerrain.setBlock(new Vector3Int(1, 0, 2), CubesTestAssets.BLOCK_GLASS); blockTerrain.setBlock(new Vector3Int(0, 1, 1), CubesTestAssets.BLOCK_WOOD_FLAT); blockTerrain.setBlock(new Vector3Int(2, 0, 1), CubesTestAssets.BLOCK_WOOD); blockTerrain.setBlock(new Vector3Int(2, 0, 2), CubesTestAssets.BLOCK_STONE); blockTerrain.setBlock(new Vector3Int(2, 1, 2), CubesTestAssets.BLOCK_STONE_PILLAR); blockTerrain.setBlock(new Vector3Int(0, 1, 0), CubesTestAssets.BLOCK_BRICK); blockTerrain.setBlock(new Vector3Int(0, 2, 0), CubesTestAssets.BLOCK_CONNECTOR_ROD); blockTerrain.setBlock(new Vector3Int(0, 3, 0), CubesTestAssets.BLOCK_BRICK); blockTerrain.setBlock(new Vector3Int(2, 1, 0), CubesTestAssets.BLOCK_BRICK); blockTerrain.setBlock(new Vector3Int(2, 2, 0), CubesTestAssets.BLOCK_CONNECTOR_ROD); blockTerrain.setBlock(new Vector3Int(2, 3, 0), CubesTestAssets.BLOCK_BRICK); blockTerrain.setBlock(new Vector3Int(1, 1, 0), CubesTestAssets.BLOCK_CONNECTOR_ROD); blockTerrain.setBlock(new Vector3Int(1, 3, 0), CubesTestAssets.BLOCK_CONNECTOR_ROD); Node terrainNode = new Node(); terrainNode.addControl(blockTerrain); rootNode.attachChild(terrainNode); cam.setLocation(new Vector3f(-7, 10, 21)); cam.lookAtDirection(new Vector3f(0.57f, -0.258f, -0.8f), Vector3f.UNIT_Y); flyCam.setMoveSpeed(50); }