예제 #1
0
        public bool ExisteVoxel(Vector3Int posicion)
        {
            int x = (int)math.floor((posicion.x - 1) / voxelTam.x);
            int z = (int)math.floor((posicion.z - 1) / voxelTam.x);

            if (x >= 0 && x < xV && z >= 0 && z < zV)
            {
                BloqueVoxel b = contenedorVoxels[x, z];
                return(b.ExisteVoxel(posicion));
            }

            return(false);
        }
예제 #2
0
        public void CargarBloque(string rutaArchivo, DataFormat tipoFormato)
        {
            string ruta = rutaArchivo + "/" + "Bloque_" + posicion.x + "_" + posicion.y + "_" + posicion.z + ".jcc";

            if (!File.Exists(ruta))
            {
                return;                 // No state to load
            }
            byte[]      bytes = File.ReadAllBytes(ruta);
            BloqueVoxel temp  = SerializationUtility.DeserializeValue <BloqueVoxel>(bytes, tipoFormato);

            this.mapaVoxels = temp.mapaVoxels;
            ActualizarBloque();
        }
예제 #3
0
        public void LlenarMapaTodo()
        {
            int xV = (int)(mapaTam.x / voxelTam.x);
            int zV = (int)(mapaTam.z / voxelTam.z);

            for (int x = 0; x < xV; x++)
            {
                for (int z = 0; z < zV; z++)
                {
                    BloqueVoxel nuevo = new BloqueVoxel(this, new Vector3(x, 0, z));
                    nuevo.LlenarBloqueCompleto();
                    contenedorVoxels[x, z] = nuevo;
                }
            }
        }
예제 #4
0
        void UpdateSurroundingVoxels(int x, int y, int z)
        {
            Vector3 thisVoxel = new Vector3(x, y, z);

            for (int p = 0; p < 6; p++)
            {
                Vector3 currentVoxel = thisVoxel + VoxelData.faceChecks[p];

                if (!IsVoxelInChunk((int)currentVoxel.x, (int)currentVoxel.y, (int)currentVoxel.z))
                {
                    BloqueVoxel b = mapa.ObtenerBloqueVoxel(currentVoxel + posicion);
                    if (b != null)
                    {
                        b.UpdateChunk();
                    }
                }
            }
        }
예제 #5
0
        public void CargarMapa(string rutaArchivo, string nombre, DataFormat tipoFormato)
        {
            string ruta       = rutaArchivo + "/MapaVoxel_" + nombre;
            string rutaNombre = ruta + "/MapaVoxel_" + nombre + ".jcc";

            if (!File.Exists(rutaNombre))
            {
                return; // No state to load
            }
            else
            {
                byte[]    bytes = File.ReadAllBytes(rutaNombre);
                MapaVoxel temp  = SerializationUtility.DeserializeValue <MapaVoxel>(bytes, tipoFormato);
                this.mapaTam           = temp.mapaTam;
                this.nombre            = temp.nombre;
                this.texturasCuadrante = temp.texturasCuadrante;
                this.voxelTam          = temp.voxelTam;
                this.xV         = temp.xV;
                this.zV         = temp.zV;
                this.idMaterial = temp.idMaterial;
                this.material   = AdministradorMateriales.Instanciar().ObtenerMaterial(temp.idMaterial).material;
                /*-----*/
                this.gameObject  = new GameObject(nombre + "Cargado");
                contenedorVoxels = new BloqueVoxel[this.xV, this.zV];
                for (int x = 0; x < xV; x++)
                {
                    for (int z = 0; z < zV; z++)
                    {
                        BloqueVoxel nuevo = new BloqueVoxel(this, new Vector3(x, 0, z));

                        nuevo.CargarBloque(ruta, tipoFormato);
                        contenedorVoxels[x, z] = nuevo;
                    }
                }
            }
        }