Esempio n. 1
0
        private static void ProcessFolder(string inputFolder, string outputFile, bool logs, bool debug)
        {
            string folder = Path.GetFullPath(inputFolder);

            List <string> files = Directory.GetFiles(folder).ToList();

            List <VoxModel> models = new List <VoxModel>();
            VoxReader       reader = new VoxReader();

            Console.WriteLine("[LOG] Started to read all vox files at path: " + folder);
            foreach (string file in files)
            {
                if (Path.GetExtension(file) == ".vox")
                {
                    Console.WriteLine("[LOG] Started to load model: " + file);
                    models.Add(reader.LoadModel(file));
                }
            }

            VoxWriterCustom writer = new VoxWriterCustom();

            if (outputFile.Contains(".vox"))
            {
                writer.WriteModel(outputFile, models);
                reader.LoadModel(outputFile, logs, debug);
            }
            else
            {
                writer.WriteModel(outputFile + ".vox", models);
                reader.LoadModel(outputFile + ".vox", logs, debug);
            }
        }
Esempio n. 2
0
    private void Start()
    {
        Loader    loader = new Loader();
        string    path   = Application.dataPath + "\\Puzzles\\Vox\\" + nameOfVoxFile;
        VoxReader reader = new VoxReader(@path, loader);

        reader.Read();

#if UNITY_EDITOR
        Puzzle newPuzzle = ScriptableObject.CreateInstance <Puzzle>();

        byte[] flatData = new byte[loader.SizeX * loader.SizeY * loader.SizeZ];
        for (int i = 0; i < loader.SizeX; i++)
        {
            for (int j = 0; j < loader.SizeY; j++)
            {
                for (int k = 0; k < loader.SizeZ; k++)
                {
                    flatData[k + j * loader.SizeZ + i * loader.SizeY * loader.SizeZ] = loader.Data[i, j, k];
                }
            }
        }

        newPuzzle.Palette = loader.Palette;
        newPuzzle.Data    = flatData;
        newPuzzle.SizeX   = loader.SizeX;
        newPuzzle.SizeY   = loader.SizeY;
        newPuzzle.SizeZ   = loader.SizeZ;

        string name = AssetDatabase.GenerateUniqueAssetPath("Assets/Puzzles/" + newPuzzleName + ".asset");
        AssetDatabase.CreateAsset(newPuzzle, name);
        AssetDatabase.SaveAssets();
#endif
    }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var voxReader = new VoxReader();
            var voxFile   = voxReader.ParseFile("test.vox");

            Console.WriteLine($"chunks count: {voxFile.chunks.Count}, skipedChunks: {voxFile.skipedChunks}");
        }
Esempio n. 4
0
        static void FillParcel(IntermediateMap map, Parcel parcel, List <Parcel> loadedParcels, int offsetX, int offsetY, int offsetZ, bool hasDonePalette, ParcelJsonConfiguration configuration)
        {
            //If no sourcefile, skip, well, sourcefile! and just plop in plots
            if (!emptySourceFileNames.Contains(parcel.sourceFile))
            {
                ParcelVoxReader parcelReader = new ParcelVoxReader();
                VoxReader       r            = new VoxReader(parcel.sourceFile, parcelReader);
                r.Read();

                parcelReader.insertReadParcel(map, offsetX, offsetY, offsetZ);

                //Do the palette
                if (!hasDonePalette)
                {
                    hasDonePalette = loadPalette(map, parcelReader.palette);
                }
            }

            foreach (Plot plot in parcel.parcelPlots)
            {
                Parcel insertParcel = findMatchingParcel(plot, parcel.parcelPlots, loadedParcels, configuration);

                FillParcel(map, insertParcel, loadedParcels, offsetX + plot.offsetX, offsetY + plot.offsetY, offsetZ + plot.offsetZ, hasDonePalette, configuration);
            }
        }
