public static RenderTriangle Create(PositionTexture a, PositionTexture b, PositionTexture c, ImageElement img, int level)
        {
            RenderTriangle temp = new RenderTriangle();

            temp.A = a.Copy();
            temp.B = b.Copy();
            temp.C = c.Copy();
            temp.texture = img;
            temp.TileLevel = level;
            return temp;
        }
 public static RenderTriangle CreateWithMiter(PositionTexture a, PositionTexture b, PositionTexture c, ImageElement img, int level, double expansion)
 {
     RenderTriangle temp = new RenderTriangle();
     temp.ExpansionInPixels = expansion;
     temp.A = a.Copy();
     temp.B = b.Copy();
     temp.C = c.Copy();
     temp.texture = img;
     temp.TileLevel = level;
     temp.MakeNormal();
     return temp;
 }
Beispiel #3
0
        public void AddGlyphPoints(List<PositionTexture> pointList, Vector2d size, Rectangle position, Rectangle uv)
        {
            PositionTexture[] points = new PositionTexture[6];

            for(int i=0; i<6;i++)
            {
                points[i] = new PositionTexture();
            }

            Vector3d left = Vector3d.Cross(center, up);
            Vector3d right = Vector3d.Cross(up, center);

            left.Normalize();
            right.Normalize();
            up.Normalize();

            Vector3d upTan = Vector3d.Cross(center, right);

            upTan.Normalize();

            if (alignment == Alignment.Center)
            {
                left.Multiply(width - position.Left * 2);
                right.Multiply(width - ((width * 2) - position.Right * 2));
            }
            else if (alignment == Alignment.Left)
            {
                left.Multiply(-position.Left * 2);
                right.Multiply(position.Right * 2);
            }

            Vector3d top = upTan.Copy();
            Vector3d bottom = Vector3d.SubtractVectors(Vector3d.Empty,upTan);

            top.Multiply(height - position.Top * 2);
            bottom.Multiply(height - ((height * 2) - position.Bottom * 2));
            Vector3d ul = center.Copy();
            ul.Add(top);
            if (sky)
            {
                ul.Add(left);
            }
            else
            {
                ul.Subtract(left);
            }
            Vector3d ur = center.Copy();
            ur.Add(top);
            if (sky)
            {
                ur.Add(right);
            }
            else
            {
                ur.Subtract(right);
            }
            Vector3d ll = center.Copy();
            if (sky)
            {
                ll.Add(left);
            }
            else
            {
                ll.Subtract(left);
            }

            ll.Add(bottom);

            Vector3d lr = center.Copy();
            if (sky)
            {
                lr.Add(right);
            }
            else
            {
                lr.Subtract(right);
            }
            lr.Add(bottom);

            points[0].Position = ul.Copy();
            points[0].Tu = uv.Left;
            points[0].Tv = uv.Top;
               //     points[0].Color = Color;

            points[2].Tu = uv.Left;
            points[2].Tv = uv.Bottom;
            points[2].Position = ll.Copy();
              //      points[2].Color = Color;

            points[1].Tu = uv.Right;
            points[1].Tv = uv.Top;
            points[1].Position = ur.Copy();
              //      points[1].Color = Color;

            points[3].Tu = uv.Right;
            points[3].Tv = uv.Bottom;
            points[3].Position = lr.Copy();
              //      points[3].Color = Color;

            points[5].Tu = uv.Right;
            points[5].Tv = uv.Top;
            points[5].Position = ur.Copy();
               //     points[5].Color = Color;

            points[4].Tu = uv.Left;
            points[4].Tv = uv.Bottom;
            points[4].Position = ll.Copy();
               //     points[4].Color = Color;

            if (Rotation != 0 || Tilt != 0 || Bank != 0)
            {
                if (!matInit)
                {
                    Matrix3d lookAt = Matrix3d.LookAtLH(center, new Vector3d(), up);
                    Matrix3d lookAtInv = lookAt.Clone();
                    lookAtInv.Invert();

                    rtbMat =  Matrix3d.MultiplyMatrix(Matrix3d.MultiplyMatrix(Matrix3d.MultiplyMatrix( Matrix3d.MultiplyMatrix(lookAt, Matrix3d.RotationZ(-Rotation / 180 * Math.PI)),  Matrix3d.RotationX(-Tilt / 180 * Math.PI)),  Matrix3d.RotationY(-Bank / 180 * Math.PI)), lookAtInv);
                    //todo make this true after debug
                    matInit = true;
                }
                for (int i = 0; i < 6; i++)
                {
                    points[i].Position = Vector3d.TransformCoordinate(points[i].Position, rtbMat);
                }
            }

            pointList.AddRange(points);
        }
