public void bufferData(int target, Uint16Array data, int usage) { return; }
private static UInt16[] CloneArray(UInt16[] indexArray) { int count = indexArray.Length; Uint16Array ui16array = new Uint16Array(count); UInt16[] indexArrayNew = (UInt16[])(object)ui16array; for (int i = 0; i < count; i++) { indexArrayNew[i] = indexArray[i]; } return indexArrayNew; }
public override bool CreateGeometry(RenderContext renderContext) { base.CreateGeometry(renderContext); if (GeometryCreated) { return true; } GeometryCreated = true; for (int i = 0; i < 4; i++) { RenderTriangleLists[i] = new List<RenderTriangle>(); } ComputeMatrix(); Height = texture.NaturalHeight; Width = texture.NaturalWidth; double latMin = 0 + (ScaleY * (Height - PixelCenterY)); double latMax = 0 - (ScaleY * PixelCenterY); double lngMin = 0 + (ScaleX * PixelCenterX); double lngMax = 0 - (ScaleX * (Width - PixelCenterX)); TopLeft = GeoTo3dTan(latMin, lngMin); BottomRight = GeoTo3dTan(latMax, lngMax); TopRight = GeoTo3dTan(latMin, lngMax); BottomLeft = GeoTo3dTan(latMax, lngMin); Vector3d topCenter = Vector3d.Lerp(TopLeft, TopRight, .5f); Vector3d bottomCenter = Vector3d.Lerp(BottomLeft, BottomRight, .5f); Vector3d center = Vector3d.Lerp(topCenter, bottomCenter, .5f); Vector3d rightCenter = Vector3d.Lerp(TopRight, BottomRight, .5f); Vector3d leftCenter = Vector3d.Lerp(TopLeft, BottomLeft, .5f); //Vector3d center = Vector3d.MidPoint(TopLeft, BottomRight); //Vector3d leftCenter = Vector3d.MidPoint(TopLeft, BottomLeft); //Vector3d rightCenter = Vector3d.MidPoint(TopRight, BottomRight); //Vector3d topCenter = Vector3d.MidPoint(TopLeft, TopRight); //Vector3d bottomCenter = Vector3d.MidPoint(BottomLeft, BottomRight); //verts[0].Position = TopLeft; //verts[0].Normal = TopLeft; //verts[0].Tu = 0; //verts[0].Tv = 0; //verts[1].Position = TopRight; //verts[1].Normal = TopRight; //verts[1].Tu = 1; //verts[1].Tv = 0; //verts[2].Position = BottomRight; //verts[2].Normal = BottomRight; //verts[2].Tu = 1; //verts[2].Tv = 1; //verts[3].Position = BottomLeft; //verts[3].Normal = BottomLeft; //verts[3].Tu = 0; //verts[3].Tv = 1; if (renderContext.gl == null) { //RenderTriangleLists[0].Add(RenderTriangle.Create(PositionTexture.CreatePosSize(TopLeft, 0, 0, Width, Height), PositionTexture.CreatePosSize(BottomLeft, 0, 1, Width, Height), PositionTexture.CreatePosSize(TopRight, 1, 0, Width, Height), texture, Level)); //RenderTriangleLists[0].Add(RenderTriangle.Create(PositionTexture.CreatePosSize(BottomLeft, 0, 1, Width, Height), PositionTexture.CreatePosSize(BottomRight, 1, 1, Width, Height), PositionTexture.CreatePosSize(TopRight, 1, 0, Width, Height), texture, Level)); vertexList = new List<PositionTexture>(); vertexList.Add(PositionTexture.CreatePosSize(TopLeft, 0, 0, Width, Height)); vertexList.Add(PositionTexture.CreatePosSize(TopRight, 1, 0, Width, Height)); vertexList.Add(PositionTexture.CreatePosSize(BottomLeft, 0, 1, Width, Height)); vertexList.Add(PositionTexture.CreatePosSize(BottomRight, 1, 1, Width, Height)); childTriangleList = new List<Triangle>(); if (dataset.BottomsUp) { childTriangleList.Add(Triangle.Create(0, 1, 2)); childTriangleList.Add(Triangle.Create(2, 1, 3)); } else { childTriangleList.Add(Triangle.Create(0, 2, 1)); childTriangleList.Add(Triangle.Create(2, 3, 1)); } int count = 3; while (count-- > 1) { List<Triangle> newList = new List<Triangle>(); foreach (Triangle tri in childTriangleList) { tri.SubDivide(newList, vertexList); } childTriangleList = newList; } double miter = .6 / (Width/256); foreach (Triangle tri in childTriangleList) { PositionTexture p1 = vertexList[tri.A]; PositionTexture p2 = vertexList[tri.B]; PositionTexture p3 = vertexList[tri.C]; RenderTriangleLists[0].Add(RenderTriangle.CreateWithMiter(p1, p2, p3, texture, Level, miter)); } } else { //process vertex list VertexBuffer = PrepDevice.createBuffer(); PrepDevice.bindBuffer(GL.ARRAY_BUFFER, VertexBuffer); Float32Array f32array = new Float32Array(9 * 5); float[] buffer = (float[])(object)f32array; int index = 0; index = AddVertex(buffer, index, PositionTexture.CreatePos(bottomCenter, .5, 1)); //0 index = AddVertex(buffer, index, PositionTexture.CreatePos(BottomLeft, 0, 1)); //1 index = AddVertex(buffer, index, PositionTexture.CreatePos(BottomRight, 1, 1)); //2 index = AddVertex(buffer, index, PositionTexture.CreatePos(center, .5, .5)); //3 index = AddVertex(buffer, index, PositionTexture.CreatePos(leftCenter, 0, .5)); //4 index = AddVertex(buffer, index, PositionTexture.CreatePos(rightCenter, 1, .5)); //5 index = AddVertex(buffer, index, PositionTexture.CreatePos(topCenter, .5, 0)); //6 index = AddVertex(buffer, index, PositionTexture.CreatePos(TopLeft, 0, 0)); //7 index = AddVertex(buffer, index, PositionTexture.CreatePos(TopRight, 1, 0)); //8 PrepDevice.bufferData(GL.ARRAY_BUFFER, f32array, GL.STATIC_DRAW); // process index buffers for (int i = 0; i < 4; i++) { index = 0; TriangleCount = 2; Uint16Array ui16array = new Uint16Array(TriangleCount * 3); UInt16[] indexArray = (UInt16[])(object)ui16array; switch (i) { case 0: indexArray[index++] = 7; indexArray[index++] = 4; indexArray[index++] = 6; indexArray[index++] = 4; indexArray[index++] = 3; indexArray[index++] = 6; break; case 1: indexArray[index++] = 6; indexArray[index++] = 5; indexArray[index++] = 8; indexArray[index++] = 6; indexArray[index++] = 3; indexArray[index++] = 5; break; case 2: indexArray[index++] = 4; indexArray[index++] = 0; indexArray[index++] = 3; indexArray[index++] = 4; indexArray[index++] = 1; indexArray[index++] = 0; break; case 3: indexArray[index++] = 3; indexArray[index++] = 2; indexArray[index++] = 5; indexArray[index++] = 3; indexArray[index++] = 0; indexArray[index++] = 2; break; } IndexBuffers[i] = PrepDevice.createBuffer(); PrepDevice.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, IndexBuffers[i]); PrepDevice.bufferData(GL.ELEMENT_ARRAY_BUFFER, ui16array, GL.STATIC_DRAW); } } return true; }
public override bool CreateGeometry(RenderContext renderContext) { if (GeometryCreated) { return true; } GeometryCreated = true; base.CreateGeometry(renderContext); if (!subDivided) { if (vertexList == null) { InitializeGrids(); } if (uvMultiple == 256) { if (dataset.DataSetType == ImageSetType.Earth || dataset.DataSetType == ImageSetType.Planet) { subDivisionLevel = Math.Min(5, Math.Max(0, 5 - Level)); } else { subDivisionLevel = Math.Min(5, Math.Max(0, 5 - Level)); } } else { if (demTile && Level > 1) { demArray = new float[17 * 17]; demSize = 17 * 17; if (backslash) { if (backslashYIndex == null) { tempBackslashYIndex = new byte[demSize]; tempBackslashXIndex = new byte[demSize]; } } else { if (slashYIndex == null) { tempSlashYIndex = new byte[demSize]; tempSlashXIndex = new byte[demSize]; } } } } for (int i = 0; i < 4; i++) { int count = subDivisionLevel; while (count-- > 1) { List<Triangle> newList = new List<Triangle>(); foreach (Triangle tri in childTriangleList[i]) { tri.SubDivide(newList, vertexList); } childTriangleList[i] = newList; } } if (renderContext.gl == null) { for (int i = 0; i < 4; i++) { RenderTriangleLists[i] = new List<RenderTriangle>(); foreach (Triangle tri in childTriangleList[i]) { PositionTexture p1 = vertexList[tri.C]; PositionTexture p2 = vertexList[tri.B]; PositionTexture p3 = vertexList[tri.A]; RenderTriangleLists[i].Add(RenderTriangle.Create(p1, p2, p3, texture, Level)); } } } else { //process vertex list VertexBuffer = PrepDevice.createBuffer(); PrepDevice.bindBuffer(GL.ARRAY_BUFFER, VertexBuffer); Float32Array f32array = new Float32Array(vertexList.Count * 5); float[] buffer = (float[])(object)f32array; int index = 0; foreach (PositionTexture pt in vertexList) { if (demTile) { index = AddVertex(buffer, index, GetMappedVertex(pt)); demIndex++; } else { index = AddVertex(buffer, index, pt); } } if (demTile) { if (backslash) { if (tempBackslashXIndex != null) { backslashXIndex = tempBackslashXIndex; backslashYIndex = tempBackslashYIndex; tempBackslashXIndex = null; tempBackslashYIndex = null; } } else { if (tempSlashYIndex != null) { slashXIndex = tempSlashXIndex; slashYIndex = tempSlashYIndex; tempSlashYIndex = null; tempSlashXIndex = null; } } } PrepDevice.bufferData(GL.ARRAY_BUFFER, f32array, GL.STATIC_DRAW); //process index list for (int i = 0; i < 4; i++) { TriangleCount = childTriangleList[i].Count; if (GetIndexBuffer(i, 0) == null) { Uint16Array ui16array = new Uint16Array(TriangleCount * 3); UInt16[] indexArray = (UInt16[])(object)ui16array; index = 0; foreach (Triangle tri in childTriangleList[i]) { indexArray[index++] = (UInt16)tri.C; indexArray[index++] = (UInt16)tri.B; indexArray[index++] = (UInt16)tri.A; } ProcessIndexBuffer(indexArray, i); } //IndexBuffers[i] = PrepDevice.createBuffer(); //PrepDevice.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, IndexBuffers[i]); //PrepDevice.bufferData(GL.ELEMENT_ARRAY_BUFFER, ui16array, GL.STATIC_DRAW); } } subDivided = true; } return true; }
public extern Uint16Array(Uint16Array array);
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; }
public override bool CreateGeometry(RenderContext renderContext) { base.CreateGeometry(renderContext); if (GeometryCreated) { return true; } GeometryCreated = true; for (int i = 0; i < 4; i++) { RenderTriangleLists[i] = new List<RenderTriangle>(); } double tileDegrees = this.dataset.BaseTileDegrees / (Math.Pow(2, this.Level)); double latMin = (((double)this.dataset.BaseTileDegrees / 2.0 - (((double)this.tileY) * tileDegrees)) + this.dataset.OffsetY); double latMax = (((double)this.dataset.BaseTileDegrees / 2.0 - (((double)(this.tileY + 1)) * tileDegrees)) + this.dataset.OffsetY); double lngMin = ((((double)this.tileX * tileDegrees) - (double)this.dataset.BaseTileDegrees / dataset.WidthFactor) + this.dataset.OffsetX); double lngMax = (((((double)(this.tileX + 1)) * tileDegrees) - (double)this.dataset.BaseTileDegrees / dataset.WidthFactor) + this.dataset.OffsetX); double tileDegreesX = lngMax - lngMin; double tileDegreesY = latMax - latMin; TopLeft = GeoTo3dTan(latMin, lngMin); BottomRight = GeoTo3dTan(latMax, lngMax); TopRight = GeoTo3dTan(latMin, lngMax); BottomLeft = GeoTo3dTan(latMax, lngMin); double latCenter = (latMin + latMax) / 2.0; double lngCenter = (lngMin + lngMax) / 2.0; Vector3d center = Vector3d.MidPoint(TopLeft, BottomRight); Vector3d leftCenter = Vector3d.MidPoint(TopLeft, BottomLeft); Vector3d rightCenter = Vector3d.MidPoint(TopRight, BottomRight); Vector3d topCenter = Vector3d.MidPoint(TopLeft, TopRight); Vector3d bottomCenter = Vector3d.MidPoint(BottomLeft, BottomRight); if (renderContext.gl == null) { RenderTriangleLists[0].Add(RenderTriangle.Create(PositionTexture.CreatePos(TopLeft, 0, 0), PositionTexture.CreatePos(leftCenter, 0, .5), PositionTexture.CreatePos(topCenter, .5, 0), texture, Level)); RenderTriangleLists[0].Add(RenderTriangle.Create(PositionTexture.CreatePos(leftCenter, 0, 0.5), PositionTexture.CreatePos(center, .5, .5), PositionTexture.CreatePos(topCenter, .5, 0), texture, Level)); RenderTriangleLists[1].Add(RenderTriangle.Create(PositionTexture.CreatePos(topCenter, .5, 0), PositionTexture.CreatePos(rightCenter, 1, .5), PositionTexture.CreatePos(TopRight, 1, 0), texture, Level)); RenderTriangleLists[1].Add(RenderTriangle.Create(PositionTexture.CreatePos(topCenter, .5, 0), PositionTexture.CreatePos(center, .5, .5), PositionTexture.CreatePos(rightCenter, 1, .5), texture, Level)); RenderTriangleLists[2].Add(RenderTriangle.Create(PositionTexture.CreatePos(leftCenter, 0, .5), PositionTexture.CreatePos(bottomCenter, .5, 1), PositionTexture.CreatePos(center, .5, .5), texture, Level)); RenderTriangleLists[2].Add(RenderTriangle.Create(PositionTexture.CreatePos(leftCenter, 0, .5), PositionTexture.CreatePos(BottomLeft, 0, 1), PositionTexture.CreatePos(bottomCenter, .5, 1), texture, Level)); RenderTriangleLists[3].Add(RenderTriangle.Create(PositionTexture.CreatePos(center, .5, .5), PositionTexture.CreatePos(BottomRight, 1, 1), PositionTexture.CreatePos(rightCenter, 1, .5), texture, Level)); RenderTriangleLists[3].Add(RenderTriangle.Create(PositionTexture.CreatePos(center, .5, .5), PositionTexture.CreatePos(bottomCenter, .5, 1), PositionTexture.CreatePos(BottomRight, 1, 1), texture, Level)); } else { //process vertex list VertexBuffer = PrepDevice.createBuffer(); PrepDevice.bindBuffer(GL.ARRAY_BUFFER, VertexBuffer); Float32Array f32array = new Float32Array(9 * 5); float[] buffer = (float[])(object)f32array; int index = 0; index = AddVertex(buffer, index, PositionTexture.CreatePos(bottomCenter, .5, 1)); //0 index = AddVertex(buffer, index, PositionTexture.CreatePos(BottomLeft, 0, 1)); //1 index = AddVertex(buffer, index, PositionTexture.CreatePos(BottomRight, 1, 1)); //2 index = AddVertex(buffer, index, PositionTexture.CreatePos(center, .5, .5)); //3 index = AddVertex(buffer, index, PositionTexture.CreatePos(leftCenter, 0, .5)); //4 index = AddVertex(buffer, index, PositionTexture.CreatePos(rightCenter, 1, .5)); //5 index = AddVertex(buffer, index, PositionTexture.CreatePos(topCenter, .5, 0)); //6 index = AddVertex(buffer, index, PositionTexture.CreatePos(TopLeft, 0, 0)); //7 index = AddVertex(buffer, index, PositionTexture.CreatePos(TopRight, 1, 0)); //8 PrepDevice.bufferData(GL.ARRAY_BUFFER, f32array, GL.STATIC_DRAW); // process index buffers for (int i = 0; i < 4; i++) { index = 0; TriangleCount = 2; Uint16Array ui16array = new Uint16Array(TriangleCount * 3); UInt16[] indexArray = (UInt16[])(object)ui16array; switch (i) { case 0: indexArray[index++] = 7; indexArray[index++] = 4; indexArray[index++] = 6; indexArray[index++] = 4; indexArray[index++] = 3; indexArray[index++] = 6; break; case 1: indexArray[index++] = 6; indexArray[index++] = 5; indexArray[index++] = 8; indexArray[index++] = 6; indexArray[index++] = 3; indexArray[index++] = 5; break; case 2: indexArray[index++] = 4; indexArray[index++] = 0; indexArray[index++] = 3; indexArray[index++] = 4; indexArray[index++] = 1; indexArray[index++] = 0; break; case 3: indexArray[index++] = 3; indexArray[index++] = 2; indexArray[index++] = 5; indexArray[index++] = 3; indexArray[index++] = 0; indexArray[index++] = 2; break; } IndexBuffers[i] = PrepDevice.createBuffer(); PrepDevice.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, IndexBuffers[i]); PrepDevice.bufferData(GL.ELEMENT_ARRAY_BUFFER, ui16array, GL.STATIC_DRAW); } } return true; }