Esempio n. 5
0
        private static void ReadVoxelModels(List <string> files, ProgramOptions programOptions)
        {
            List <VoxModel> models = new List <VoxModel>();
            VoxReader       reader = new VoxReader();

            foreach (string file in files.Where(file => Path.GetExtension(file) == ".vox"))
            {
                Console.WriteLine("[LOG] Started to load model: " + file);
                models.Add(reader.LoadModel(file, false, false, false, false));
            }

            VoxWriterCustom writer = new VoxWriterCustom();

            if (models.Count == 0)
            {
                Console.WriteLine("[ERR] No models founds! Abort.");
            }
            else
            {
                writer.WriteModel(programOptions.GetSageOutputFile(), models);
                if (programOptions.EnableDebug)
                {
                    reader.LoadModel(programOptions.OutputFile, programOptions.EnableLogs, true);
                }
            }
        }
Esempio n. 6
0
        public void VoxReader_Read_ModelCountIsCorrect(string file, int expectedCount)
        {
            file = Zip.UnzipFilesFromSevenZipArchive(file).First();

            IVoxFile voxFile = VoxReader.Read(file);

            voxFile.Models.Should().HaveCount(expectedCount);
        }
Esempio n. 7
0
 private static void CheckDebug()
 {
     if (Schematic.DEBUG)
     {
         VoxReader reader = new VoxReader();
         reader.LoadModel(FormatOutputDestination(OUTPUT_PATH));
     }
 }
Esempio n. 8
0
 private static void CheckVerbose()
 {
     if (DEBUG)
     {
         VoxReader reader = new VoxReader();
         reader.LoadModel(OUTPUT_PATH + ".vox");
     }
 }
Esempio n. 9
0
 private static void CheckVerbose()
 {
     if (_verbose)
     {
         VoxReader reader = new VoxReader();
         reader.LoadModel(_outputPath + ".vox");
     }
 }
Esempio n. 10
0
        public void VoxReader_Read_VoxelCountIsCorrectForSmallestModel()
        {
            string file = Zip.UnzipFilesFromSevenZipArchive(TestFile_1x1).First();

            IVoxFile voxFile = VoxReader.Read(file);

            IModel model = voxFile.Models.First();

            model.Voxels.Should().HaveCount(1);
        }
Esempio n. 11
0
        public void VoxReader_Read_VoxelColorIsCorrectForSmallestModel()
        {
            string file = Zip.UnzipFilesFromSevenZipArchive(TestFile_1x1).First();

            IVoxFile voxFile = VoxReader.Read(file);

            IModel model = voxFile.Models.First();

            model.Voxels.First(voxel => voxel.Position == new Vector3(0, 0, 0)).Color.Should().Be(new Color(123, 162, 63, 255));
        }
Esempio n. 12
0
        public void VoxReader_Read_VoxelColorIsCorrectForLargestModel()
        {
            string file = Zip.UnzipFilesFromSevenZipArchive(TestFile_256x256).First();

            IVoxFile voxFile = VoxReader.Read(file);

            IModel model = voxFile.Models.First();

            foreach (Voxel voxel in model.Voxels)
            {
                voxel.Color.Should().Be(new Color(123, 162, 63, 255));
            }
        }
Esempio n. 13
0
        public void VoxReader_Read_VoxelColorIsCorrect()
        {
            string file = Zip.UnzipFilesFromSevenZipArchive(TestFile_3x3).First();

            IVoxFile voxFile = VoxReader.Read(file);

            IModel model = voxFile.Models.First();

            model.Voxels.First(voxel => voxel.Position == new Vector3(0, 0, 0)).Color.Should().Be(new Color(255, 177, 27, 255));
            model.Voxels.First(voxel => voxel.Position == new Vector3(2, 0, 0)).Color.Should().Be(new Color(203, 64, 66, 255));
            model.Voxels.First(voxel => voxel.Position == new Vector3(0, 2, 0)).Color.Should().Be(new Color(27, 129, 62, 255));
            model.Voxels.First(voxel => voxel.Position == new Vector3(0, 0, 2)).Color.Should().Be(new Color(0, 92, 175, 255));
        }