Beispiel #4
0
        public int AddVertex(float[] buffer, int index, PositionTexture p)
        {
            buffer[index++] = (float)p.Position.X;
            buffer[index++] = (float)p.Position.Y;
            buffer[index++] = (float)p.Position.Z;
            buffer[index++] = (float)p.Tu;
            buffer[index++] = (float)p.Tv;

            return index;
        }
Beispiel #5
0
        private PositionTexture Midpoint(PositionTexture positionNormalTextured, PositionTexture positionNormalTextured_2)
        {
            Vector3d a1 = Vector3d.Lerp(positionNormalTextured.Position, positionNormalTextured_2.Position, .5f);
            Vector2d a1uv = Vector2d.Lerp(Vector2d.Create(positionNormalTextured.Tu, positionNormalTextured.Tv), Vector2d.Create(positionNormalTextured_2.Tu, positionNormalTextured_2.Tv), .5f);

            a1.Normalize();
            return PositionTexture.CreatePos(a1, a1uv.X, a1uv.Y);
        }
Beispiel #6
0
        internal PositionTexture GetMappedVertex(PositionTexture vert)
        {
            PositionTexture vertOut = new PositionTexture();
            Coordinates latLng = Coordinates.CartesianToSpherical2(vert.Position);
            //      latLng.Lng += 90;
            if (latLng.Lng < -180)
            {
                latLng.Lng += 360;
            }
            if (latLng.Lng > 180)
            {
                latLng.Lng -= 360;
            }

            if (Level > 1)
            {
                byte arrayX = (byte)(int)(vert.Tu * 16 + .5);
                byte arrayY = (byte)(int)(vert.Tv * 16 + .5);
                demArray[arrayX + arrayY * 17] = DemData[demIndex];

                if (backslash)
                {
                    if (tempBackslashYIndex != null)
                    {
                        tempBackslashXIndex[demIndex] = arrayX;
                        tempBackslashYIndex[demIndex] = arrayY;
                    }
                }
                else
                {
                    if (tempSlashYIndex != null)
                    {
                        tempSlashXIndex[demIndex] = arrayX;
                        tempSlashYIndex[demIndex] = arrayY;
                    }
                }
            }

            Vector3d pos = GeoTo3dWithAlt(latLng.Lat, latLng.Lng, false, false);
            vertOut.Tu = (float)vert.Tu;
            vertOut.Tv = (float)vert.Tv;

            //vertOut.Lat = latLng.Lat;
            //vertOut.Lng = latLng.Lng;
            //vertOut.Normal = pos;
            pos.Subtract(localCenter);
            vertOut.Position = pos;

            return vertOut;
        }
Beispiel #7
0
 //{
 //    get
 //    {
 //        return Vector3d.Create(X, Y, Z);
 //    }
 //    set
 //    {
 //        X = value.X;
 //        Y = value.Y;
 //        Z = value.Z;
 //    }
 //}
 public PositionTexture Copy()
 {
     PositionTexture temp = new PositionTexture();
     temp.Position = Vector3d.MakeCopy(this.Position);
     temp.Tu = this.Tu;
     temp.Tv = this.Tv;
     return temp;
 }
Beispiel #8
0
        public static PositionTexture CreatePosSize(Vector3d pos, double u, double v, double width, double height)
        {
            PositionTexture temp = new PositionTexture();

            temp.Tu = u * width;
            temp.Tv = v * height;
            temp.Position = pos;

            return temp;
        }
Beispiel #9
0
        public static PositionTexture CreatePosRaw(Vector3d pos, double u, double v)
        {
            PositionTexture temp = new PositionTexture();

            temp.Tu = u;
            temp.Tv = v;
            temp.Position = pos;

            return temp;
        }
