Пример #1
0
    void Awake()
    {
        log.Info("Starting Voxel Valley!");

        VoxelManager.LoadVoxels();
        StructureManager.LoadStructures();
    }
Пример #2
0
 public void DisplayData()
 {
     for (int i = 0; i < DisplaySize; i++)
     {
         for (int j = 0; j < DisplaySize; j++)
         {
             for (int k = 0; k < DisplaySize; k++)
             {
                 GameObject g = (GameObject)Instantiate(Resources.Load("DisplayCube"), new Vector3(i, j, k), Quaternion.identity, debug);
                 g.transform.localScale = new Vector3(1 / 10f, 1 / 10f, 1 / 10f);
                 g.GetComponent <Renderer>().material.color = ((Voxel)data[VoxelManager.getIndex(i, j, k, DisplaySize)]).color;
                 if (useTestData)
                 {
                     Vector3Int pos   = new Vector3Int(i, j, k);
                     int        index = 0;
                     if (pos == new Vector3Int(0, 0, 0))
                     {
                         index = 0;
                     }
                     else if (pos == new Vector3Int(1, 0, 0))
                     {
                         index = 1;
                     }
                     else if (pos == new Vector3Int(1, 1, 0))
                     {
                         index = 2;
                     }
                     else if (pos == new Vector3Int(0, 1, 0))
                     {
                         index = 3;
                     }
                     else if (pos == new Vector3Int(0, 0, 1))
                     {
                         index = 4;
                     }
                     else if (pos == new Vector3Int(1, 0, 1))
                     {
                         index = 5;
                     }
                     else if (pos == new Vector3Int(1, 1, 1))
                     {
                         index = 6;
                     }
                     else if (pos == new Vector3Int(0, 1, 1))
                     {
                         index = 7;
                     }
                     g.GetComponent <TextMesh>().text = index.ToString();
                 }
                 else
                 {
                     g.GetComponent <TextMesh>().text = (i + j * DisplaySize + k * DisplaySize * DisplaySize).ToString();
                 }
             }
         }
     }
 }
Пример #3
0
    private void Collect(Collider other)
    {
        VoxelManager voxel = other.GetComponent <VoxelManager>();        //TODO Replace voxel GetComponents with voxel registry

        voxel.Rigidbody.isKinematic = true;
//		voxel.Rigidbody.velocity = Vector3.zero;
        voxel.transform.SetParent(_gun.transform, true);
        voxel.owner            = this;
        voxel.gameObject.layer = SceneManager.Instance.playerProjectileLayer;
        _collectedVoxels.Add(voxel);
    }
Пример #4
0
 internal override ushort GetVoxel(int x, int y, int z, ushort height)
 {
     if (y < height)
     {
         return(VoxelManager.GetVoxel("debug_red").Id);
     }
     else
     {
         return(VoxelManager.AirVoxel);
     }
 }
 static int GetCubeCorner(int[] data, int chunkSize, int i, int j, int k)
 {
     try
     {
         return(data[VoxelManager.getIndex(i, j, k, chunkSize)]);
     }
     catch (System.Exception)
     {
         Debug.LogError(string.Format("Cube corner out of bounds: {0} {1} {2}", i, j, k));
         return(0);
     }
 }
Пример #6
0
        public PlayingState()
        {
            gui          = new Gui();
            world        = new World();
            voxelManager = new VoxelManager();
            client       = GameEngine.GetInstance().Client;
            client.SetWorld(world);
            worldRenderer = new Renderer(GameEngine.GetInstance().GraphicsDevice);

            movement = new MouseKeyboardStrategy(GameEngine.GetInstance().Camera, GameEngine.GetInstance().InputManager);
            GenerateWorld();
        }
