示例#1
0
    void initialize()
    {
        shapeGenerator = new ShapeGenerator(seed, settings);

        if (meshFilters == null || meshFilters.Length == 0)
        {
            meshFilters = new MeshFilter[6];
        }
        planetFaces = new PlanetFace[6];

        Vector3[] directions = { Vector3.up, Vector3.down, Vector3.right, Vector3.left, Vector3.forward, Vector3.back };
        for (int i = 0; i < 6; i++)
        {
            if (meshFilters[i] == null)
            {
                GameObject meshObj = new GameObject("mesh");
                meshObj.transform.parent = transform;

                meshObj.AddComponent <MeshRenderer>().sharedMaterial = new Material(Shader.Find("Standard"));
                meshFilters[i]            = meshObj.AddComponent <MeshFilter>();
                meshFilters[i].sharedMesh = new Mesh();
            }

            planetFaces[i] = new PlanetFace(shapeGenerator, meshFilters[i].sharedMesh, resolution, directions[i]);
        }

        transform.localScale = Vector3.one * radius;
    }
示例#2
0
    public void Initialize()
    {
        colourGenerator.UpdateSettings(coloursSettings);
        elevationMinMax = new MinMax();

        if (faces.Length != 6)
        {
            faces = new PlanetFace[6];
        }
        for (int i = 0; i < 6; i++)
        {
            if (faces[i] == null)
            {
                GameObject go = new GameObject("face");
                go.transform.parent     = transform;
                go.transform.localScale = Vector3.one;
                Debug.Log("init face " + i);
                faces[i] = go.AddComponent <PlanetFace>();
            }
            ;
            PlanetFace face = faces[i];
            face.gameObject.layer = terrainLayer;
            face.GetComponent <MeshRenderer>().sharedMaterial = coloursSettings.planetMaterial;
        }
    }
示例#3
0
    void Initialize()
    {
        shapeGenerator.UpdateSettings(shapeSettings);
        colorCreator.UpdateSettings(colorParameters, planetId);

        if (meshFilters == null || meshFilters.Length == 0)
        {
            meshFilters = new MeshFilter[6];
        }
        planetFaces = new PlanetFace[6];

        Vector3[] directions = { Vector3.up, Vector3.down, Vector3.left, Vector3.right, Vector3.forward, Vector3.back };

        for (int i = 0; i < 6; i++)
        {
            if (meshFilters[i] == null)
            {
                GameObject meshObj = new GameObject("face" + i);
                meshObj.transform.parent = transform;

                meshObj.AddComponent <MeshRenderer>();
                meshFilters[i]            = meshObj.AddComponent <MeshFilter>();
                meshFilters[i].sharedMesh = new Mesh();
            }
            meshFilters[i].GetComponent <MeshRenderer>().sharedMaterial = colorParameters.planetMaterial;

            planetFaces[i] = new PlanetFace(meshFilters[i].sharedMesh, resolution, directions[i], shapeGenerator);
        }
    }
示例#4
0
    void Initialize()
    {
        if (res % 2 != 0)
        {
            res += 1;
        }

        if (meshFilters == null || meshFilters.Length == 0)
        {
            meshFilters = new MeshFilter[numOfChunks];
        }
        planetFaces = new PlanetFace[numOfChunks];

        Vector3[] directions = { Vector3.up, Vector3.down, Vector3.left, Vector3.right, Vector3.forward, Vector3.back };

        for (int i = 0; i < numOfChunks; i++)
        {
            if (meshFilters[i] == null)
            {
                GameObject meshObj   = new GameObject("mesh");
                GameObject FaceGroup = new GameObject("FaceGroup_" + i);
                FaceGroup.transform.parent = this.transform;
                meshObj.transform.parent   = FaceGroup.transform;

                meshObj.AddComponent <MeshRenderer>().sharedMaterial = mat;
                meshFilters[i]            = meshObj.AddComponent <MeshFilter>();
                meshFilters[i].sharedMesh = new Mesh();
            }

            planetFaces[i] = new PlanetFace(meshFilters[i].sharedMesh, res + 1, directions[i], planetRadius, sizeOfChunk, ChunkPos);
        }
    }