Beispiel #10
0
        //
        // Summary:
        //     Initializes a new instance of the Microsoft.DirectX.Direct3D.CustomVertex.PositionTextured
        //     class.
        //
        // Parameters:
        //   pos:
        //     A Microsoft.DirectX.Vector3d object that contains the vertex position.
        //
        //   u:
        //     Floating-point value that represents the Microsoft.DirectX.Direct3D.CustomVertex.PositionTextured.#ctor()
        //     component of the texture coordinate.
        //
        //   v:
        //     Floating-point value that represents the Microsoft.DirectX.Direct3D.CustomVertex.PositionTextured.#ctor()
        //     component of the texture coordinate.
        public static PositionTexture CreatePos(Vector3d pos, double u, double v)
        {
            PositionTexture temp = new PositionTexture();

            temp.Tu = u*Tile.uvMultiple;
            temp.Tv = v*Tile.uvMultiple;
            temp.Position = pos;

            return temp;
        }
Beispiel #11
0
 //
 // Summary:
 //     Initializes a new instance of the Microsoft.DirectX.Direct3D.CustomVertex.PositionTextured
 //     class.
 //
 // Parameters:
 //   xvalue:
 //     Floating-point value that represents the x coordinate of the position.
 //
 //   yvalue:
 //     Floating-point value that represents the y coordinate of the position.
 //
 //   zvalue:
 //     Floating-point value that represents the z coordinate of the position.
 //
 //   u:
 //     Floating-point value that represents the Microsoft.DirectX.Direct3D.CustomVertex.PositionTextured.#ctor()
 //     component of the texture coordinate.
 //
 //   v:
 //     Floating-point value that represents the Microsoft.DirectX.Direct3D.CustomVertex.PositionTextured.#ctor()
 //     component of the texture coordinate.
 public static PositionTexture Create(double xvalue, double yvalue, double zvalue, double u, double v)
 {
     PositionTexture temp = new PositionTexture();
     temp.Position = Vector3d.Create(xvalue, yvalue, zvalue);
     temp.Tu = u*Tile.uvMultiple;
     temp.Tv = v*Tile.uvMultiple;
     return temp;
 }
