private static GameObject CreateShip(VoxelTypes types, MaterialInstance materialInstance) { var gridLength = 4; var voxelSize = 1; var voxelSpaceData = new VoxelGridData(gridLength, gridLength, gridLength, voxelSize); voxelSpaceData[0, 0, 0] = new Voxel() { Exists = true }; var voxelSpace = new VoxelSpace(new Vector3i(gridLength, gridLength, gridLength), voxelSize); var spaceShip = new GameObject("Single Block"); spaceShip.AddComponent(voxelSpace); spaceShip.AddComponent(new DynamicVoxelSpaceBody()); spaceShip.AddComponent(new Construct()); spaceShip.AddComponent(new ConstructFlightControl()); spaceShip.AddComponent(new ConstructVoxelSpaceExpander(types, materialInstance)); var voxelGridObj = new GameObject($"{spaceShip.Name} Voxel Grid"); voxelGridObj.AddComponent(new VoxelGrid(voxelSpaceData, new Dictionary <Vector3i, GameObject>())); voxelGridObj.AddComponent(new VoxelMeshRenderable(types, materialInstance)); //voxelGridObj.AddComponent(new VoxelGridRenderable(types, materialInstance)); voxelSpace.Add(new Vector3i(0, 0, 0), voxelGridObj); return(spaceShip); }
public void Update(float time) { var position = _player.Transform.WorldPosition; SetCenterChunk((int)MathF.Floor(position.X / _chunkLength), (int)MathF.Floor(position.Y / _chunkLength), (int)MathF.Floor(position.Z / _chunkLength)); //SetCenterChunk(0, 0, 0); while (_chunksToAdd.TryDequeue(out Chunk chunk)) { _chunkMap[chunk.Coordinates] = chunk; _worldSpace.Add(chunk.Coordinates, chunk.GameObject); } }