示例#5
0
    void Initialize()
    {
        int rootedValue = Mathf.RoundToInt(Mathf.Sqrt(values));

        if (meshFilters == null || meshFilters.Length == 0)
        {
            meshFilters = new MeshFilter[6, rootedValue, rootedValue];
        }
        planetFaces = new PlanetFace[6, rootedValue, rootedValue];

        Vector3[] directions = { Vector3.up, Vector3.down, Vector3.left, Vector3.right, Vector3.forward, Vector3.back };

        for (int i = 0; i < 6; i++)
        {
            GameObject FaceGroup = new GameObject("FaceGroup_" + i);
            FaceGroup.transform.parent = this.transform;
            for (int a = 0; a < rootedValue; a++)
            {
                for (int b = 0; b < rootedValue; b++)
                {
                    if (meshFilters[i, a, b] == null)
                    {
                        GameObject meshObj = new GameObject("mesh_" + a + "_" + b);
                        meshObj.transform.parent = FaceGroup.transform;

                        meshObj.AddComponent <MeshRenderer>().sharedMaterial = mat;
                        meshFilters[i, a, b]            = meshObj.AddComponent <MeshFilter>();
                        meshFilters[i, a, b].sharedMesh = new Mesh();
                    }
                    planetFaces[i, a, b] = new PlanetFace(meshFilters[i, a, b].sharedMesh, res, directions[i], planetRadius, values, a, b);
                }
            }
        }
    }
示例#6
0
    void SetupMesh()
    {
        for (int i = 0; i < 6; i++)
        {
            PlanetFace face     = faces[i];
            bool       renderIt = toRender.HasFlag((Faces)(1 << i));
            face.meshFilter.sharedMesh   = renderIt ? GenerateFaceMesh(directions[i], nbSegments) : null;
            face.meshCollider.sharedMesh = renderIt && !designMode?GenerateFaceMesh(directions[i], Mathf.CeilToInt(colliderPrecision *nbSegments)) : null;

            face.GetComponent <MeshRenderer>().sharedMaterial = coloursSettings.planetMaterial;
            colourGenerator.UpdateElevation(elevationMinMax);
        }
    }
示例#7
0
    // Create, initialize, and render the planet surfaces
    private void CreatePlanetSurface(PlanetFace planetFace)
    {
        // Calculate the max LOD based on the radius of the planet.
        lodMax = (int)Math.Log((float)((2.0f * Math.PI * radius) / 4.0f), 2);
        int cubeSize = lodMax * 2;

        GameObject go = new GameObject("Surface");

        go.transform.parent   = this.transform;
        go.transform.position = transform.position;
        PlanetSurface planetSurface = go.AddComponent <PlanetSurface>();

        planetSurface.InitializeRoot(this, planetFace, lodMax, cubeSize);
        //planetSurface.GenerateMesh(Spherized);
        planetSurfaces.Add(planetSurface);
    }
示例#8
0
 private void UpdatePlanetFace()
 {
     if (!CurrentFace.IsPositionOnFace(transform.position))
     {
         PlanetHandle handle =
             CurrentFace.GetClosestHandle(transform.position);
         if (handle.FirstFace != CurrentFace && handle.SwitchToFirstFace())
         {
             CurrentFace = handle.FirstFace;
         }
         if (handle.SecondFace != CurrentFace && handle.SwitchToSecondFace())
         {
             CurrentFace = handle.SecondFace;
         }
     }
 }
示例#9
0
    private void Initialise()
    {
        if (faces != null && filters != null && faces.Length == 6 && faces.Length == 6)
        {
            return;
        }

        faces   = new PlanetFace[6];
        filters = new MeshFilter[6];

        foreach (Face face in Enum.GetValues(typeof(Face)))
        {
            CreateFaceGameObject(face);

            faces[(int)face] = new PlanetFace(face.GetUpVector(), filters[(int)face].transform);
        }
    }
示例#10
0
    //
    // Summary:
    //     Creates a new World.
    //
    // Parameters:
    //   worldSize:
    //     Size of world, must be divisible by 8.
    //
    public WorldData(int worldSize)
    {
        if (worldSize % 8 != 0)
        {
            throw new System.Exception("worldSize must be divisible by 8");
        }

        //Init vars
        faces = new PlanetFace[6];
        Vector3[] upVectors = new Vector3[] { Vector3.up, Vector3.back, Vector3.right, Vector3.left, Vector3.forward, Vector3.down };
        chunkHolder    = new GameObject("ChunkHolder");
        this.worldSize = worldSize;

        //For each face
        for (int i = 0; i < 6; i++)
        {
            faces[i] = new PlanetFace(worldSize, upVectors[i]);
        }
    }