Beispiel #12
0
        public override bool CreateGeometry(RenderContext renderContext)
        {
            base.CreateGeometry(renderContext);

            if (GeometryCreated)
            {
                return true;
            }
            GeometryCreated = true;

            if (uvMultiple == 256)
            {
                if (dataset.DataSetType == ImageSetType.Earth || dataset.DataSetType == ImageSetType.Planet)
                {
                    subDivisionLevel = Math.Max(2, (6 - Level) * 2);
                }
            }

            for (int i = 0; i < 4; i++)
            {
                RenderTriangleLists[i] = new List<RenderTriangle>();
            }

            //    try
            {
                double lat, lng;

                int index = 0;
                double tileDegrees = 360 / (Math.Pow(2, this.Level));

                latMin = AbsoluteMetersToLatAtZoom(tileY * 256, Level);
                latMax = AbsoluteMetersToLatAtZoom((tileY + 1) * 256, Level);
                lngMin = (((double)this.tileX * tileDegrees) - 180.0);
                lngMax = ((((double)(this.tileX + 1)) * tileDegrees) - 180.0);

                double latCenter = AbsoluteMetersToLatAtZoom(((tileY * 2) + 1) * 256, Level + 1);

                TopLeft = (Vector3d)GeoTo3d(latMin, lngMin, false);
                BottomRight = (Vector3d)GeoTo3d(latMax, lngMax, false);
                TopRight = (Vector3d)GeoTo3d(latMin, lngMax, false);
                BottomLeft = (Vector3d)GeoTo3d(latMax, lngMin, false);

                PositionTexture[] verts = new PositionTexture[(subDivisionLevel + 1) * (subDivisionLevel + 1)];

                tileDegrees = lngMax - lngMin;
                double dGrid = (tileDegrees / subDivisionLevel);
                int x1, y1;
                double textureStep = 1.0f / subDivisionLevel;

                double latDegrees = latMax - latCenter;

                for (y1 = 0; y1 < subDivisionLevel / 2; y1++)
                {

                    if (y1 != subDivisionLevel / 2)
                    {
                        lat = latMax - (2 * textureStep * latDegrees * (double)y1);
                    }
                    else
                    {
                        lat = latCenter;
                    }

                    for (x1 = 0; x1 <= subDivisionLevel; x1++)
                    {
                        if (x1 != subDivisionLevel)
                        {
                            lng = lngMin + (textureStep * tileDegrees * (double)x1);
                        }
                        else
                        {
                            lng = lngMax;
                        }
                        index = y1 * (subDivisionLevel + 1) + x1;
                        verts[index] = new PositionTexture();
                        verts[index].Position = (Vector3d)GeoTo3dWithAlt(lat, lng, false, true);// Add Altitude mapping here
                        verts[index].Tu = (x1 * textureStep)*Tile.uvMultiple;
                        verts[index].Tv = ((AbsoluteLatToMetersAtZoom(lat, Level) - (tileY * 256)) / 256f)*Tile.uvMultiple;
                        demIndex++;
                    }
                }
                latDegrees = latMin - latCenter;

                for (y1 = subDivisionLevel / 2; y1 <= subDivisionLevel; y1++)
                {

                    if (y1 != subDivisionLevel)
                    {
                        lat = latCenter + (2 * textureStep * latDegrees * (double)(y1 - (subDivisionLevel / 2)));
                    }
                    else
                    {
                        lat = latMin;
                    }

                    for (x1 = 0; x1 <= subDivisionLevel; x1++)
                    {
                        if (x1 != subDivisionLevel)
                        {
                            lng = lngMin + (textureStep * tileDegrees * (double)x1);
                        }
                        else
                        {
                            lng = lngMax;
                        }
                        index = y1 * (subDivisionLevel + 1) + x1;
                        verts[index] = new PositionTexture();
                        verts[index].Position = (Vector3d)GeoTo3dWithAlt(lat, lng, false, true);// Add Altitude mapping here
                        verts[index].Tu = (x1 * textureStep)*Tile.uvMultiple;
                        verts[index].Tv = ((AbsoluteLatToMetersAtZoom(lat, Level) - (tileY * 256)) / 256f)*Tile.uvMultiple;
                        demIndex++;
                    }
                }
                if (tileY == 0)
                {
                    // Send the tops to the pole to fill in the Bing Hole
                    y1 = subDivisionLevel;
                    for (x1 = 0; x1 <= subDivisionLevel; x1++)
                    {
                        index = y1 * (subDivisionLevel + 1) + x1;
                        verts[index].Position = Vector3d.Create(0, 1, 0);

                    }
                }

                if (tileY == Math.Pow(2, Level) - 1)
                {
                    // Send the tops to the pole to fill in the Bing Hole
                    y1 = 0;
                    for (x1 = 0; x1 <= subDivisionLevel; x1++)
                    {
                        index = y1 * (subDivisionLevel + 1) + x1;
                        verts[index].Position = Vector3d.Create(0, -1, 0);

                    }
                }

                TriangleCount = (subDivisionLevel) * (subDivisionLevel) * 2;

                int quarterDivisions = subDivisionLevel / 2;
                int part = 0;

                if (renderContext.gl == null)
                {
                    for (int y2 = 0; y2 < 2; y2++)
                    {
                        for (int x2 = 0; x2 < 2; x2++)
                        {

                            index = 0;
                            for (y1 = (quarterDivisions * y2); y1 < (quarterDivisions * (y2 + 1)); y1++)
                            {
                                for (x1 = (quarterDivisions * x2); x1 < (quarterDivisions * (x2 + 1)); x1++)
                                {
                                    //index = ((y1 * quarterDivisions * 6) + 6 * x1);
                                    // First triangle in quad

                                    PositionTexture p1;
                                    PositionTexture p2;
                                    PositionTexture p3;

                                    p1 = verts[(y1 * (subDivisionLevel + 1) + x1)];
                                    p2 = verts[((y1 + 1) * (subDivisionLevel + 1) + x1)];
                                    p3 = verts[(y1 * (subDivisionLevel + 1) + (x1 + 1))];
                                    RenderTriangle tri = RenderTriangle.Create(p1, p2, p3, texture, Level);
                                    RenderTriangleLists[part].Add(tri);

                                    // Second triangle in quad
                                    p1 = verts[(y1 * (subDivisionLevel + 1) + (x1 + 1))];
                                    p2 = verts[((y1 + 1) * (subDivisionLevel + 1) + x1)];
                                    p3 = verts[((y1 + 1) * (subDivisionLevel + 1) + (x1 + 1))];
                                    tri = RenderTriangle.Create(p1, p2, p3, texture, Level);
                                    RenderTriangleLists[part].Add(tri);

                                }
                            }

                            part++;
                        }
                    }
                }
                else
                {
                    //process vertex list
                    VertexBuffer = PrepDevice.createBuffer();
                    PrepDevice.bindBuffer(GL.ARRAY_BUFFER, VertexBuffer);
                    Float32Array f32array = new Float32Array(verts.Length * 5);
                    float[] buffer = (float[])(object)f32array;
                    index = 0;
                    foreach (PositionTexture pt in verts)
                    {
                        index = AddVertex(buffer, index, pt);
                    }

                    PrepDevice.bufferData(GL.ARRAY_BUFFER, f32array, GL.STATIC_DRAW);

                    for (int y2 = 0; y2 < 2; y2++)
                    {
                        for (int x2 = 0; x2 < 2; x2++)
                        {
                            Uint16Array ui16array = new Uint16Array(TriangleCount * 3);

                            UInt16[] indexArray = (UInt16[])(object)ui16array;

                            index = 0;
                            for (y1 = (quarterDivisions * y2); y1 < (quarterDivisions * (y2 + 1)); y1++)
                            {
                                for (x1 = (quarterDivisions * x2); x1 < (quarterDivisions * (x2 + 1)); x1++)
                                {
                                    // First triangle in quad
                                    indexArray[index++] = (UInt16)((y1 * (subDivisionLevel + 1) + x1));
                                    indexArray[index++] = (UInt16)(((y1 + 1) * (subDivisionLevel + 1) + x1));
                                    indexArray[index++] = (UInt16)((y1 * (subDivisionLevel + 1) + (x1 + 1)));

                                    // Second triangle in quad
                                    indexArray[index++] = (UInt16)((y1 * (subDivisionLevel + 1) + (x1 + 1)));
                                    indexArray[index++] = (UInt16)(((y1 + 1) * (subDivisionLevel + 1) + x1));
                                    indexArray[index++] = (UInt16)(((y1 + 1) * (subDivisionLevel + 1) + (x1 + 1)));
                                }
                            }

                            IndexBuffers[part] = PrepDevice.createBuffer();
                            PrepDevice.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, IndexBuffers[part]);
                            PrepDevice.bufferData(GL.ELEMENT_ARRAY_BUFFER, ui16array, GL.STATIC_DRAW);

                            part++;
                        }
                    }
                }

            }
             //       catch
            {
            }

            return true;
        }
        public override bool CreateGeometry(RenderContext renderContext)
        {
            base.CreateGeometry(renderContext);
            if (renderContext.gl == null)
            {
                if (dataset.DataSetType == ImageSetType.Earth || dataset.DataSetType == ImageSetType.Planet)
                {
                    subDivisionLevel = Math.Max(2, (4 - Level) * 2);
                }
            }
            else
            {
                subDivisionLevel = 32;
            }

            try
            {
                for (int i = 0; i < 4; i++)
                {
                    RenderTriangleLists[i] = new List<RenderTriangle>();
                }

                if (!topDown)
                {
                    return CreateGeometryBottomsUp(renderContext);
                }
                double lat, lng;

                int index = 0;
                double tileDegrees = this.dataset.BaseTileDegrees / (Math.Pow(2, this.Level));

                double latMin = (90 - (((double)this.tileY) * tileDegrees));
                double latMax = (90 - (((double)(this.tileY + 1)) * tileDegrees));
                double lngMin = (((double)this.tileX * tileDegrees) - 180.0);
                double lngMax = ((((double)(this.tileX + 1)) * tileDegrees) - 180.0);
                double tileDegreesX = lngMax - lngMin;
                double tileDegreesY = latMax - latMin;

                TopLeft = (Vector3d)GeoTo3d(latMin, lngMin, false);
                BottomRight = (Vector3d)GeoTo3d(latMax, lngMax, false);
                TopRight = (Vector3d)GeoTo3d(latMin, lngMax, false);
                BottomLeft = (Vector3d)GeoTo3d(latMax, lngMin, false);

                // Create a vertex buffer
                PositionTexture[] verts = new PositionTexture[(subDivisionLevel + 1) * (subDivisionLevel + 1)]; // Lock the buffer (which will return our structs)
                int x, y;

                double textureStep = 1.0f / subDivisionLevel;
                for (y = 0; y <= subDivisionLevel; y++)
                {
                    if (y != subDivisionLevel)
                    {
                        lat = latMin + (textureStep * tileDegreesY * y);
                    }
                    else
                    {
                        lat = latMax;
                    }
                    for (x = 0; x <= subDivisionLevel; x++)
                    {

                        if (x != subDivisionLevel)
                        {
                            lng = lngMin + (textureStep * tileDegreesX * x);
                        }
                        else
                        {
                            lng = lngMax;
                        }
                        index = y * (subDivisionLevel + 1) + x;
                        verts[index] = PositionTexture.CreatePos(GeoTo3d(lat, lng, false), x * textureStep, y * textureStep);
                    }
                }
                TriangleCount = (subDivisionLevel) * (subDivisionLevel) * 2;

                int quarterDivisions = subDivisionLevel / 2;
                int part = 0;

                if (renderContext.gl == null)
                {
                    for (int y2 = 0; y2 < 2; y2++)
                    {
                        for (int x2 = 0; x2 < 2; x2++)
                        {
                            index = 0;
                            for (int y1 = (quarterDivisions * y2); y1 < (quarterDivisions * (y2 + 1)); y1++)
                            {
                                for (int x1 = (quarterDivisions * x2); x1 < (quarterDivisions * (x2 + 1)); x1++)
                                {
                                    //index = ((y1 * quarterDivisions * 6) + 6 * x1);
                                    // First triangle in quad

                                    PositionTexture p1;
                                    PositionTexture p2;
                                    PositionTexture p3;

                                    p1 = verts[(y1 * (subDivisionLevel + 1) + x1)];
                                    p2 = verts[((y1 + 1) * (subDivisionLevel + 1) + x1)];
                                    p3 = verts[(y1 * (subDivisionLevel + 1) + (x1 + 1))];
                                    RenderTriangleLists[part].Add(RenderTriangle.Create(p1, p3, p2, texture, Level));

                                    // Second triangle in quad
                                    p1 = verts[(y1 * (subDivisionLevel + 1) + (x1 + 1))];
                                    p2 = verts[((y1 + 1) * (subDivisionLevel + 1) + x1)];
                                    p3 = verts[((y1 + 1) * (subDivisionLevel + 1) + (x1 + 1))];
                                    RenderTriangleLists[part].Add(RenderTriangle.Create(p1, p3, p2, texture, Level));

                                }
                            }
                            part++;
                        }
                    }
                }
                else
                {
                    //process vertex list
                    VertexBuffer = PrepDevice.createBuffer();
                    PrepDevice.bindBuffer(GL.ARRAY_BUFFER, VertexBuffer);
                    Float32Array f32array = new Float32Array(verts.Length * 5);
                    float[] buffer = (float[])(object)f32array;
                    index = 0;
                    foreach (PositionTexture pt in verts)
                    {
                        index = AddVertex(buffer, index, pt);
                    }

                    PrepDevice.bufferData(GL.ARRAY_BUFFER, f32array, GL.STATIC_DRAW);
                    for (int y2 = 0; y2 < 2; y2++)
                    {
                        for (int x2 = 0; x2 < 2; x2++)
                        {
                            Uint16Array ui16array = new Uint16Array(TriangleCount * 3);

                            UInt16[] indexArray = (UInt16[])(object)ui16array;

                            index = 0;
                            for (int y1 = (quarterDivisions * y2); y1 < (quarterDivisions * (y2 + 1)); y1++)
                            {
                                for (int x1 = (quarterDivisions * x2); x1 < (quarterDivisions * (x2 + 1)); x1++)
                                {
                                    // First triangle in quad
                                    indexArray[index++] = (UInt16)((y1 * (subDivisionLevel + 1) + x1));
                                    indexArray[index++] = (UInt16)(((y1 + 1) * (subDivisionLevel + 1) + x1));
                                    indexArray[index++] = (UInt16)((y1 * (subDivisionLevel + 1) + (x1 + 1)));

                                    // Second triangle in quad
                                    indexArray[index++] = (UInt16)((y1 * (subDivisionLevel + 1) + (x1 + 1)));
                                    indexArray[index++] = (UInt16)(((y1 + 1) * (subDivisionLevel + 1) + x1));
                                    indexArray[index++] = (UInt16)(((y1 + 1) * (subDivisionLevel + 1) + (x1 + 1)));
                                }
                            }

                            IndexBuffers[part] = PrepDevice.createBuffer();
                            PrepDevice.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, IndexBuffers[part]);
                            PrepDevice.bufferData(GL.ELEMENT_ARRAY_BUFFER, ui16array, GL.STATIC_DRAW);

                            part++;
                        }
                    }
                }
            }
            catch
            {
            }
            return true;
        }