private void DoWork()
    {
        Vector3 vector3_1;

        ((Vector3) ref vector3_1).\u002Ector((float)(this.width / 2), 0.0f, (float)(this.height / 2));
        Vector3 vector3_2;

        ((Vector3) ref vector3_2).\u002Ector((float)(this.pivot.x - vector3_1.x), 0.0f, (float)(this.pivot.z - vector3_1.z));
        TerrainHeightMap heightMap = TerrainMeta.HeightMap;
        TerrainAlphaMap  alphaMap  = TerrainMeta.AlphaMap;
        int num1 = 0;

        for (int index = 0; index <= this.height; ++index)
        {
            int num2 = 0;
            while (num2 <= this.width)
            {
                Vector3 worldPos  = Vector3.op_Addition(new Vector3((float)num2, 0.0f, (float)index), vector3_2);
                Vector3 vector3_3 = Vector3.op_Subtraction(new Vector3((float)num2, 0.0f, (float)index), vector3_1);
                float   height    = heightMap.GetHeight(worldPos);
                if ((double)height < -1.0)
                {
                    this.indices.Add(-1);
                }
                else if (this.alpha && (double)alphaMap.GetAlpha(worldPos) < 0.100000001490116)
                {
                    this.indices.Add(-1);
                }
                else
                {
                    if (this.normal)
                    {
                        this.normals.Add(heightMap.GetNormal(worldPos));
                    }
                    worldPos.y = (__Null)(double)(vector3_3.y = (__Null)(height - (float)this.pivot.y));
                    this.indices.Add(this.vertices.Count);
                    this.vertices.Add(vector3_3);
                }
                ++num2;
                ++num1;
            }
        }
        int index1 = 0;
        int num3   = 0;

        while (num3 < this.height)
        {
            int num2 = 0;
            while (num2 < this.width)
            {
                int index2 = this.indices[index1];
                int index3 = this.indices[index1 + this.width + 1];
                int index4 = this.indices[index1 + 1];
                int index5 = this.indices[index1 + 1];
                int index6 = this.indices[index1 + this.width + 1];
                int index7 = this.indices[index1 + this.width + 2];
                if (index2 != -1 && index3 != -1 && index4 != -1)
                {
                    this.triangles.Add(index2);
                    this.triangles.Add(index3);
                    this.triangles.Add(index4);
                }
                if (index5 != -1 && index6 != -1 && index7 != -1)
                {
                    this.triangles.Add(index5);
                    this.triangles.Add(index6);
                    this.triangles.Add(index7);
                }
                ++num2;
                ++index1;
            }
            ++num3;
            ++index1;
        }
    }
Esempio n. 2
0
    private void DoWork()
    {
        Vector3          vector3   = new Vector3((float)(this.width / 2), 0f, (float)(this.height / 2));
        Vector3          vector31  = new Vector3(this.pivot.x - vector3.x, 0f, this.pivot.z - vector3.z);
        TerrainHeightMap heightMap = TerrainMeta.HeightMap;
        TerrainAlphaMap  alphaMap  = TerrainMeta.AlphaMap;
        int num = 0;

        for (int i = 0; i <= this.height; i++)
        {
            int num1 = 0;
            while (num1 <= this.width)
            {
                Vector3 vector32 = new Vector3((float)num1, 0f, (float)i) + vector31;
                Vector3 vector33 = new Vector3((float)num1, 0f, (float)i) - vector3;
                float   height   = heightMap.GetHeight(vector32);
                if (height < -1f)
                {
                    this.indices.Add(-1);
                }
                else if (!this.alpha || alphaMap.GetAlpha(vector32) >= 0.1f)
                {
                    if (this.normal)
                    {
                        Vector3 normal = heightMap.GetNormal(vector32);
                        this.normals.Add(normal);
                    }
                    float single  = height - this.pivot.y;
                    float single1 = single;
                    vector33.y = single;
                    vector32.y = single1;
                    this.indices.Add(this.vertices.Count);
                    this.vertices.Add(vector33);
                }
                else
                {
                    this.indices.Add(-1);
                }
                num1++;
                num++;
            }
        }
        int num2 = 0;
        int num3 = 0;

        while (num3 < this.height)
        {
            int num4 = 0;
            while (num4 < this.width)
            {
                int item  = this.indices[num2];
                int item1 = this.indices[num2 + this.width + 1];
                int item2 = this.indices[num2 + 1];
                int item3 = this.indices[num2 + 1];
                int item4 = this.indices[num2 + this.width + 1];
                int item5 = this.indices[num2 + this.width + 2];
                if (item != -1 && item1 != -1 && item2 != -1)
                {
                    this.triangles.Add(item);
                    this.triangles.Add(item1);
                    this.triangles.Add(item2);
                }
                if (item3 != -1 && item4 != -1 && item5 != -1)
                {
                    this.triangles.Add(item3);
                    this.triangles.Add(item4);
                    this.triangles.Add(item5);
                }
                num4++;
                num2++;
            }
            num3++;
            num2++;
        }
    }
    private void DoWork()
    {
        Vector3          vector    = new Vector3(width / 2, 0f, height / 2);
        Vector3          vector2   = new Vector3(pivot.x - vector.x, 0f, pivot.z - vector.z);
        TerrainHeightMap heightMap = TerrainMeta.HeightMap;
        TerrainAlphaMap  alphaMap  = TerrainMeta.AlphaMap;
        int num = 0;

        for (int i = 0; i <= height; i++)
        {
            int num2 = 0;
            while (num2 <= width)
            {
                Vector3 worldPos = new Vector3(num2, 0f, i) + vector2;
                Vector3 item     = new Vector3(num2, 0f, i) - vector;
                float   num3     = heightMap.GetHeight(worldPos);
                if (num3 < -1f)
                {
                    indices.Add(-1);
                }
                else if (alpha && alphaMap.GetAlpha(worldPos) < 0.1f)
                {
                    indices.Add(-1);
                }
                else
                {
                    if (normal)
                    {
                        Vector3 item2 = heightMap.GetNormal(worldPos);
                        normals.Add(item2);
                    }
                    worldPos.y = (item.y = num3 - pivot.y);
                    indices.Add(vertices.Count);
                    vertices.Add(item);
                }
                num2++;
                num++;
            }
        }
        int num4 = 0;
        int num5 = 0;

        while (num5 < height)
        {
            int num6 = 0;
            while (num6 < width)
            {
                int num7  = indices[num4];
                int num8  = indices[num4 + width + 1];
                int num9  = indices[num4 + 1];
                int num10 = indices[num4 + 1];
                int num11 = indices[num4 + width + 1];
                int num12 = indices[num4 + width + 2];
                if (num7 != -1 && num8 != -1 && num9 != -1)
                {
                    triangles.Add(num7);
                    triangles.Add(num8);
                    triangles.Add(num9);
                }
                if (num10 != -1 && num11 != -1 && num12 != -1)
                {
                    triangles.Add(num10);
                    triangles.Add(num11);
                    triangles.Add(num12);
                }
                num6++;
                num4++;
            }
            num5++;
            num4++;
        }
    }