示例#11
0
 private bool SwitchToFace(PlanetFace face)
 {
     isGateActive = true;
     if (Planet.transform.parent != null)
     {
         return(false);
     }
     transform.rotation = Quaternion.LookRotation(
         transform.forward, face.transform.up);
     transform.parent        = null;
     Planet.transform.parent = transform;
     _currentZAngle          = transform.eulerAngles.z;
     if (_currentZAngle > 180)
     {
         _currentZAngle = _currentZAngle - 360;
     }
     DOTween.To(() => _currentZAngle, (val) => _currentZAngle = val, 0, 0.3f).
     OnComplete(OnTransitionComplete);
     _isInTransition = true;
     _activeFace     = face;
     return(true);
 }
示例#12
0
    void Initialize()
    {
        foreach (Transform child in this.transform)
        {
            GameObject.Destroy(child.gameObject);
        }
        Vector3[] directions =
        {
            Vector3.up, Vector3.down, Vector3.left, Vector3.right, Vector3.forward, Vector3.back
        };

        for (int i = 0; i < 6; i++)
        {
            GameObject meshObj = new GameObject("mesh-" + directions[i].ToString());
            meshObj.transform.parent = transform;
            meshObj.tag = "PlanetSide";
            meshObj.AddComponent <MeshRenderer>().sharedMaterial = new Material(Shader.Find("Standard"));
            meshFilters[i]            = meshObj.AddComponent <MeshFilter>();
            meshFilters[i].sharedMesh = new Mesh();
            meshColliders[i]          = meshObj.AddComponent <MeshCollider>();
            meshFilters[i].GetComponent <MeshRenderer>().sharedMaterial = colorSettings.planetMaterial;
            meshFilters[i].GetComponent <MeshRenderer>().material.SetTexture("_texture", type.planetTexture);
            planetFaces[i] = new PlanetFace(
                this.GetComponent <Planet>(),
                resourceGenerator,
                shapeGenerator,
                meshFilters[i].sharedMesh,
                meshColliders[i],
                resolution,
                directions[i],
                this.isTutorialWorld);
        }

        if (isTutorialWorld)
        {
            this.resourceGenerator.PlaceMine(new Vector3(0, this.GetComponent <Planet>().radius, 0));
        }
    }
示例#13
0
    // Initialize the surface and set its center and local X and Y axis based on the desired radius of the planet.
    public void InitializeRoot(Planet planet, PlanetFace planetFace, int lodLevel, int nodeSize)
    {
        this.planet     = planet;
        this.planetFace = planetFace;
        this.lodLevel   = lodLevel;
        if (planet.surfaceMaterial != null)
        {
            this.surfaceMaterial = planet.surfaceMaterial;
        }
        else
        {
            this.surfaceMaterial = new Material(Shader.Find("Standard"));
        }

        int nodeHalf = nodeSize / 2;

        switch (planetFace)
        {
        case PlanetFace.FRONT:
            base.name = base.name + " (Front)";
            center    = new Vector3(0, 0, -nodeHalf);
            localX    = new Vector3(nodeSize, 0, 0);
            localY    = new Vector3(0, nodeSize, 0);
            break;

        case PlanetFace.BACK:
            base.name = base.name + " (Back)";
            center    = new Vector3(0, 0, nodeHalf);
            localX    = new Vector3(-nodeSize, 0, 0);
            localY    = new Vector3(0, nodeSize, 0);
            break;

        case PlanetFace.LEFT:
            base.name = base.name + " (Left)";
            center    = new Vector3(-nodeHalf, 0, 0);
            localX    = new Vector3(0, 0, -nodeSize);
            localY    = new Vector3(0, nodeSize, 0);
            break;

        case PlanetFace.RIGHT:
            base.name = base.name + " (Right)";
            center    = new Vector3(nodeHalf, 0, 0);
            localX    = new Vector3(0, 0, nodeSize);
            localY    = new Vector3(0, nodeSize, 0);
            break;

        case PlanetFace.TOP:
            base.name = base.name + " (Top)";
            center    = new Vector3(0, nodeHalf, 0);
            localX    = new Vector3(-nodeSize, 0, 0);
            localY    = new Vector3(0, 0, -nodeSize);
            break;

        case PlanetFace.BOTTOM:
            base.name = base.name + " (Bottom)";
            center    = new Vector3(0, -nodeHalf, 0);
            localX    = new Vector3(nodeSize, 0, 0);
            localY    = new Vector3(0, 0, -nodeSize);
            break;
        }

        // If the mesh isn't already set then get the needed components and set a defaul mesh and material.
        if (mesh == null)
        {
            MeshFilter meshFilter = gameObject.GetComponent <MeshFilter>();
            mesh = meshFilter.sharedMesh = new Mesh();

            MeshRenderer meshRenderer = gameObject.GetComponent <MeshRenderer>();
            meshRenderer.sharedMaterial = surfaceMaterial;
        }

        if (lodLevel == 0)
        {
            isLeaf = true;
        }
        else
        {
            for (int i = 0; i < 4; i++)
            {
                GameObject go = new GameObject("Sub Surface");
                go.transform.parent   = this.transform;
                go.transform.position = transform.position;
                PlanetSurface planetSurface = go.AddComponent <PlanetSurface>();
                planetSurface.InitializeChild(this, (NodeType)i, lodLevel - 1, nodeSize);
                planetSubSurfaces.Add(planetSurface);
            }
        }
    }