Esempio n. 14
0
        public void VoxReader_Read_VoxelCountIsCorrect(string file, params int[] expectedCount)
        {
            file = Zip.UnzipFilesFromSevenZipArchive(file).First();

            IVoxFile voxFile = VoxReader.Read(file);

            var models = voxFile.Models;

            models.Should().HaveCount(expectedCount.Length);

            for (int i = 0; i < expectedCount.Length; i++)
            {
                models[i].Voxels.Should().HaveCount(expectedCount[i]);
            }
        }
Esempio n. 15
0
    BakedPointCloud ImportAsBakedPointCloud(string path)
    {
        VoxReader voxReader = new VoxReader();
        VoxModel  model     = voxReader.LoadModel(path);

        if (model == null)
        {
            return(null);
        }

        List <Vector3> positions     = new List <Vector3>();
        List <Color>   colors        = new List <Color>();
        var            colorsPalette = model.Palette;

        for (int i = 0; i < model.VoxelFrames.Count; i++)
        {
            VoxelData data = model.VoxelFrames[i];
            FileToVoxCore.Schematics.Tools.Vector3 worldPositionFrame = model.TransformNodeChunks[i + 1].TranslationAt();

            if (worldPositionFrame == FileToVoxCore.Schematics.Tools.Vector3.zero)
            {
                continue;
            }

            for (int y = 0; y < data.VoxelsTall; y++)
            {
                for (int z = 0; z < data.VoxelsDeep; z++)
                {
                    for (int x = 0; x < data.VoxelsWide; x++)
                    {
                        int indexColor = data.Get(x, y, z);
                        var color      = colorsPalette[indexColor];
                        if (color != FileToVoxCore.Drawing.Color.Empty)
                        {
                            positions.Add(new Vector3(z + worldPositionFrame.X, y + worldPositionFrame.Z, x + worldPositionFrame.Y));
                            colors.Add(color.ToUnityColor());
                        }
                    }
                }
            }
        }

        BakedPointCloud bakedPointCloud = ScriptableObject.CreateInstance <BakedPointCloud>();

        bakedPointCloud.Initialize(positions, colors);
        bakedPointCloud.name = Path.GetFileNameWithoutExtension(path);
        return(bakedPointCloud);
    }
Esempio n. 16
0
    // Format refer to
    // https://github.com/ephtracy/voxel-model/blob/master/MagicaVoxel-file-format-vox.txt
    public static IEnumerable <VoxelData> ParseFrom(string path, out Color32[] palette)
    {
        List <VoxelData> outputData = new List <VoxelData>();

        using (VoxReader reader = new VoxReader(path))
        {
            reader.Read();

            foreach (var model in reader.m_Models)
            {
                VoxelData data = CreateInstance <VoxelData>();
                data.m_Width   = model.m_SizeX;
                data.m_Height  = model.m_SizeY;
                data.m_Depth   = model.m_SizeZ;
                data.m_RawData = new Voxel[model.m_SizeX * model.m_SizeY * model.m_SizeZ];

                foreach (var voxel in model.m_Voxels)
                {
                    if (voxel.colourIndex == 0)
                    {
                        Debug.LogWarning("Colour Index 0 found!");
                    }

                    data.m_RawData[data.GetRawIndex(voxel.x, voxel.y, voxel.z)] = new Voxel(voxel.colourIndex);
                }

                outputData.Add(data);
            }

            palette = new Color32[reader.m_Palette.Length];
            for (int i = 0; i < palette.Length; ++i)
            {
                palette[i] = reader.GetColour(i);
            }
        }

        return(outputData);
    }