Пример #7
0
        public void init()
        {
            sunLight = new LightSun(new Vector3(0.1f, 0.125f, 0.2f) * 3f, this);
            sunLight.lightAmbient      = new Vector3(0.1f, 0.125f, 0.2f) * 0.5f;//new Vector3(0.2f, 0.125f, 0.1f);//new Vector3(0.1f, 0.14f, 0.3f);
            sunLight.PointingDirection = Vector3.Normalize(new Vector3(674, -674, 1024));
            sunFrameBuffer             = gameWindow.framebufferCreator.createFrameBuffer("shadowFramebuffer", shadowRes * 2, shadowRes * 2, PixelInternalFormat.Rgba8, false);
            sunInnerFrameBuffer        = gameWindow.framebufferCreator.createFrameBuffer("shadowFramebuffer", shadowRes * 2, shadowRes * 2, PixelInternalFormat.Rgba8, false);


            mFilter2d = new Quad2d(this);

            mSkyModel = new Skybox(this, gameWindow);

            mGroundPlane = new GroundPlane(this);
            mGroundPlane.setMaterial("floor.xmf");

            mGroundPlane.setMesh("water_plane.obj");
            mGroundPlane.setMaterial("floor.xmf");

            //need to be fixed -- cant be executed after voxel Manager creation.

            if (Settings.Instance.video.Particles)
            {
                generateParticleSys();
            }

            voxelManager = new VoxelManager(this);

            compositeMod.X = Settings.Instance.video.gamma;

            particleAffectors.Add(new ParticleAffectorWind(new Vector3(1, -0.5f, 0) * 0.01f));
            particleAffectors.Add(new ParticleAffectorFriction(0.1f));
            particleAffectors.Add(new ParticleAffectorFloorKiller(waterLevel));
            particleAffectors.Add(new ParticleAffectorLifeTimeKiller(this));

            /*
             *  waterModel.setTextures(mTextureLoader.fromMixed(new int[]{
             *  TextureGroup.TYPE_FRAMEBUFFER,
             *  TextureGroup.TYPE_FROMFILE},
             *  new string[] {
             *      Convert.ToString(waterFramebuffer.ColorTexture),
             *      "noise.png"}));
             */

            mGroundPlane.Position = new Vector3(0, waterLevel, 0);
            //mGroundPlane.updateModelMatrix();

            Matrix4 translate = Matrix4.CreateTranslation(0, -waterLevel * 2, 0);
            Matrix4 invert    = Matrix4.Scale(1, -1, 1);

            Matrix4.Mult(ref translate, ref invert, out mWaterMatrix);
        }
Пример #8
0
    private void FirePulse()
    {
        _audioSource.Play();
        VoxelManager pulse = Instantiate(_projectilePrefab, transform.position, transform.rotation) as VoxelManager;

        pulse.Initialize(this);
        Debug.Log("rigidbody: " + (pulse.Rigidbody == null ? " null" :  "thing"));
        Debug.Log("head position: " + SceneManager.Instance.player.head.transform.position);

        Vector3 velocity = (SceneManager.Instance.player.head.transform.position - transform.position) * pulseSpeed;

        Debug.Log("velocity" + velocity);
        pulse.Rigidbody.velocity = velocity;
    }
Пример #9
0
    private void Awake()
    {
        if (null != sInstance && this != sInstance)
        {
            Destroy(this.gameObject);
        }

        sInstance = this;
        DontDestroyOnLoad(this.gameObject);

        if (null == mMapData)
        {
            Vector3 newMapSize = mMapSize * mChunkSize;
            mMapData = new byte[(int)newMapSize.x, (int)newMapSize.y, (int)newMapSize.z];
        }

        GenerateMapData();
    }
Пример #10
0
    void ApplyVertexToggle()
    {
        GUILayout.Label("Test Data Vertices");
        for (int i = 0; i < dv.DisplaySize; i++)
        {
            GUILayout.BeginHorizontal(i.ToString(), GUILayout.Height(10));

            for (int j = 0; j < dv.DisplaySize; j++)
            {
                for (int k = 0; k < dv.DisplaySize; k++)
                {
                    //Debug.Log(string.Format("x{0},y{1},z{2}", i, j, k));
                    int index = VoxelManager.getIndex(k, j, i, dv.DisplaySize);
                    dv.testData[index] = GUILayout.Toggle(((Voxel)dv.testData[index]).opaque, "") ? Voxel.FILLED.Id : Voxel.EMPTY.Id;
                }
            }
            GUILayout.EndHorizontal();
        }
    }
    public int[] GenerateData(int size, float scale, Vector3Int startPos)
    {
        startPos.x *= (size - 1);
        startPos.y *= (size - 1);
        startPos.z *= (size - 1);

        int[] data = new int[size * size * size];
        for (int i = 0; i < size; i++)
        {
            for (int j = 0; j < size; j++)
            {
                for (int k = 0; k < size; k++)
                {
                    data[VoxelManager.getIndex(i, j, k, size)] = DataAtPoint((i + startPos.x) / (float)size * scale, (j + startPos.y) / (float)size * scale, (k + startPos.z) / (float)size * scale);
                }
            }
        }

        return(data);
    }