示例#14
0
    private void InitializeChild(PlanetSurface parent, NodeType nodeType, int lodLevel, int nodeSize)
    {
        this.planet     = parent.planet;
        this.parent     = parent;
        this.planetFace = parent.planetFace;
        this.lodLevel   = lodLevel;
        if (planet.surfaceMaterial != null)
        {
            this.surfaceMaterial = parent.surfaceMaterial;
        }
        else
        {
            this.surfaceMaterial = new Material(Shader.Find("Standard"));
        }

        this.nodeSize = nodeSize;

        switch (nodeType)
        {
        case NodeType.BOTTOMLEFT:
            base.name = base.name + " (Bottom Left)";
            localX    = new Vector3(parent.localX.x / 2f, parent.localX.y / 2f, parent.localX.z / 2f);
            localY    = new Vector3(parent.localY.x / 2f, parent.localY.y / 2f, parent.localY.z / 2f);
            center    = parent.center - (localX / 2f) - (localY / 2f);
            break;

        case NodeType.TOPLEFT:
            base.name = base.name + " (Top Left)";
            localX    = new Vector3(parent.localX.x / 2f, parent.localX.y / 2f, parent.localX.z / 2f);
            localY    = new Vector3(parent.localY.x / 2f, parent.localY.y / 2f, parent.localY.z / 2f);
            center    = parent.center - (localX / 2f) + (localY / 2f);
            break;

        case NodeType.TOPRIGHT:
            base.name = base.name + " (Top Right)";
            localX    = new Vector3(parent.localX.x / 2f, parent.localX.y / 2f, parent.localX.z / 2f);
            localY    = new Vector3(parent.localY.x / 2f, parent.localY.y / 2f, parent.localY.z / 2f);
            center    = parent.center + (localX / 2f) + (localY / 2f);
            break;

        case NodeType.BOTTOMRIGHT:
            base.name = base.name + " (Bottom Right)";
            localX    = new Vector3(parent.localX.x / 2f, parent.localX.y / 2f, parent.localX.z / 2f);
            localY    = new Vector3(parent.localY.x / 2f, parent.localY.y / 2f, parent.localY.z / 2f);
            center    = parent.center + (localX / 2f) - (localY / 2f);
            break;
        }

        // If the mesh isn't already set then get the needed components and set a defaul mesh and material.
        if (mesh == null)
        {
            MeshFilter meshFilter = gameObject.GetComponent <MeshFilter>();
            mesh = meshFilter.sharedMesh = new Mesh();

            MeshRenderer meshRenderer = gameObject.GetComponent <MeshRenderer>();
            meshRenderer.sharedMaterial = surfaceMaterial;
        }

        if (lodLevel == 0)
        {
            isLeaf = true;
            GenerateMesh(planet.Spherized);
        }
        else
        {
            for (int i = 0; i < 4; i++)
            {
                GameObject go = new GameObject("Sub Surface");
                go.transform.parent   = this.transform;
                go.transform.position = transform.position;
                PlanetSurface planetSurface = go.AddComponent <PlanetSurface>();
                planetSurface.InitializeChild(this, (NodeType)i, lodLevel - 1, nodeSize);
                planetSubSurfaces.Add(planetSurface);
            }
        }
    }