Esempio n. 17
0
        public VoxToSchematic(string path) : base(path)
        {
            VoxReader reader = new VoxReader();

            mVoxModel = reader.LoadModel(path);
        }
Esempio n. 18
0
        static void Main(string[] args)
        {
            VoxReader reader = new VoxReader();
            VoxWriter writer = new VoxWriter();

            DisplayInformations();

            if (args.Length < 2)
            {
                Console.WriteLine("[ERROR] Missing arguments");
                Console.WriteLine("Usage: VoxSlicer.exe SIZE FILE");
                return;
            }

            try
            {
                short size = Convert.ToInt16(args[0]);
                if (size <= 10 || size > 256)
                {
                    Console.WriteLine("[ERROR] Size must be between 10 and 256");
                    return;
                }

                VoxModel model = reader.LoadModel(args[1]);

                if (model == null)
                {
                    Console.WriteLine("[ERROR] Failed to load model");
                    return;
                }

                Schematic.CHUNK_SIZE = size;
                DirectoryInfo directory = Directory.CreateDirectory(Path.GetFileNameWithoutExtension(args[1]));
                foreach (VoxelData data in model.VoxelFrames)
                {
                    int sizeX = (int)Math.Ceiling((decimal)data.VoxelsWide / size);
                    int sizeY = (int)Math.Ceiling((decimal)data.VoxelsTall / size);
                    int sizeZ = (int)Math.Ceiling((decimal)data.VoxelsDeep / size);

                    Schematic[,,] schematics = new Schematic[sizeX, sizeY, sizeZ];
                    Color[] colors = model.Palette;
                    for (int y = 0; y < data.VoxelsTall; y++)
                    {
                        for (int z = 0; z < data.VoxelsDeep; z++)
                        {
                            for (int x = 0; x < data.VoxelsWide; x++)
                            {
                                int posX = x / size;
                                int posY = y / size;
                                int posZ = z / size;

                                schematics[posX, posY, posZ] ??= new Schematic();
                                int   indexColor = data.Get(x, y, z);
                                Color color      = colors[indexColor];

                                if (indexColor != 0)
                                {
                                    schematics[posX, posY, posZ].AddVoxel(x, y, z, color);
                                }
                            }
                        }
                    }

                    for (int x = 0; x < schematics.GetLength(0); x++)
                    {
                        for (int y = 0; y < schematics.GetLength(1); y++)
                        {
                            for (int z = 0; z < schematics.GetLength(2); z++)
                            {
                                if (schematics[x, y, z].GetAllVoxels().Count != 0)
                                {
                                    var    rotation = model.TransformNodeChunks.First().RotationAt();
                                    string name     = $"{Path.GetFileNameWithoutExtension(args[1])}-{x}-{y}-{z}.vox";
                                    Console.WriteLine("[INFO] Started to process: " + name);
                                    string outputPath = Path.Combine(directory.FullName, name);
                                    writer.WriteModel(size, outputPath, model.Palette.ToList(), schematics[x, y, z], rotation);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                Console.WriteLine("[ERROR] Failed to read voxel volume size");
            }
        }
Esempio n. 19
0
        static void Main(string[] args)
        {
            VoxReader reader = new VoxReader();
            VoxWriter writer = new VoxWriter();

            if (args.Length < 2)
            {
                Console.WriteLine("[ERROR] Missing arguments");
                Console.WriteLine("Usage: VoxSlicer.exe SIZE FILE");
                return;
            }

            try
            {
                short size = Convert.ToInt16(args[0]);
                if (size >= 126)
                {
                    Console.WriteLine("[ERROR] Size must be lower than 126");
                    return;
                }

                VoxModel model = reader.LoadModel(args[1]);
                if (model == null)
                {
                    return;
                }

                DirectoryInfo directory = Directory.CreateDirectory(Path.GetFileNameWithoutExtension(args[1]));

                foreach (var data in model.voxelFrames)
                {
                    SchematicConstants.WidthSchematic  = size;
                    SchematicConstants.HeightSchematic = size;
                    SchematicConstants.LengthSchematic = size;

                    int sizeX = (int)Math.Ceiling((decimal)data.VoxelsWide / size);
                    int sizeY = (int)Math.Ceiling((decimal)data.VoxelsTall / size);
                    int sizeZ = (int)Math.Ceiling((decimal)data.VoxelsDeep / size);
                    Schematic[,,] schematics = new Schematic[sizeX, sizeY, sizeZ];

                    Color[] colors = model.palette;
                    for (int y = 0; y < data.VoxelsTall; y++)
                    {
                        for (int z = 0; z < data.VoxelsDeep; z++)
                        {
                            for (int x = 0; x < data.VoxelsWide; x++)
                            {
                                int posX = x / size;
                                int posY = y / size;
                                int posZ = z / size;

                                if (schematics[posX, posY, posZ] == null)
                                {
                                    schematics[posX, posY, posZ] = new Schematic()
                                    {
                                        Blocks = new System.Collections.Generic.HashSet <Block>(),
                                        Heigth = size,
                                        Length = size,
                                        Width  = size
                                    };
                                }
                                int   indexColor = data.Get(x, y, z);
                                Color color      = colors[indexColor];
                                if (!color.IsEmpty)
                                {
                                    schematics[posX, posY, posZ].Blocks.Add(new Block((ushort)x, (ushort)y, (ushort)z, color.ColorToUInt()));
                                }
                            }
                        }
                    }

                    for (int x = 0; x < schematics.GetLength(0); x++)
                    {
                        for (int y = 0; y < schematics.GetLength(1); y++)
                        {
                            for (int z = 0; z < schematics.GetLength(2); z++)
                            {
                                if (schematics[x, y, z].TotalCount != 0)
                                {
                                    string name = $"{Path.GetFileNameWithoutExtension(args[1])}-{x}-{y}-{z}.vox";
                                    Console.WriteLine("[INFO] Started to process: " + name);
                                    writer.WriteModel(Path.Combine(directory.FullName, name), schematics[x, y, z], 0, size);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                Console.WriteLine("[ERROR] Failed to read voxel volume size");
            }
        }
Esempio n. 20
0
        public override void OnCreate()
        {
            try
            {
                Console.WriteLine(ShaderPreprocessor.Execute(@"res\shaders\raytracing\fragment.glsl"));

                Shader voxelVertexShader   = new Shader(ShaderType.VertexShader, ShaderPreprocessor.Execute(@"res\shaders\raytracing\vertex.glsl"));
                Shader voxelFragmentShader = new Shader(ShaderType.FragmentShader, ShaderPreprocessor.Execute(@"res\shaders\raytracing\fragment.glsl"));
                Shader scaleFragmentShader = new Shader(ShaderType.FragmentShader, ShaderPreprocessor.Execute(@"res\shaders\raytracing\scale.glsl"));
                _voxelRenderer = new VoxelRenderer(new ShaderProgram(new[] { voxelVertexShader, voxelFragmentShader }), new ShaderProgram(new[] { voxelVertexShader, scaleFragmentShader }));

                Shader spriteVertexShader   = new Shader(ShaderType.VertexShader, ShaderPreprocessor.Execute(@"res\shaders\ui\vertex.glsl"));
                Shader spriteFragmentShader = new Shader(ShaderType.FragmentShader, ShaderPreprocessor.Execute(@"res\shaders\ui\fragment.glsl"));
                _spriteRenderer = new SpriteRenderer(new ShaderProgram(new[] { spriteVertexShader, spriteFragmentShader }));
            } catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw;
            }

            _voxelRenderer.GenerateFramebuffer(window);

            //List<Material> materials = new List<Material>();
            //for (int i = 0; i < 256; i++)
            //    materials.Add(new Material(Vector3.One, 1.5f));

            //_voxelRenderer.Materials = materials;

            Console.WriteLine("Shader compiled <o/"); //epic it work

            _model = _voxelRenderer.CreateModel(32, 32, 32,
                                                new Transform(new Vector3(24.0f, 0.0f, 0.0f), Vector3.Zero, new Vector3(0.5f)));

            for (int x = 0; x < 32; x++)
            {
                for (int y = 0; y < 32; y++)
                {
                    for (int z = 0; z < 32; z++)
                    {
                        _model[x, y, z] = (byte)((x + y + z) & 1);//new Voxel((ushort) ((x + y + z) & 1));
                    }
                }
            }
            MyVoxLoader CastleVox = new MyVoxLoader();
            VoxReader r           = new VoxReader(@"res\maps\map.vox", CastleVox);
            r.Read();

            //Use palette of castlevox
            List <Material> materials = new List <Material>();
            for (int i = 0; i < 256; i++)
            {
                Vector3 color = new Vector3((float)CastleVox._materials[i].r / 255f, (float)CastleVox._materials[i].g / 255f, (float)CastleVox._materials[i].b / 255f);
                float   ior   = 1.01f;
                if (i == 252)
                {
                    ior = 1.1f;
                }
                if (i == 254)
                {
                    ior = 1.1f;
                }
                //Vector3 color = new Vector3(1f, 0f, 0f);
                materials.Add(new Material(color, ior));
            }
            _voxelRenderer.Materials.Set(materials);

            _model2 = _voxelRenderer.CreateModel(CastleVox.Width, CastleVox.Height, CastleVox.Depth,
                                                 new Transform(new Vector3(-24.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.1f, 0.0f), new Vector3(0.5f)));

            //for (int x = -16; x < 16; x++)
            //for (int y = -16; y < 16; y++)
            //for (int z = -16; z < 16; z++)
            //    _model2[x + 16, y + 16, z + 16] = (x * x + y * y + z * z < 16 * 16) ? (byte)1 : (byte)0;
            for (int x = 0; x < CastleVox.Width; x++)
            {
                for (int y = 0; y < CastleVox.Height; y++)
                {
                    for (int z = 0; z < CastleVox.Depth; z++)
                    {
                        _model2[x, y, z] = CastleVox._data[x, y, z];
                    }
                }
            }

            Console.WriteLine("Epic");


            //int s = 512;
            //VoxelModel model3 = _voxelRenderer.CreateModel(s,1,s,
            //    new Transform(new Vector3(0.0f, -48.0f, 0.0f), Vector3.Zero, new Vector3(1.0f)));

            //for (int x = 0; x < s; x++)
            //for (int y = 0; y < 1; y++)
            //for (int z = 0; z < s; z++)
            //    model3[x,y,z] = (byte)1;

            Console.WriteLine("Epic");

            Sprite crosshair = new Sprite(new Texture("res/textures/crosshair.png", TextureMinFilter.Linear, TextureMagFilter.Linear));
            _spriteRenderer.Add(crosshair);
            crosshair.Colour          = new Colour(1.0f, 1.0f, 1.0f, 1.0f);
            crosshair.Transform.Scale = new Vector3(128.0f, 128.0f, 0.25f);

            List <DirectionalLight> dirLights = new List <DirectionalLight>();
            var sun = new DirectionalLight();
            sun.direction = new Vector3(-0.5f, 1.5f, -1.0f);
            sun.intensity = 0.8f;
            sun.colour    = new Vector3(1f, 1f, 1f);
            dirLights.Add(sun);

            var sun2 = new DirectionalLight();
            sun2.direction = new Vector3(-0.4f, 1.5f, 0.8f);
            sun2.intensity = 0.6f;
            sun2.colour    = new Vector3(0.7f, 0.8f, 1f);
            dirLights.Add(sun2);

            var sun3 = new DirectionalLight();
            sun3.direction = new Vector3(0.4f, 0.1f, 0.2f);
            sun3.intensity = 0.6f;
            sun3.colour    = new Vector3(0.4f, 0.8f, 1f);
            dirLights.Add(sun3);
            _voxelRenderer.DirectionalLights = dirLights;

            List <PointLight> pointLights = new List <PointLight>();
            var pointlight = new PointLight();
            pointlight.position  = new Vector3(0f, 0f, -20f);
            pointlight.intensity = 0.5f;
            pointlight.colour    = new Vector3(1f, 0.0f, 0.0f);
            pointLights.Add(pointlight);
            _voxelRenderer.PointLights = pointLights;

            MyVoxLoader CharBodyVox = new MyVoxLoader();
            VoxReader rCharBody     = new VoxReader(@"res\char1_body.vox", CharBodyVox);
            rCharBody.Read();

            //Use palette of castlevox
            //List<Material> materialsChar = new List<Material>();
            //for (int i = 0; i < 256; i++)
            //{
            //    Vector3 color = new Vector3((float)CharBodyVox._materials[i].r / 255f, (float)CharBodyVox._materials[i].g / 255f, (float)CharBodyVox._materials[i].b / 255f);
            //    float ior = 1.01f;
            //    if (i == 252) ior = 1.1f;
            //    if (i == 254) ior = 1.1f;
            //    //Vector3 color = new Vector3(1f, 0f, 0f);
            //    materialsChar.Add(new Material(color, ior));
            //}
            //_voxelRenderer.Materials.Set(materialsChar);

            TcpConnection connection = new TcpConnection(IPAddress.Parse("127.0.0.1"), 42069, (IConnection c, byte[] data) =>
            {
                //Console.WriteLine("Received packet...");
                if (data.Length > 1)
                {
                    if (data[0] == 1)
                    {
                        Console.WriteLine("Received our player id!");
                        _playerId              = BitConverter.ToUInt64(data, 1);
                        _mainPlayer            = new Player(data[1], _playerId, true);
                        _mainPlayer._world     = _model2;
                        _mainPlayer._modelBody = _voxelRenderer.CreateModel(CharBodyVox.Width, CharBodyVox.Height, CharBodyVox.Depth,
                                                                            new Transform(new Vector3(-24.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.1f, 0.0f), new Vector3(0.5f)));

                        //for (int x = 0; x < CharBodyVox.Width; x++)
                        //    for (int y = 0; y < CharBodyVox.Height; y++)
                        //        for (int z = 0; z < CharBodyVox.Depth; z++)
                        //            _mainPlayer._modelBody[x, y, z] = CharBodyVox._data[x, y, z];

                        //Commenting this line out will give you access to the FreeCamera
                        //_camera = _mainPlayer.camera;
                        _entityManager.Add(_mainPlayer);
                    }
                    else if (data[0] == 0)
                    {
                        //Not sure if myId should be data[5] or _playerId
                        if (NetworkEntity.HandlePacket(_entityManager, data, _playerId) == false)
                        {
                            //Player doesn't exist yet
                            Console.WriteLine("Adding new player");
                            Player player     = new Player(data[1], data[5], false);
                            player._modelBody = _voxelRenderer.CreateModel(CharBodyVox.Width, CharBodyVox.Height, CharBodyVox.Depth,
                                                                           new Transform(new Vector3(-24.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.1f, 0.0f), new Vector3(0.5f)));

                            for (int x = 0; x < CharBodyVox.Width; x++)
                            {
                                for (int y = 0; y < CharBodyVox.Height; y++)
                                {
                                    for (int z = 0; z < CharBodyVox.Depth; z++)
                                    {
                                        player._modelBody[x, y, z] = CharBodyVox._data[x, y, z];
                                    }
                                }
                            }
                            _entityManager.Add(player);
                        }
                    }
                }
            });

            _packetSender.AddReceiver(connection);
        }