Пример #12
0
        public void initFields()
        {
            instance             = this;
            voxelEngine          = new VoxelManager();
            entityEngine         = new EntityManager();
            Cursor.visible       = false;
            EngineInstance       = this;
            ChunkManagerInstance = GetComponent <ChunkManager>();

            WorldName = lWorldName;
            UpdateWorldPath();

            BlocksPath = lBlocksPath;
            Blocks     = lBlocks;

            TargetFPS            = lTargetFPS;
            MaxChunkSaves        = lMaxChunkSaves;
            MaxChunkDataRequests = lMaxChunkDataRequests;

            TextureUnit              = lTextureUnit;
            TexturePadding           = lTexturePadding;
            GenerateColliders        = lGenerateColliders;
            ShowBorderFaces          = lShowBorderFaces;
            EnableMultiplayer        = lEnableMultiplayer;
            MultiplayerTrackPosition = lMultiplayerTrackPosition;
            SaveVoxelData            = lSaveVoxelData;
            GenerateMeshes           = lGenerateMeshes;

            ChunkSpawnDistance   = lChunkSpawnDistance;
            HeightRange          = lHeightRange;
            ChunkDespawnDistance = lChunkDespawnDistance;

            SendCameraLookEvents = lSendCameraLookEvents;
            SendCursorEvents     = lSendCursorEvents;

            ChunkSideLength   = lChunkSideLength;
            SquaredSideLength = lChunkSideLength * lChunkSideLength;
        }
Пример #13
0
    private void initialize()
    {
        //initialize v chunk lists

        animatedVoxels = new List <AnimatedVoxel>();

        GameObject landChunk = makeGameObjectWithPosition(new Vector3(0, 0, 0));

        landChunk.name = "landChunk";

        GameObject waterChunk = makeGameObjectWithPosition(new Vector3(0, 5, 10));

        waterChunk.name = "waterChunk";

        GameObject lavaChunk = makeGameObjectWithPosition(new Vector3(50, 5, 50));

        lavaChunk.name = "lavaChunk";

        animatedVoxels = new List <AnimatedVoxel>();

        Material lavaMat = Resources.Load("LavaVoxelMat") as Material;
        Material landMat = Resources.Load("LandVoxelMat") as Material;


        IEnumerable <LandVoxel>  lv  = VoxelManager.generate <LandVoxel>(landChunk, landMat, 100);
        IEnumerable <WaterVoxel> wv  = VoxelManager.generate <WaterVoxel>(waterChunk, lavaMat, 10);
        IEnumerable <LavaVoxel>  lvv = VoxelManager.generate <LavaVoxel>(lavaChunk, lavaMat, 10);

        foreach (WaterVoxel v in wv)
        {
            animatedVoxels.Add(v);
        }

        foreach (LavaVoxel l in lvv)
        {
            animatedVoxels.Add(l);
        }
    }