示例#15
0
    public ChunkMeshData BuildChunk(int faceIndex, int chunkX, int chunkY, bool threaded)
    {
        //Init vars for for loop
        int           chunkSize = 8;
        ChunkMeshData data      = new ChunkMeshData();

        Vector3[] verts = new Vector3[chunkSize * chunkSize * 20];
        int[]     tris  = new int[chunkSize * chunkSize * 18 * 3];
        Vector2[] uvs   = new Vector2[chunkSize * chunkSize * 20];

        PlanetFace face       = faces[faceIndex];
        int        xOffset    = chunkX * 8;
        int        yOffset    = chunkY * 8;
        float      uvStepSize = 1f / 16;

        if (threaded)
        {
            //Create verts, tris and uvs
            Parallel.For(0, chunkSize * chunkSize, index =>
            {
                //Debug.Log(Thread.CurrentThread.ManagedThreadId);

                //init local vars
                int vertIndex = index * 12;
                int trisIndex = index * 18 * 3;

                //Get the position in the data array
                int xPos = (index % 8) + xOffset;
                int yPos = Mathf.FloorToInt(index / 8f) + yOffset;

                //Set the top vertices
                float height         = face.heightMap[xPos, yPos];
                verts[vertIndex]     = face.baseVertexPos[xPos, yPos] * height;
                verts[vertIndex + 1] = face.baseVertexPos[xPos + 1, yPos] * height;
                verts[vertIndex + 2] = face.baseVertexPos[xPos, yPos + 1] * height;
                verts[vertIndex + 3] = face.baseVertexPos[xPos + 1, yPos + 1] * height;

                //Set these values based on pillarType later, for now default to grass
                float topCornerX   = uvStepSize * 2;
                float topCornerY   = uvStepSize * 14;
                uvs[vertIndex]     = new Vector2(topCornerX, topCornerY);
                uvs[vertIndex + 1] = new Vector2(topCornerX + uvStepSize, topCornerY);
                uvs[vertIndex + 2] = new Vector2(topCornerX, topCornerY - uvStepSize);
                uvs[vertIndex + 3] = new Vector2(topCornerX + uvStepSize, topCornerY - uvStepSize);

                //Set the middle vertices, double all because uvs
                height = (face.heightMap[xPos, yPos] - 1);
                verts[vertIndex + 4]  = face.baseVertexPos[xPos, yPos] * height;
                verts[vertIndex + 5]  = face.baseVertexPos[xPos, yPos] * height;
                verts[vertIndex + 6]  = face.baseVertexPos[xPos + 1, yPos] * height;
                verts[vertIndex + 7]  = face.baseVertexPos[xPos + 1, yPos] * height;
                verts[vertIndex + 8]  = face.baseVertexPos[xPos + 1, yPos + 1] * height;
                verts[vertIndex + 9]  = face.baseVertexPos[xPos + 1, yPos + 1] * height;
                verts[vertIndex + 10] = face.baseVertexPos[xPos, yPos + 1] * height;
                verts[vertIndex + 11] = face.baseVertexPos[xPos, yPos + 1] * height;

                float doubleStep    = uvStepSize * 2;
                uvs[vertIndex + 4]  = new Vector2(topCornerX - uvStepSize, topCornerY);
                uvs[vertIndex + 5]  = new Vector2(topCornerX, topCornerY + uvStepSize);
                uvs[vertIndex + 6]  = new Vector2(topCornerX + uvStepSize, topCornerY + uvStepSize);
                uvs[vertIndex + 7]  = new Vector2(topCornerX + doubleStep, topCornerY);
                uvs[vertIndex + 8]  = new Vector2(topCornerX + doubleStep, topCornerY - uvStepSize);
                uvs[vertIndex + 9]  = new Vector2(topCornerX + uvStepSize, topCornerY - doubleStep);
                uvs[vertIndex + 10] = new Vector2(topCornerX, topCornerY - doubleStep);
                uvs[vertIndex + 11] = new Vector2(topCornerX - uvStepSize, topCornerY - uvStepSize);

                //Set the bottom vertices, double all because uvs
                verts[vertIndex + 12] = face.baseVertexPos[xPos, yPos];
                verts[vertIndex + 13] = face.baseVertexPos[xPos, yPos];
                verts[vertIndex + 14] = face.baseVertexPos[xPos + 1, yPos];
                verts[vertIndex + 15] = face.baseVertexPos[xPos + 1, yPos];
                verts[vertIndex + 16] = face.baseVertexPos[xPos + 1, yPos + 1];
                verts[vertIndex + 17] = face.baseVertexPos[xPos + 1, yPos + 1];
                verts[vertIndex + 18] = face.baseVertexPos[xPos, yPos + 1];
                verts[vertIndex + 19] = face.baseVertexPos[xPos, yPos + 1];

                uvStepSize         *= 2;
                doubleStep         *= 2;
                uvs[vertIndex + 12] = new Vector2(topCornerX - uvStepSize, topCornerY);
                uvs[vertIndex + 13] = new Vector2(topCornerX, topCornerY + uvStepSize);
                uvs[vertIndex + 14] = new Vector2(topCornerX + uvStepSize, topCornerY + uvStepSize);
                uvs[vertIndex + 15] = new Vector2(topCornerX + doubleStep, topCornerY);
                uvs[vertIndex + 16] = new Vector2(topCornerX + doubleStep, topCornerY - uvStepSize);
                uvs[vertIndex + 17] = new Vector2(topCornerX + uvStepSize, topCornerY - doubleStep);
                uvs[vertIndex + 18] = new Vector2(topCornerX, topCornerY - doubleStep);
                uvs[vertIndex + 19] = new Vector2(topCornerX - uvStepSize, topCornerY - uvStepSize);
                uvStepSize         *= 0.5f;

                //Set the top face
                tris[trisIndex]     = vertIndex;
                tris[trisIndex + 1] = vertIndex + 1;
                tris[trisIndex + 2] = vertIndex + 2;
                tris[trisIndex + 3] = vertIndex + 1;
                tris[trisIndex + 4] = vertIndex + 3;
                tris[trisIndex + 5] = vertIndex + 2;

                trisIndex += 6;

                //Set the side faces, once for top sides, once for sides that go to world center

                //Back side
                tris[trisIndex]     = vertIndex;
                tris[trisIndex + 1] = vertIndex + 5;
                tris[trisIndex + 2] = vertIndex + 6;
                tris[trisIndex + 3] = vertIndex + 1;
                tris[trisIndex + 4] = vertIndex;
                tris[trisIndex + 5] = vertIndex + 6;
                //Right side
                tris[trisIndex + 6]  = vertIndex + 1;
                tris[trisIndex + 7]  = vertIndex + 7;
                tris[trisIndex + 8]  = vertIndex + 8;
                tris[trisIndex + 9]  = vertIndex + 3;
                tris[trisIndex + 10] = vertIndex + 1;
                tris[trisIndex + 11] = vertIndex + 8;
                //Front side
                tris[trisIndex + 12] = vertIndex + 3;
                tris[trisIndex + 13] = vertIndex + 9;
                tris[trisIndex + 14] = vertIndex + 10;
                tris[trisIndex + 15] = vertIndex + 2;
                tris[trisIndex + 16] = vertIndex + 3;
                tris[trisIndex + 17] = vertIndex + 10;
                //Left side
                tris[trisIndex + 18] = vertIndex + 2;
                tris[trisIndex + 19] = vertIndex + 11;
                tris[trisIndex + 20] = vertIndex + 4;
                tris[trisIndex + 21] = vertIndex;
                tris[trisIndex + 22] = vertIndex + 2;
                tris[trisIndex + 23] = vertIndex + 4;

                //Bottom side faces
                //Back side
                tris[trisIndex + 24] = vertIndex + 5;
                tris[trisIndex + 25] = vertIndex + 13;
                tris[trisIndex + 26] = vertIndex + 14;
                tris[trisIndex + 27] = vertIndex + 6;
                tris[trisIndex + 28] = vertIndex + 5;
                tris[trisIndex + 29] = vertIndex + 14;
                //Right side
                tris[trisIndex + 30] = vertIndex + 7;
                tris[trisIndex + 31] = vertIndex + 15;
                tris[trisIndex + 32] = vertIndex + 16;
                tris[trisIndex + 33] = vertIndex + 8;
                tris[trisIndex + 34] = vertIndex + 7;
                tris[trisIndex + 35] = vertIndex + 16;
                //Front side
                tris[trisIndex + 36] = vertIndex + 9;
                tris[trisIndex + 37] = vertIndex + 17;
                tris[trisIndex + 38] = vertIndex + 18;
                tris[trisIndex + 39] = vertIndex + 10;
                tris[trisIndex + 40] = vertIndex + 9;
                tris[trisIndex + 41] = vertIndex + 18;
                //Left side
                tris[trisIndex + 42] = vertIndex + 11;
                tris[trisIndex + 43] = vertIndex + 19;
                tris[trisIndex + 44] = vertIndex + 12;
                tris[trisIndex + 45] = vertIndex + 4;
                tris[trisIndex + 46] = vertIndex + 11;
                tris[trisIndex + 47] = vertIndex + 12;

                vertIndex += 20;
                trisIndex += 48;
            });
        }
        else
        {
            int vertIndex = 0;
            int trisIndex = 0;

            for (int x = 0; x < chunkSize; x++)
            {
                for (int y = 0; y < chunkSize; y++)
                {
                    //Get the position in the data array
                    int xPos = x + xOffset;
                    int yPos = y + yOffset;

                    //Set the top vertices
                    float height = face.heightMap[xPos, yPos];
                    verts[vertIndex]     = face.baseVertexPos[xPos, yPos] * height;
                    verts[vertIndex + 1] = face.baseVertexPos[xPos + 1, yPos] * height;
                    verts[vertIndex + 2] = face.baseVertexPos[xPos, yPos + 1] * height;
                    verts[vertIndex + 3] = face.baseVertexPos[xPos + 1, yPos + 1] * height;

                    //Set these values based on pillarType later, for now default to grass
                    float topCornerX = uvStepSize * 2;
                    float topCornerY = uvStepSize * 14;
                    uvs[vertIndex]     = new Vector2(topCornerX, topCornerY);
                    uvs[vertIndex + 1] = new Vector2(topCornerX + uvStepSize, topCornerY);
                    uvs[vertIndex + 2] = new Vector2(topCornerX, topCornerY - uvStepSize);
                    uvs[vertIndex + 3] = new Vector2(topCornerX + uvStepSize, topCornerY - uvStepSize);

                    //Set the middle vertices, double all because uvs
                    height = (face.heightMap[xPos, yPos] - 1);
                    verts[vertIndex + 4]  = face.baseVertexPos[xPos, yPos] * height;
                    verts[vertIndex + 5]  = face.baseVertexPos[xPos, yPos] * height;
                    verts[vertIndex + 6]  = face.baseVertexPos[xPos + 1, yPos] * height;
                    verts[vertIndex + 7]  = face.baseVertexPos[xPos + 1, yPos] * height;
                    verts[vertIndex + 8]  = face.baseVertexPos[xPos + 1, yPos + 1] * height;
                    verts[vertIndex + 9]  = face.baseVertexPos[xPos + 1, yPos + 1] * height;
                    verts[vertIndex + 10] = face.baseVertexPos[xPos, yPos + 1] * height;
                    verts[vertIndex + 11] = face.baseVertexPos[xPos, yPos + 1] * height;

                    float doubleStep = uvStepSize * 2;
                    uvs[vertIndex + 4]  = new Vector2(topCornerX - uvStepSize, topCornerY);
                    uvs[vertIndex + 5]  = new Vector2(topCornerX, topCornerY + uvStepSize);
                    uvs[vertIndex + 6]  = new Vector2(topCornerX + uvStepSize, topCornerY + uvStepSize);
                    uvs[vertIndex + 7]  = new Vector2(topCornerX + doubleStep, topCornerY);
                    uvs[vertIndex + 8]  = new Vector2(topCornerX + doubleStep, topCornerY - uvStepSize);
                    uvs[vertIndex + 9]  = new Vector2(topCornerX + uvStepSize, topCornerY - doubleStep);
                    uvs[vertIndex + 10] = new Vector2(topCornerX, topCornerY - doubleStep);
                    uvs[vertIndex + 11] = new Vector2(topCornerX - uvStepSize, topCornerY - uvStepSize);

                    //Set the bottom vertices, double all because uvs
                    verts[vertIndex + 12] = face.baseVertexPos[xPos, yPos];
                    verts[vertIndex + 13] = face.baseVertexPos[xPos, yPos];
                    verts[vertIndex + 14] = face.baseVertexPos[xPos + 1, yPos];
                    verts[vertIndex + 15] = face.baseVertexPos[xPos + 1, yPos];
                    verts[vertIndex + 16] = face.baseVertexPos[xPos + 1, yPos + 1];
                    verts[vertIndex + 17] = face.baseVertexPos[xPos + 1, yPos + 1];
                    verts[vertIndex + 18] = face.baseVertexPos[xPos, yPos + 1];
                    verts[vertIndex + 19] = face.baseVertexPos[xPos, yPos + 1];

                    uvStepSize         *= 2;
                    doubleStep         *= 2;
                    uvs[vertIndex + 12] = new Vector2(topCornerX - uvStepSize, topCornerY);
                    uvs[vertIndex + 13] = new Vector2(topCornerX, topCornerY + uvStepSize);
                    uvs[vertIndex + 14] = new Vector2(topCornerX + uvStepSize, topCornerY + uvStepSize);
                    uvs[vertIndex + 15] = new Vector2(topCornerX + doubleStep, topCornerY);
                    uvs[vertIndex + 16] = new Vector2(topCornerX + doubleStep, topCornerY - uvStepSize);
                    uvs[vertIndex + 17] = new Vector2(topCornerX + uvStepSize, topCornerY - doubleStep);
                    uvs[vertIndex + 18] = new Vector2(topCornerX, topCornerY - doubleStep);
                    uvs[vertIndex + 19] = new Vector2(topCornerX - uvStepSize, topCornerY - uvStepSize);
                    uvStepSize         *= 0.5f;

                    //Set the top face
                    tris[trisIndex]     = vertIndex;
                    tris[trisIndex + 1] = vertIndex + 1;
                    tris[trisIndex + 2] = vertIndex + 2;
                    tris[trisIndex + 3] = vertIndex + 1;
                    tris[trisIndex + 4] = vertIndex + 3;
                    tris[trisIndex + 5] = vertIndex + 2;

                    trisIndex += 6;

                    //Set the side faces, once for top sides, once for sides that go to world center

                    //Back side
                    tris[trisIndex]     = vertIndex;
                    tris[trisIndex + 1] = vertIndex + 5;
                    tris[trisIndex + 2] = vertIndex + 6;
                    tris[trisIndex + 3] = vertIndex + 1;
                    tris[trisIndex + 4] = vertIndex;
                    tris[trisIndex + 5] = vertIndex + 6;
                    //Right side
                    tris[trisIndex + 6]  = vertIndex + 1;
                    tris[trisIndex + 7]  = vertIndex + 7;
                    tris[trisIndex + 8]  = vertIndex + 8;
                    tris[trisIndex + 9]  = vertIndex + 3;
                    tris[trisIndex + 10] = vertIndex + 1;
                    tris[trisIndex + 11] = vertIndex + 8;
                    //Front side
                    tris[trisIndex + 12] = vertIndex + 3;
                    tris[trisIndex + 13] = vertIndex + 9;
                    tris[trisIndex + 14] = vertIndex + 10;
                    tris[trisIndex + 15] = vertIndex + 2;
                    tris[trisIndex + 16] = vertIndex + 3;
                    tris[trisIndex + 17] = vertIndex + 10;
                    //Left side
                    tris[trisIndex + 18] = vertIndex + 2;
                    tris[trisIndex + 19] = vertIndex + 11;
                    tris[trisIndex + 20] = vertIndex + 4;
                    tris[trisIndex + 21] = vertIndex;
                    tris[trisIndex + 22] = vertIndex + 2;
                    tris[trisIndex + 23] = vertIndex + 4;

                    //Bottom side faces
                    //Back side
                    tris[trisIndex + 24] = vertIndex + 5;
                    tris[trisIndex + 25] = vertIndex + 13;
                    tris[trisIndex + 26] = vertIndex + 14;
                    tris[trisIndex + 27] = vertIndex + 6;
                    tris[trisIndex + 28] = vertIndex + 5;
                    tris[trisIndex + 29] = vertIndex + 14;
                    //Right side
                    tris[trisIndex + 30] = vertIndex + 7;
                    tris[trisIndex + 31] = vertIndex + 15;
                    tris[trisIndex + 32] = vertIndex + 16;
                    tris[trisIndex + 33] = vertIndex + 8;
                    tris[trisIndex + 34] = vertIndex + 7;
                    tris[trisIndex + 35] = vertIndex + 16;
                    //Front side
                    tris[trisIndex + 36] = vertIndex + 9;
                    tris[trisIndex + 37] = vertIndex + 17;
                    tris[trisIndex + 38] = vertIndex + 18;
                    tris[trisIndex + 39] = vertIndex + 10;
                    tris[trisIndex + 40] = vertIndex + 9;
                    tris[trisIndex + 41] = vertIndex + 18;
                    //Left side
                    tris[trisIndex + 42] = vertIndex + 11;
                    tris[trisIndex + 43] = vertIndex + 19;
                    tris[trisIndex + 44] = vertIndex + 12;
                    tris[trisIndex + 45] = vertIndex + 4;
                    tris[trisIndex + 46] = vertIndex + 11;
                    tris[trisIndex + 47] = vertIndex + 12;

                    vertIndex += 20;
                    trisIndex += 48;
                }
            }
        }

        data.verts = verts;
        data.tris  = tris;
        data.uvs   = uvs;

        return(data);
    }