Exemple #1
0
        public VoxWorld(VoxState s)
        {
            // Reference The State
            state = s;

            // Start With World Near The Center
            worldMin = new Point(-WIDTH / 2, -DEPTH / 2);

            // No Regions To Add Yet
            regions = new Region[REGION_COUNT];
            Array.Clear(regions, 0, REGION_COUNT);
            pager = new RegionPager();

            // Create An Empty Atlas
            Atlas = new VoxAtlas();
        }
Exemple #2
0
        public VoxWorld(VoxState s)
        {
            // Reference The State
            state = s;

            // Start With World Near The Center
            worldMin = new Point(-WIDTH / 2, -DEPTH / 2);

            // No Regions To Add Yet
            regions = new Region[REGION_COUNT];
            Array.Clear(regions, 0, REGION_COUNT);
            pager = new RegionPager();

            // Create An Empty Atlas
            Atlas = new VoxAtlas();
        }
 public void CreateVoxGeos(VoxAtlas atlas)
 {
     float DUV = 0.125f;
     int vi;
     for(int i = 1; i < 6; i++) {
         var vgpTop = new VGPCube6();
         var vgpTrans = new VGPCube6();
         var vgpCliff = new VGPCube6();
         for(int fi = 0; fi < 6; fi++) {
             vgpTop.Colors[fi] = Color.White;
             switch(fi) {
                 case Voxel.FACE_NY:
                     vgpTop.UVRects[fi] = new Vector4(DUV * i, DUV * 4, DUV, DUV);
                     vgpTrans.UVRects[fi] = new Vector4(DUV * i, DUV * 4, DUV, DUV);
                     vgpCliff.UVRects[fi] = new Vector4(DUV * i, DUV * 4, DUV, DUV);
                     break;
                 case Voxel.FACE_PY:
                     vgpTop.UVRects[fi] = new Vector4(DUV * i, DUV * 0, DUV, DUV);
                     vgpTrans.UVRects[fi] = new Vector4(DUV * i, DUV * 4, DUV, DUV);
                     vgpCliff.UVRects[fi] = new Vector4(DUV * i, DUV * 4, DUV, DUV);
                     break;
                 default:
                     vgpTop.UVRects[fi] = new Vector4(DUV * i, DUV * 1, DUV, DUV);
                     vgpTrans.UVRects[fi] = new Vector4(DUV * i, DUV * 2, DUV, DUV);
                     vgpCliff.UVRects[fi] = new Vector4(DUV * i, DUV * 3, DUV, DUV);
                     break;
             }
         }
         atlas[(ushort)(i)].GeoProvider = vgpTop;
         atlas[(ushort)(i + 5)].GeoProvider = vgpTrans;
         atlas[(ushort)(i + 10)].GeoProvider = vgpCliff;
     }
     for(vi = 0; vi < 4; vi++) {
         var vd = atlas[(ushort)(vi + 16)];
         var vgp = new VGPCustom();
         Vector4 uvr = new Vector4(DUV * 5, DUV * 0, DUV, DUV);
         switch(vi) {
             case 0:
             case 1:
                 vgp.CustomVerts[Voxel.FACE_PY] = new VertexVoxel[] {
                     new VertexVoxel(new Vector3(0, 0, 0), Vector2.UnitX, uvr, Color.White),
                     new VertexVoxel(new Vector3(1, -1, 0), Vector2.One, uvr, Color.White),
                     new VertexVoxel(new Vector3(1, -1, 1), Vector2.UnitY, uvr, Color.White),
                     new VertexVoxel(new Vector3(0, 0, 1), Vector2.Zero, uvr, Color.White),
                     new VertexVoxel(new Vector3(0, -1, 0), Vector2.UnitX, uvr, Color.White),
                     new VertexVoxel(new Vector3(0, -1, 1), Vector2.Zero, uvr, Color.White)
                 };
                 vgp.CustomInds[Voxel.FACE_PY] = new int[] {
                     0, 1, 3, 3, 1, 2,
                     3, 2, 5, 1, 0, 4,
                     0, 3, 4, 4, 3, 5
                 };
                 break;
             default:
                 vgp.CustomVerts[Voxel.FACE_PY] = new VertexVoxel[] {
                     new VertexVoxel(new Vector3(1, 0, 0), Vector2.UnitX, uvr, Color.White),
                     new VertexVoxel(new Vector3(1, -1, 1), Vector2.One, uvr, Color.White),
                     new VertexVoxel(new Vector3(0, -1, 1), Vector2.UnitY, uvr, Color.White),
                     new VertexVoxel(new Vector3(0, 0, 0), Vector2.Zero, uvr, Color.White),
                     new VertexVoxel(new Vector3(1, -1, 0), Vector2.UnitX, uvr, Color.White),
                     new VertexVoxel(new Vector3(0, -1, 0), Vector2.Zero, uvr, Color.White)
                 };
                 vgp.CustomInds[Voxel.FACE_PY] = new int[] {
                     0, 1, 3, 3, 1, 2,
                     3, 2, 5, 1, 0, 4,
                     0, 3, 4, 4, 3, 5
                 };
                 break;
         }
         if((vi % 2) == 1) {
             if(vi == 1) for(int fi = 0; fi < 6; fi++)
                     vgp.CustomVerts[Voxel.FACE_PY][fi].Position.X = 1 - vgp.CustomVerts[Voxel.FACE_PY][fi].Position.X;
             else for(int fi = 0; fi < 6; fi++)
                     vgp.CustomVerts[Voxel.FACE_PY][fi].Position.Z = 1 - vgp.CustomVerts[Voxel.FACE_PY][fi].Position.Z;
             for(int ti = 0; ti < vgp.CustomInds[Voxel.FACE_PY].Length; ) {
                 int buf = vgp.CustomInds[Voxel.FACE_PY][ti + 2];
                 vgp.CustomInds[Voxel.FACE_PY][ti + 2] = vgp.CustomInds[Voxel.FACE_PY][ti];
                 vgp.CustomInds[Voxel.FACE_PY][ti] = buf;
                 ti += 3;
             }
         }
         vd.GeoProvider = vgp;
     }
     vi = 20;
     for(int i = 0; i < 5; i++) {
         var vgp = new VGPCube6();
         for(int fi = 0; fi < 6; fi++) {
             vgp.Colors[fi] = Color.White;
             switch(fi) {
                 case Voxel.FACE_NY:
                     vgp.UVRects[fi] = new Vector4(DUV * i, DUV * 7, DUV, DUV);
                     break;
                 case Voxel.FACE_PY:
                     vgp.UVRects[fi] = new Vector4(DUV * i, DUV * 5, DUV, DUV);
                     break;
                 default:
                     vgp.UVRects[fi] = new Vector4(DUV * i, DUV * 6, DUV, DUV);
                     break;
             }
         }
         atlas[(ushort)(vi + i)].GeoProvider = vgp;
     }
     vi += 5;
     for(int i = 0; i < 5; i++) {
         var vgp = new VGPCustom();
         Vector4 uvr = new Vector4(DUV * 7, DUV * i, DUV, DUV);
         vgp.CustomVerts[Voxel.FACE_PY] = new VertexVoxel[] {
             new VertexVoxel(new Vector3(0, 0, 0), Vector2.Zero, uvr, Color.White),
             new VertexVoxel(new Vector3(1, 0, 1), Vector2.UnitX, uvr, Color.White),
             new VertexVoxel(new Vector3(0, -1, 0), Vector2.UnitY, uvr, Color.White),
             new VertexVoxel(new Vector3(1, -1, 1), Vector2.One, uvr, Color.White),
             new VertexVoxel(new Vector3(0, 0, 1), Vector2.Zero, uvr, Color.White),
             new VertexVoxel(new Vector3(1, 0, 0), Vector2.UnitX, uvr, Color.White),
             new VertexVoxel(new Vector3(0, -1, 1), Vector2.UnitY, uvr, Color.White),
             new VertexVoxel(new Vector3(1, -1, 0), Vector2.One, uvr, Color.White)
         };
         vgp.CustomInds[Voxel.FACE_PY] = new int[] {
             0, 1, 2, 2, 1, 3,
             4, 5, 6, 6, 5, 7
         };
         atlas[(ushort)(vi + i)].GeoProvider = vgp;
     }
 }
 public abstract List<LEVoxel> CreateVoxels(VoxAtlas atlas);
        public override List<LEVoxel> CreateVoxels(VoxAtlas atlas)
        {
            float duv = 1f / 8f;
            voxels = new List<LEVoxel>(2);
            LEVoxel lev;
            VGPCube vgp;

            // Create Flora Voxel
            lev = new LEVoxel("Flora", atlas);
            lev.VData.FaceType.SetAllTypes(0x00000001u);
            lev.VData.FaceType.SetAllMasks(0xfffffffeu);
            vgp = new VGPCube();
            vgp.Color = Color.Khaki;
            vgp.UVRect = new Vector4(duv * 0, duv * 1, duv, duv);
            lev.VData.GeoProvider = vgp;
            voxels.Add(lev);

            // Create Ore Voxel
            lev = new LEVoxel("Ore", atlas);
            lev.VData.FaceType.SetAllTypes(0x00000001u);
            lev.VData.FaceType.SetAllMasks(0xfffffffeu);
            vgp = new VGPCube();
            vgp.Color = Color.Purple;
            vgp.UVRect = new Vector4(duv * 1, duv * 1, duv, duv);
            lev.VData.GeoProvider = vgp;
            voxels.Add(lev);

            minID = voxels[0].VData.ID;
            maxID = voxels[voxels.Count - 1].VData.ID;
            return voxels;
        }
 public override List<LEVoxel> CreateVoxels(VoxAtlas atlas)
 {
     return null;
 }
        public override List<LEVoxel> CreateVoxels(VoxAtlas atlas)
        {
            float duv = 1f / 8f;
            voxels = new List<LEVoxel>(1);

            // Create Camera Voxel
            LEVoxel lev = new LEVoxel("Camera Position", atlas);
            lev.VData.FaceType.SetAllTypes(0x00000001u);
            lev.VData.FaceType.SetAllMasks(0xfffffffeu);
            VGPCube vgp = new VGPCube();
            vgp.Color = Color.White;
            vgp.UVRect = new Vector4(duv * 0, duv * 1, duv, duv);
            lev.VData.GeoProvider = vgp;
            voxels.Add(lev);

            camID = voxels[0].VData.ID;
            return voxels;
        }