Пример #14
0
    protected override void OnTriggerClicked(object sender, ClickedEventArgs e)
    {
        audioSource.Play();
        device.TriggerHapticPulse(HAPTIC_FORCE);

        RaycastHit hit;

        Debug.DrawRay(bulletOrigin.position, bulletOrigin.forward, Color.cyan, 3f);
        if (Physics.Raycast(bulletOrigin.position, bulletOrigin.forward, out hit, RANGE))
        {
            if (hit.collider.gameObject.layer != SceneManager.Instance.enemyLayer)
            {
                Debug.Log("hit non-enemy: " + hit.collider.gameObject.name);
                return;
            }
            Debug.Log("hit enemy: " + hit.collider.gameObject.name);
            VoxelManager voxel = hit.collider.GetComponent <VoxelManager>();
            voxel.TakeDamage(DAMAGE, bulletOrigin, BLAST_FORCE);
        }
        else
        {
            Debug.Log("miss");
        }
    }
    private void Update()
    {
        performActionFloat = SteamVR_Actions.picross.PerformActionFloat[SteamVR_Input_Sources.Any].axis;
        performAction      = performActionFloat > 0.8f;

        if (_hovering && !selected)
        {
            if (_voxelManagerGameObject == null)
            {
                _voxelManagerGameObject = GameObject.FindGameObjectWithTag("VoxelManager");
            }

            VoxelManager _voxelManager = _voxelManagerGameObject.GetComponent <VoxelManager>();

            if (currentModeSelectButton == ModeSelectButton.Mark)
            {
                if (_voxelManager.CurrentGameMode == VoxelManager.GameMode.Mark)
                {
                    Debug.Log("mark Don't do anything!");
                }
                else
                {
                    Instantiate(_switchModeSound);
                    GameObject.FindGameObjectWithTag("Destroy").GetComponent <MeshRenderer>().material       = _unselectedMaterial;
                    GameObject.FindGameObjectWithTag("Build").GetComponent <MeshRenderer>().material         = _unselectedMaterial;
                    GameObject.FindGameObjectWithTag("Destroy").GetComponent <ChangeModeSelector>().selected = false;
                    GameObject.FindGameObjectWithTag("Build").GetComponent <ChangeModeSelector>().selected   = false;
                    selected = true;
                    // Change GameMode
                    _voxelManager.CurrentGameMode = VoxelManager.GameMode.Mark;
                    _voxelManager.MakeMarkable();
                    _meshRenderer.material = _selectedMaterial;
                }
            }

            if (currentModeSelectButton == ModeSelectButton.Destroy)
            {
                if (_voxelManager.CurrentGameMode == VoxelManager.GameMode.Destroy)
                {
                    Debug.Log("destroy Don't do anything!");
                }
                else
                {
                    Instantiate(_switchModeSound);
                    GameObject.FindGameObjectWithTag("Mark").GetComponent <MeshRenderer>().material        = _unselectedMaterial;
                    GameObject.FindGameObjectWithTag("Build").GetComponent <MeshRenderer>().material       = _unselectedMaterial;
                    GameObject.FindGameObjectWithTag("Mark").GetComponent <ChangeModeSelector>().selected  = false;
                    GameObject.FindGameObjectWithTag("Build").GetComponent <ChangeModeSelector>().selected = false;
                    selected = true;
                    _voxelManager.CurrentGameMode = VoxelManager.GameMode.Destroy;
                    _voxelManager.MakeDestroyable();
                    _meshRenderer.material = _selectedMaterial;
                }
            }

            if (currentModeSelectButton == ModeSelectButton.Build)
            {
                if (_voxelManager.CurrentGameMode == VoxelManager.GameMode.Build)
                {
                    Debug.Log("build Don't do anything!");
                }
                else
                {
                    Instantiate(_switchModeSound);
                    GameObject.FindGameObjectWithTag("Destroy").GetComponent <MeshRenderer>().material       = _unselectedMaterial;
                    GameObject.FindGameObjectWithTag("Mark").GetComponent <MeshRenderer>().material          = _unselectedMaterial;
                    GameObject.FindGameObjectWithTag("Destroy").GetComponent <ChangeModeSelector>().selected = false;
                    GameObject.FindGameObjectWithTag("Mark").GetComponent <ChangeModeSelector>().selected    = false;
                    selected = true;
                    _voxelManager.CurrentGameMode = VoxelManager.GameMode.Build;
                    _voxelManager.MakeBuildable();
                    _meshRenderer.material = _selectedMaterial;
                }
            }
        }
    }
    public static void MarchingCubes(int[] data, int chunkSize, out Vector3[] verts, out int[] tris, out Color[] cols)
    {
        List <Vector3> _verts = new List <Vector3>();
        List <Color>   _col   = new List <Color>();
        List <int>     _tris  = new List <int>();

        int triCount = 0;


        //Debug.Log(string.Format("{0} , {1}, {2}", data.GetLength(0), data.GetLength(1), data.GetLength(2)));
        int flag = 0;

        for (int i = 0; i < chunkSize - 1; i++)
        {
            for (int j = 0; j < chunkSize - 1; j++)
            {
                for (int k = 0; k < chunkSize - 1; k++)
                {
                    if (i > 55)
                    {
                        //Debug.Log(string.Format("{0} , {1}, {2}", i, j, k));
                    }
                    Vector3 startPos = new Vector3(i, j, k);
                    int[]   corners  = CubeCorners(data, i, j, k, chunkSize);
                    //0-7 Control Nodes
                    flag = 0;
                    for (int c = 0; c < 8; c++)
                    {
                        if (!((Voxel)corners[c]).opaque)
                        {
                            flag |= 1 << c;
                        }
                    }

                    if (flag == 0x00 || flag == 0xFF)
                    {
                        //Debug.Log("No flag");
                        continue;
                    }

                    //Debug.Log("Flag: " + flag);
                    for (int tri = 0; tri < 5; tri++)
                    {
                        int edgeI = EdgeIndexFromConfig[flag, 3 * tri];
                        if (edgeI < 0)
                        {
                            break;
                        }


                        for (int v = 0; v < 3; v++)
                        {
                            edgeI = EdgeIndexFromConfig[flag, 3 * tri + v];

                            //Each vertex has two edges connected
                            Vector3 edgeVert1 = edgeVertexOffsets[edgeI, 0], edgeVert2 = edgeVertexOffsets[edgeI, 1];

                            _verts.Add(startPos + (edgeVert1 + edgeVert2) * 0.5f);
                            _tris.Add(triCount++);
                            _col.Add(((Voxel)data[VoxelManager.getIndex(i, j, k, chunkSize)]).color);
                        }
                    }
                }
            }
        }

        verts = _verts.ToArray();
        tris  = _tris.ToArray();
        cols  = _col.ToArray();
    }
Пример #17
0
 public void SetManager(VoxelManager _manager, int _x, int _y, int _z)
 {
     this.cm    = _manager;
     this.index = new Vector3Int(_x, _y, _z);
 }
Пример #18
0
 public Voxel(string voxel, int[] position)
 {
     this.voxel    = VoxelManager.GetVoxel(voxel).Id;
     this.position = new Vector3Int(position[0], position[1], position[2]);
 }
Пример #19
0
        void GetMeshData(int x, int y, int z)
        {
            int addedVertices = 0;
            int indiceOffset  = vertices.Count;

            //Left
            if (IsSolid(x, y, z - 1))
            {
                vertices.Add(new Vector3(x + 0, y + 0, z + 0));
                vertices.Add(new Vector3(x + 1, y + 1, z + 0));
                vertices.Add(new Vector3(x + 1, y + 0, z + 0));
                vertices.Add(new Vector3(x + 0, y + 1, z + 0));

                indices.AddRange(new int[] { indiceOffset + 0, indiceOffset + 1, indiceOffset + 2, indiceOffset + 0, indiceOffset + 3, indiceOffset + 1 });
                normals.AddRange(new Vector3[] { -Vector3.UnitZ, -Vector3.UnitZ, -Vector3.UnitZ, -Vector3.UnitZ });

                addedVertices += 4;
                indiceOffset  += 4;
            }
            //Right
            if (IsSolid(x, y, z + 1))
            {
                vertices.Add(new Vector3(x + 0, y + 0, z + 1));
                vertices.Add(new Vector3(x + 1, y + 0, z + 1));
                vertices.Add(new Vector3(x + 1, y + 1, z + 1));
                vertices.Add(new Vector3(x + 0, y + 1, z + 1));

                indices.AddRange(new int[] { indiceOffset + 0, indiceOffset + 1, indiceOffset + 2, indiceOffset + 0, indiceOffset + 2, indiceOffset + 3 });
                normals.AddRange(new Vector3[] { Vector3.UnitZ, Vector3.UnitZ, Vector3.UnitZ, Vector3.UnitZ });

                addedVertices += 4;
                indiceOffset  += 4;
            }
            //Front
            if (IsSolid(x - 1, y, z))
            {
                vertices.Add(new Vector3(x + 0, y + 0, z + 0));
                vertices.Add(new Vector3(x + 0, y + 1, z + 1));
                vertices.Add(new Vector3(x + 0, y + 1, z + 0));
                vertices.Add(new Vector3(x + 0, y + 0, z + 1));

                indices.AddRange(new int[] { indiceOffset + 0, indiceOffset + 1, indiceOffset + 2, indiceOffset + 0, indiceOffset + 3, indiceOffset + 1 });
                normals.AddRange(new Vector3[] { -Vector3.UnitX, -Vector3.UnitX, -Vector3.UnitX, -Vector3.UnitX });

                addedVertices += 4;
                indiceOffset  += 4;
            }
            //Back
            if (IsSolid(x + 1, y, z))
            {
                vertices.Add(new Vector3(x + 1, y + 0, z + 0));
                vertices.Add(new Vector3(x + 1, y + 1, z + 0));
                vertices.Add(new Vector3(x + 1, y + 1, z + 1));
                vertices.Add(new Vector3(x + 1, y + 0, z + 1));

                indices.AddRange(new int[] { indiceOffset + 0, indiceOffset + 1, indiceOffset + 2, indiceOffset + 0, indiceOffset + 2, indiceOffset + 3 });
                normals.AddRange(new Vector3[] { Vector3.UnitX, Vector3.UnitX, Vector3.UnitX, Vector3.UnitX });

                addedVertices += 4;
                indiceOffset  += 4;
            }
            //Bottom
            if (IsSolid(x, y - 1, z))
            {
                vertices.Add(new Vector3(x + 0, y + 0, z + 0));
                vertices.Add(new Vector3(x + 1, y + 0, z + 0));
                vertices.Add(new Vector3(x + 1, y + 0, z + 1));
                vertices.Add(new Vector3(x + 0, y + 0, z + 1));

                indices.AddRange(new int[] { indiceOffset + 0, indiceOffset + 1, indiceOffset + 2, indiceOffset + 0, indiceOffset + 2, indiceOffset + 3 });
                normals.AddRange(new Vector3[] { -Vector3.UnitY, -Vector3.UnitY, -Vector3.UnitY, -Vector3.UnitY });

                addedVertices += 4;
                indiceOffset  += 4;
            }
            //Top
            if (IsSolid(x, y + 1, z))
            {
                vertices.Add(new Vector3(x + 1, y + 1, z + 0));
                vertices.Add(new Vector3(x + 0, y + 1, z + 0));
                vertices.Add(new Vector3(x + 1, y + 1, z + 1));
                vertices.Add(new Vector3(x + 0, y + 1, z + 1));

                indices.AddRange(new int[] { indiceOffset + 1, indiceOffset + 2, indiceOffset + 0, indiceOffset + 1, indiceOffset + 3, indiceOffset + 2 });
                normals.AddRange(new Vector3[] { Vector3.UnitY, Vector3.UnitY, Vector3.UnitY, Vector3.UnitY });

                addedVertices += 4;
                indiceOffset  += 4;
            }

            if (addedVertices > 0)
            {
                Vector4b voxelColor = VoxelManager.GetVoxel(parentChunk.voxels[x, y, z]).Color;
                for (int i = 0; i < addedVertices; i++)
                {
                    colors.Add(voxelColor);
                }
            }
        }
 private void Awake()
 {
     _vm = this;
     vdm = new DataGenerator(worldSize.y);
     OctreeNode.Init();
 }
Пример #21
0
        void GetMeshData(int x, int y, int z)
        {
            int addedVertices = 0;
            int indiceOffset  = Vertices.Count;

            //Left
            if (IsSolid(x, y, z - 1))
            {
                Vertices.Add(new Vector3(x + 0, y + 0, z + 0));
                Vertices.Add(new Vector3(x + 1, y + 1, z + 0));
                Vertices.Add(new Vector3(x + 1, y + 0, z + 0));
                Vertices.Add(new Vector3(x + 0, y + 1, z + 0));

                Indices.AddRange(new int[] { indiceOffset + 0, indiceOffset + 1, indiceOffset + 2, indiceOffset + 0, indiceOffset + 3, indiceOffset + 1 });
                Normals.AddRange(new Vector3[] { -Vector3.forward, -Vector3.forward, -Vector3.forward, -Vector3.forward });

                addedVertices += 4;
                indiceOffset  += 4;
            }
            //Right
            if (IsSolid(x, y, z + 1))
            {
                Vertices.Add(new Vector3(x + 0, y + 0, z + 1));
                Vertices.Add(new Vector3(x + 1, y + 0, z + 1));
                Vertices.Add(new Vector3(x + 1, y + 1, z + 1));
                Vertices.Add(new Vector3(x + 0, y + 1, z + 1));

                Indices.AddRange(new int[] { indiceOffset + 0, indiceOffset + 1, indiceOffset + 2, indiceOffset + 0, indiceOffset + 2, indiceOffset + 3 });
                Normals.AddRange(new Vector3[] { Vector3.forward, Vector3.forward, Vector3.forward, Vector3.forward });

                addedVertices += 4;
                indiceOffset  += 4;
            }
            //Front
            if (IsSolid(x - 1, y, z))
            {
                Vertices.Add(new Vector3(x + 0, y + 0, z + 0));
                Vertices.Add(new Vector3(x + 0, y + 1, z + 1));
                Vertices.Add(new Vector3(x + 0, y + 1, z + 0));
                Vertices.Add(new Vector3(x + 0, y + 0, z + 1));

                Indices.AddRange(new int[] { indiceOffset + 0, indiceOffset + 1, indiceOffset + 2, indiceOffset + 0, indiceOffset + 3, indiceOffset + 1 });
                Normals.AddRange(new Vector3[] { -Vector3.right, -Vector3.right, -Vector3.right, -Vector3.right });

                addedVertices += 4;
                indiceOffset  += 4;
            }
            //Back
            if (IsSolid(x + 1, y, z))
            {
                Vertices.Add(new Vector3(x + 1, y + 0, z + 0));
                Vertices.Add(new Vector3(x + 1, y + 1, z + 0));
                Vertices.Add(new Vector3(x + 1, y + 1, z + 1));
                Vertices.Add(new Vector3(x + 1, y + 0, z + 1));

                Indices.AddRange(new int[] { indiceOffset + 0, indiceOffset + 1, indiceOffset + 2, indiceOffset + 0, indiceOffset + 2, indiceOffset + 3 });
                Normals.AddRange(new Vector3[] { Vector3.right, Vector3.right, Vector3.right, Vector3.right });

                addedVertices += 4;
                indiceOffset  += 4;
            }
            //Bottom
            if (IsSolid(x, y - 1, z))
            {
                Vertices.Add(new Vector3(x + 0, y + 0, z + 0));
                Vertices.Add(new Vector3(x + 1, y + 0, z + 0));
                Vertices.Add(new Vector3(x + 1, y + 0, z + 1));
                Vertices.Add(new Vector3(x + 0, y + 0, z + 1));

                Indices.AddRange(new int[] { indiceOffset + 0, indiceOffset + 1, indiceOffset + 2, indiceOffset + 0, indiceOffset + 2, indiceOffset + 3 });
                Normals.AddRange(new Vector3[] { -Vector3.up, -Vector3.up, -Vector3.up, -Vector3.up });

                addedVertices += 4;
                indiceOffset  += 4;
            }
            //Top
            if (IsSolid(x, y + 1, z))
            {
                Vertices.Add(new Vector3(x + 1, y + 1, z + 0));
                Vertices.Add(new Vector3(x + 0, y + 1, z + 0));
                Vertices.Add(new Vector3(x + 1, y + 1, z + 1));
                Vertices.Add(new Vector3(x + 0, y + 1, z + 1));

                Indices.AddRange(new int[] { indiceOffset + 1, indiceOffset + 2, indiceOffset + 0, indiceOffset + 1, indiceOffset + 3, indiceOffset + 2 });
                Normals.AddRange(new Vector3[] { Vector3.up, Vector3.up, Vector3.up, Vector3.up });

                addedVertices += 4;
                indiceOffset  += 4;
            }

            if (addedVertices > 0)
            {
                Color32 voxelColor = VoxelManager.GetVoxel(voxels[x, y, z]).Color;
                for (int i = 0; i < addedVertices; i++)
                {
                    Colors.Add(voxelColor);
                }
            }
        }
 void LoadData()
 {
     VoxelManager.LoadVoxels();
     StructureManager.LoadStructures();
 }