Ejemplo n.º 1
0
        void InitLineBuffer()
        {
            if (lineBuffers.Count == 0)
            {
                int count = linePoints.Count;

                PositionVertexBuffer11 lineBuffer = null;


                SharpDX.Vector3[] linePointList = null;
                localCenter = new Vector3d();
                if (DepthBuffered)
                {
                    // compute the local center..
                    foreach (Vector3d point in linePoints)
                    {
                        localCenter.Add(point);
                    }
                    localCenter.X /= count;
                    localCenter.Y /= count;
                    localCenter.Z /= count;
                }

                int      countLeft = count;
                int      index     = 0;
                int      counter   = 0;
                Vector3d temp;

                foreach (Vector3d point in linePoints)
                {
                    if (counter >= 100000 || linePointList == null)
                    {
                        if (lineBuffer != null)
                        {
                            lineBuffer.Unlock();
                        }
                        int thisCount = Math.Min(100000, countLeft);

                        countLeft -= thisCount;
                        lineBuffer = new PositionVertexBuffer11(thisCount, RenderContext11.PrepDevice);

                        linePointList = (SharpDX.Vector3[])lineBuffer.Lock(0, 0); // Lock the buffer (which will return our structs)

                        lineBuffers.Add(lineBuffer);
                        lineBufferCounts.Add(thisCount);
                        counter = 0;
                    }


                    temp = point - localCenter;
                    linePointList[counter] = temp.Vector311;
                    index++;
                    counter++;
                }

                lineBuffer.Unlock();
            }
        }
Ejemplo n.º 2
0
        public static PositionVertexBuffer11 CreateEllipseVertexBufferWithoutStartPoint(int vertexCount)
        {
            PositionVertexBuffer11 vb = new PositionVertexBuffer11(vertexCount, RenderContext11.PrepDevice);
            SharpDX.Vector3[] verts = (SharpDX.Vector3[])vb.Lock(0, 0);

            // Setting a non-zero value will prevent the ellipse shader from using the 'head' point
            verts[0] = new SharpDX.Vector3(1.0e-6f, 0.0f, 0.0f);

            for (int i = 1; i < vertexCount; ++i)
            {
                verts[i] = new SharpDX.Vector3(2.0f * (float)i / (float)vertexCount, 0.0f, 0.0f);
            }

            vb.Unlock();

            return vb;
        }
Ejemplo n.º 3
0
        public static PositionVertexBuffer11 CreateEllipseVertexBufferWithoutStartPoint(int vertexCount)
        {
            PositionVertexBuffer11 vb = new PositionVertexBuffer11(vertexCount, RenderContext11.PrepDevice);

            SharpDX.Vector3[] verts = (SharpDX.Vector3[])vb.Lock(0, 0);

            // Setting a non-zero value will prevent the ellipse shader from using the 'head' point
            verts[0] = new SharpDX.Vector3(1.0e-6f, 0.0f, 0.0f);

            for (int i = 1; i < vertexCount; ++i)
            {
                verts[i] = new SharpDX.Vector3(2.0f * (float)i / (float)vertexCount, 0.0f, 0.0f);
            }

            vb.Unlock();

            return(vb);
        }
Ejemplo n.º 4
0
        public static PositionVertexBuffer11 CreateEllipseVertexBuffer(int vertexCount)
        {
            PositionVertexBuffer11 vb = new PositionVertexBuffer11( vertexCount,RenderContext11.PrepDevice);
            SharpDX.Vector3[] verts = (SharpDX.Vector3[])vb.Lock(0,0);
            int index = 0;
            // Pack extra samples into the front of the orbit to avoid obvious segmentation
            // when viewed from near the planet or moon.
            for (int i = 0; i < vertexCount / 2; ++i)
            {
                verts[index++] = new SharpDX.Vector3(2.0f * (float)i / (float)vertexCount * 0.05f, 0.0f, 0.0f);
            }
            for (int i = 0; i < vertexCount / 2; ++i)
            {
                verts[index++] = new SharpDX.Vector3(2.0f * (float)i / (float)vertexCount * 0.95f + 0.05f, 0.0f, 0.0f);
            }

            vb.Unlock();

            return vb;
        }
Ejemplo n.º 5
0
        public static PositionVertexBuffer11 CreateEllipseVertexBuffer(int vertexCount)
        {
            PositionVertexBuffer11 vb = new PositionVertexBuffer11(vertexCount, RenderContext11.PrepDevice);

            SharpDX.Vector3[] verts = (SharpDX.Vector3[])vb.Lock(0, 0);
            int index = 0;

            // Pack extra samples into the front of the orbit to avoid obvious segmentation
            // when viewed from near the planet or moon.
            for (int i = 0; i < vertexCount / 2; ++i)
            {
                verts[index++] = new SharpDX.Vector3(2.0f * (float)i / (float)vertexCount * 0.05f, 0.0f, 0.0f);
            }
            for (int i = 0; i < vertexCount / 2; ++i)
            {
                verts[index++] = new SharpDX.Vector3(2.0f * (float)i / (float)vertexCount * 0.95f + 0.05f, 0.0f, 0.0f);
            }

            vb.Unlock();


            return(vb);
        }
        public override bool Draw(RenderContext11 renderContext, float opacity, bool flat)
        {
            if (shapefile == null)
            {
                return false;
            }

            if (shapeFileVertex == null)
            {

                var vertList = new List<Vector3>();
                var indexList = new List<UInt32>();
                UInt32 firstItemIndex = 0;
                var lastItem = new Vector3();
                var firstItem = true;

                var north = true;
                double offsetX = 0;
                double offsetY = 0;
                double centralMeridian = 0;
                double mapScale = 0;
                double standardParallel = 70;

                if (shapefile.Projection == ShapeFile.Projections.PolarStereo)
                {
                    north = shapefile.FileHeader.ProjectionInfo.Name.ToLower().Contains("north");
                    standardParallel = shapefile.FileHeader.ProjectionInfo.GetParameter("standard_parallel_1");
                    centralMeridian = shapefile.FileHeader.ProjectionInfo.GetParameter("central_meridian");
                    mapScale = shapefile.FileHeader.ProjectionInfo.GetParameter("scale_factor");
                    offsetY = shapefile.FileHeader.ProjectionInfo.GetParameter("false_easting");
                    offsetX = shapefile.FileHeader.ProjectionInfo.GetParameter("false_northing");

                }

                UInt32 currentIndex = 0;
                var color = Color;
                var count = 360;
                for (var i = 0; i < shapefile.Shapes.Count; i++)
                {
                    if (shapefile.Shapes[i].GetType() == typeof(Polygon))
                    {
                        var p = (Polygon)shapefile.Shapes[i];

                        for (var z = 0; z < p.Rings.Length; z++)
                        {
                            count = (p.Rings[z].Points.Length);

                            // content from DBF
                            var dr = p.Rings[z].Attributes;

                            for (var k = 0; k < p.Rings[z].Points.Length; k++)
                            {
                                // 2D Point coordinates. 3d also supported which would add a Z. There's also an optional measure (M) that can be used.
                                var Xcoord = p.Rings[z].Points[k].X;
                                var Ycoord = p.Rings[z].Points[k].Y;

                                if (shapefile.Projection == ShapeFile.Projections.Geo)
                                {
                                    lastItem = Coordinates.GeoTo3d(Ycoord, Xcoord);
                                }
                                else if (shapefile.Projection == ShapeFile.Projections.PolarStereo)
                                {
                                    lastItem = Coordinates.SterographicTo3d(Xcoord, Ycoord, 1, standardParallel, centralMeridian, offsetX, offsetY, mapScale, north).Vector3;
                                }

                                if (k == 0)
                                {
                                    firstItemIndex = currentIndex;
                                    firstItem = true;
                                }

                                vertList.Add(lastItem);

                                if (firstItem)
                                {
                                    firstItem = false;
                                }
                                else
                                {
                                    indexList.Add(currentIndex);
                                    currentIndex++;
                                    indexList.Add(currentIndex);
                                }
                            }

                            indexList.Add(currentIndex);
                            indexList.Add(firstItemIndex);
                            currentIndex++;

                        }
                    }
                    else if (shapefile.Shapes[i].GetType() == typeof(PolygonZ))
                    {
                        var p = (PolygonZ)shapefile.Shapes[i];

                        for (var z = 0; z < p.Rings.Length; z++)
                        {
                            count = (p.Rings[z].Points.Length);

                            // content from DBF
                            var dr = p.Rings[z].Attributes;

                            for (var k = 0; k < p.Rings[z].Points.Length; k++)
                            {
                                // 2D Point coordinates. 3d also supported which would add a Z. There's also an optional measure (M) that can be used.
                                var Xcoord = p.Rings[z].Points[k].X;
                                var Ycoord = p.Rings[z].Points[k].Y;

                                if (shapefile.Projection == ShapeFile.Projections.Geo)
                                {
                                    lastItem = Coordinates.GeoTo3d(Ycoord, Xcoord);
                                }
                                else if (shapefile.Projection == ShapeFile.Projections.PolarStereo)
                                {
                                    lastItem = Coordinates.SterographicTo3d(Xcoord, Ycoord, 1, standardParallel, centralMeridian, offsetX, offsetY, mapScale, north).Vector3;
                                }

                                if (k == 0)
                                {
                                    firstItemIndex = currentIndex;
                                    firstItem = true;
                                }

                                vertList.Add(lastItem);

                                if (firstItem)
                                {
                                    firstItem = false;
                                }
                                else
                                {
                                    indexList.Add(currentIndex);
                                    currentIndex++;
                                    indexList.Add(currentIndex);
                                }
                            }

                            indexList.Add(currentIndex);
                            indexList.Add(firstItemIndex);
                            currentIndex++;

                        }
                    }
                    else if (shapefile.Shapes[i].GetType() == typeof(PolyLine))
                    {
                        var p = (PolyLine)shapefile.Shapes[i];
                        for (var z = 0; z < p.Lines.Length; z++)
                        {
                            count = (p.Lines[z].Points.Length);

                            firstItem = true;
                            for (var k = 0; k < p.Lines[z].Points.Length; k++)
                            {
                                // 2D Point coordinates. 3d also supported which would add a Z. There's also an optional measure (M) that can be used.
                                var Xcoord = p.Lines[z].Points[k].X;
                                var Ycoord = p.Lines[z].Points[k].Y;
                                if (shapefile.Projection == ShapeFile.Projections.Geo)
                                {
                                    lastItem = Coordinates.GeoTo3d(Ycoord, Xcoord);
                                }
                                else if (shapefile.Projection == ShapeFile.Projections.PolarStereo)
                                {
                                    lastItem = Coordinates.SterographicTo3d(Xcoord, Ycoord, 1, standardParallel, centralMeridian, offsetX, offsetY, mapScale, north).Vector3;
                                }

                                if (k == 0)
                                {
                                    firstItemIndex = currentIndex;
                                    firstItem = true;
                                }

                                vertList.Add(lastItem);

                                if (firstItem)
                                {
                                    firstItem = false;
                                }
                                else
                                {
                                    indexList.Add(currentIndex);
                                    currentIndex++;
                                    indexList.Add(currentIndex);
                                }

                            }
                            currentIndex++;

                        }
                    }
                    else if (shapefile.Shapes[i].GetType() == typeof(PolyLineZ))
                    {
                        var p = (PolyLineZ)shapefile.Shapes[i];
                        for (var z = 0; z < p.Lines.Length; z++)
                        {
                            count = (p.Lines[z].Points.Length);
                            var points = new Vector3[(count)];

                            firstItem = true;
                            for (var k = 0; k < p.Lines[z].Points.Length; k++)
                            {
                                // 2D Point coordinates. 3d also supported which would add a Z. There's also an optional measure (M) that can be used.
                                var Xcoord = p.Lines[z].Points[k].X;
                                var Ycoord = p.Lines[z].Points[k].Y;
                                if (shapefile.Projection == ShapeFile.Projections.Geo)
                                {
                                    lastItem = Coordinates.GeoTo3d(Ycoord, Xcoord);
                                }
                                else if (shapefile.Projection == ShapeFile.Projections.PolarStereo)
                                {
                                    lastItem = Coordinates.SterographicTo3d(Xcoord, Ycoord, 1, standardParallel, centralMeridian, offsetX, offsetY, mapScale, north).Vector3;
                                }

                                if (k == 0)
                                {
                                    firstItemIndex = currentIndex;
                                    firstItem = true;
                                }

                                vertList.Add(lastItem);

                                if (firstItem)
                                {
                                    firstItem = false;
                                }
                                else
                                {
                                    indexList.Add(currentIndex);
                                    currentIndex++;
                                    indexList.Add(currentIndex);
                                }

                            }
                            currentIndex++;

                        }
                    }
                    else if (shapefile.Shapes[i].GetType() == typeof(Point))
                    {
                        var p = (Point)shapefile.Shapes[i];

                        // 2D Point coordinates. 3d also supported which would add a Z. There's also an optional measure (M) that can be used.
                        var Xcoord = p.X;
                        var Ycoord = p.Y;
                        if (shapefile.Projection == ShapeFile.Projections.Geo)
                        {
                            lastItem = Coordinates.GeoTo3d(Ycoord, Xcoord);
                        }
                        else if (shapefile.Projection == ShapeFile.Projections.PolarStereo)
                        {
                            lastItem = Coordinates.SterographicTo3d(Xcoord, Ycoord, 1, standardParallel, centralMeridian, offsetX, offsetY, mapScale, north).Vector3;
                        }

                        vertList.Add(lastItem);

                        currentIndex++;
                        lines = false;
                    }

                }

                shapeVertexCount = vertList.Count;
                shapeFileVertex = new PositionVertexBuffer11(vertList.Count, RenderContext11.PrepDevice);

                var verts = (Vector3[])shapeFileVertex.Lock(0, 0); // Lock the buffer (which will return our structs)
                var indexer = 0;
                foreach (var vert in vertList)
                {
                    verts[indexer++] = vert;
                }
                shapeFileVertex.Unlock();

                shapeIndexCount = indexList.Count;

                if (lines)
                {
                    if (indexList.Count > 65500)
                    {
                        isLongIndex = true;
                        shapeFileIndex = new IndexBuffer11(typeof(UInt32), indexList.Count, RenderContext11.PrepDevice);
                    }
                    else
                    {
                        isLongIndex = false;
                        shapeFileIndex = new IndexBuffer11(typeof(short), indexList.Count, RenderContext11.PrepDevice);
                    }

                    if (isLongIndex)
                    {
                        indexer = 0;
                        var indexes = (UInt32[])shapeFileIndex.Lock();
                        foreach (var indexVal in indexList)
                        {
                            indexes[indexer++] = indexVal;
                        }
                        shapeFileIndex.Unlock();
                    }
                    else
                    {
                        indexer = 0;
                        var indexes = (short[])shapeFileIndex.Lock();
                        foreach (var indexVal in indexList)
                        {
                            indexes[indexer++] = (short)indexVal;
                        }
                        shapeFileIndex.Unlock();
                    }
                }
            }

            renderContext.DepthStencilMode = DepthStencilMode.Off;
            renderContext.BlendMode = BlendMode.Alpha;
            SimpleLineShader11.Color = Color.FromArgb((int)(opacity * 255), Color);

            var mat = (renderContext.World * renderContext.View * renderContext.Projection).Matrix11;
            mat.Transpose();

            SimpleLineShader11.WVPMatrix = mat;
            SimpleLineShader11.CameraPosition = Vector3d.TransformCoordinate(renderContext.CameraPosition, Matrix3d.Invert(renderContext.World)).Vector3;
            SimpleLineShader11.ShowFarSide = false;
            SimpleLineShader11.Sky = false;

            renderContext.SetVertexBuffer(shapeFileVertex);
            SimpleLineShader11.Use(renderContext.devContext);

            if (lines)
            {
                renderContext.devContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.LineList;
                renderContext.SetIndexBuffer(shapeFileIndex);
                renderContext.devContext.DrawIndexed(shapeFileIndex.Count, 0, 0);
            }
            else
            {
                renderContext.devContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.PointList;
                renderContext.devContext.Draw(shapeVertexCount, 0);
            }

            renderContext.devContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;

            return true;
        }
        public override bool Draw(RenderContext11 renderContext, float opacity, bool flat)
        {
            if (shapefile == null)
            {
                return(false);
            }

            if (shapeFileVertex == null)
            {
                List <Vector3> vertList       = new List <Vector3>();
                List <UInt32>  indexList      = new List <UInt32>();
                UInt32         firstItemIndex = 0;
                Vector3        lastItem       = new Vector3();
                bool           firstItem      = true;



                bool   north            = true;
                double offsetX          = 0;
                double offsetY          = 0;
                double centralMeridian  = 0;
                double mapScale         = 0;
                double standardParallel = 70;

                if (shapefile.Projection == ShapeFile.Projections.PolarStereo)
                {
                    north            = shapefile.FileHeader.ProjectionInfo.Name.ToLower().Contains("north");
                    standardParallel = shapefile.FileHeader.ProjectionInfo.GetParameter("standard_parallel_1");
                    centralMeridian  = shapefile.FileHeader.ProjectionInfo.GetParameter("central_meridian");
                    mapScale         = shapefile.FileHeader.ProjectionInfo.GetParameter("scale_factor");
                    offsetY          = shapefile.FileHeader.ProjectionInfo.GetParameter("false_easting");
                    offsetX          = shapefile.FileHeader.ProjectionInfo.GetParameter("false_northing");
                }



                UInt32 currentIndex = 0;
                Color  color        = Color;
                int    count        = 360;
                for (int i = 0; i < shapefile.Shapes.Count; i++)
                {
                    if (shapefile.Shapes[i].GetType() == typeof(Polygon))
                    {
                        Polygon p = (Polygon)shapefile.Shapes[i];

                        for (int z = 0; z < p.Rings.Length; z++)
                        {
                            count = (p.Rings[z].Points.Length);

                            // content from DBF
                            DataRow dr = p.Rings[z].Attributes;

                            for (int k = 0; k < p.Rings[z].Points.Length; k++)
                            {
                                // 2D Point coordinates. 3d also supported which would add a Z. There's also an optional measure (M) that can be used.
                                double Xcoord = p.Rings[z].Points[k].X;
                                double Ycoord = p.Rings[z].Points[k].Y;

                                if (shapefile.Projection == ShapeFile.Projections.Geo)
                                {
                                    lastItem = Coordinates.GeoTo3d(Ycoord, Xcoord);
                                }
                                else if (shapefile.Projection == ShapeFile.Projections.PolarStereo)
                                {
                                    lastItem = Coordinates.SterographicTo3d(Xcoord, Ycoord, 1, standardParallel, centralMeridian, offsetX, offsetY, mapScale, north).Vector3;
                                }

                                if (k == 0)
                                {
                                    firstItemIndex = currentIndex;
                                    firstItem      = true;
                                }

                                vertList.Add(lastItem);

                                if (firstItem)
                                {
                                    firstItem = false;
                                }
                                else
                                {
                                    indexList.Add(currentIndex);
                                    currentIndex++;
                                    indexList.Add(currentIndex);
                                }
                            }

                            indexList.Add(currentIndex);
                            indexList.Add(firstItemIndex);
                            currentIndex++;
                        }
                    }
                    else if (shapefile.Shapes[i].GetType() == typeof(PolygonZ))
                    {
                        PolygonZ p = (PolygonZ)shapefile.Shapes[i];

                        for (int z = 0; z < p.Rings.Length; z++)
                        {
                            count = (p.Rings[z].Points.Length);

                            // content from DBF
                            DataRow dr = p.Rings[z].Attributes;

                            for (int k = 0; k < p.Rings[z].Points.Length; k++)
                            {
                                // 2D Point coordinates. 3d also supported which would add a Z. There's also an optional measure (M) that can be used.
                                double Xcoord = p.Rings[z].Points[k].X;
                                double Ycoord = p.Rings[z].Points[k].Y;

                                if (shapefile.Projection == ShapeFile.Projections.Geo)
                                {
                                    lastItem = Coordinates.GeoTo3d(Ycoord, Xcoord);
                                }
                                else if (shapefile.Projection == ShapeFile.Projections.PolarStereo)
                                {
                                    lastItem = Coordinates.SterographicTo3d(Xcoord, Ycoord, 1, standardParallel, centralMeridian, offsetX, offsetY, mapScale, north).Vector3;
                                }


                                if (k == 0)
                                {
                                    firstItemIndex = currentIndex;
                                    firstItem      = true;
                                }

                                vertList.Add(lastItem);

                                if (firstItem)
                                {
                                    firstItem = false;
                                }
                                else
                                {
                                    indexList.Add(currentIndex);
                                    currentIndex++;
                                    indexList.Add(currentIndex);
                                }
                            }

                            indexList.Add(currentIndex);
                            indexList.Add(firstItemIndex);
                            currentIndex++;
                        }
                    }
                    else if (shapefile.Shapes[i].GetType() == typeof(PolyLine))
                    {
                        PolyLine p = (PolyLine)shapefile.Shapes[i];
                        for (int z = 0; z < p.Lines.Length; z++)
                        {
                            count = (p.Lines[z].Points.Length);

                            firstItem = true;
                            for (int k = 0; k < p.Lines[z].Points.Length; k++)
                            {
                                // 2D Point coordinates. 3d also supported which would add a Z. There's also an optional measure (M) that can be used.
                                double Xcoord = p.Lines[z].Points[k].X;
                                double Ycoord = p.Lines[z].Points[k].Y;
                                if (shapefile.Projection == ShapeFile.Projections.Geo)
                                {
                                    lastItem = Coordinates.GeoTo3d(Ycoord, Xcoord);
                                }
                                else if (shapefile.Projection == ShapeFile.Projections.PolarStereo)
                                {
                                    lastItem = Coordinates.SterographicTo3d(Xcoord, Ycoord, 1, standardParallel, centralMeridian, offsetX, offsetY, mapScale, north).Vector3;
                                }

                                if (k == 0)
                                {
                                    firstItemIndex = currentIndex;
                                    firstItem      = true;
                                }

                                vertList.Add(lastItem);

                                if (firstItem)
                                {
                                    firstItem = false;
                                }
                                else
                                {
                                    indexList.Add(currentIndex);
                                    currentIndex++;
                                    indexList.Add(currentIndex);
                                }
                            }
                            currentIndex++;
                        }
                    }
                    else if (shapefile.Shapes[i].GetType() == typeof(PolyLineZ))
                    {
                        PolyLineZ p = (PolyLineZ)shapefile.Shapes[i];
                        for (int z = 0; z < p.Lines.Length; z++)
                        {
                            count = (p.Lines[z].Points.Length);
                            Vector3[] points = new Vector3[(count)];

                            firstItem = true;
                            for (int k = 0; k < p.Lines[z].Points.Length; k++)
                            {
                                // 2D Point coordinates. 3d also supported which would add a Z. There's also an optional measure (M) that can be used.
                                double Xcoord = p.Lines[z].Points[k].X;
                                double Ycoord = p.Lines[z].Points[k].Y;
                                if (shapefile.Projection == ShapeFile.Projections.Geo)
                                {
                                    lastItem = Coordinates.GeoTo3d(Ycoord, Xcoord);
                                }
                                else if (shapefile.Projection == ShapeFile.Projections.PolarStereo)
                                {
                                    lastItem = Coordinates.SterographicTo3d(Xcoord, Ycoord, 1, standardParallel, centralMeridian, offsetX, offsetY, mapScale, north).Vector3;
                                }

                                if (k == 0)
                                {
                                    firstItemIndex = currentIndex;
                                    firstItem      = true;
                                }

                                vertList.Add(lastItem);

                                if (firstItem)
                                {
                                    firstItem = false;
                                }
                                else
                                {
                                    indexList.Add(currentIndex);
                                    currentIndex++;
                                    indexList.Add(currentIndex);
                                }
                            }
                            currentIndex++;
                        }
                    }
                    else if (shapefile.Shapes[i].GetType() == typeof(ShapefileTools.Point))
                    {
                        ShapefileTools.Point p = (ShapefileTools.Point)shapefile.Shapes[i];

                        // 2D Point coordinates. 3d also supported which would add a Z. There's also an optional measure (M) that can be used.
                        double Xcoord = p.X;
                        double Ycoord = p.Y;
                        if (shapefile.Projection == ShapeFile.Projections.Geo)
                        {
                            lastItem = Coordinates.GeoTo3d(Ycoord, Xcoord);
                        }
                        else if (shapefile.Projection == ShapeFile.Projections.PolarStereo)
                        {
                            lastItem = Coordinates.SterographicTo3d(Xcoord, Ycoord, 1, standardParallel, centralMeridian, offsetX, offsetY, mapScale, north).Vector3;
                        }

                        vertList.Add(lastItem);

                        currentIndex++;
                        lines = false;
                    }
                }

                shapeVertexCount = vertList.Count;
                shapeFileVertex  = new PositionVertexBuffer11(vertList.Count, RenderContext11.PrepDevice);

                Vector3[] verts   = (Vector3[])shapeFileVertex.Lock(0, 0); // Lock the buffer (which will return our structs)
                int       indexer = 0;
                foreach (Vector3 vert in vertList)
                {
                    verts[indexer++] = vert;
                }
                shapeFileVertex.Unlock();


                shapeIndexCount = indexList.Count;

                if (lines)
                {
                    if (indexList.Count > 65500)
                    {
                        isLongIndex    = true;
                        shapeFileIndex = new IndexBuffer11(typeof(UInt32), indexList.Count, RenderContext11.PrepDevice);
                    }
                    else
                    {
                        isLongIndex    = false;
                        shapeFileIndex = new IndexBuffer11(typeof(short), indexList.Count, RenderContext11.PrepDevice);
                    }

                    if (isLongIndex)
                    {
                        indexer = 0;
                        UInt32[] indexes = (UInt32[])shapeFileIndex.Lock();
                        foreach (UInt32 indexVal in indexList)
                        {
                            indexes[indexer++] = indexVal;
                        }
                        shapeFileIndex.Unlock();
                    }
                    else
                    {
                        indexer = 0;
                        short[] indexes = (short[])shapeFileIndex.Lock();
                        foreach (UInt32 indexVal in indexList)
                        {
                            indexes[indexer++] = (short)indexVal;
                        }
                        shapeFileIndex.Unlock();
                    }
                }
            }


            renderContext.DepthStencilMode = DepthStencilMode.Off;
            renderContext.BlendMode        = BlendMode.Alpha;
            SimpleLineShader11.Color       = Color.FromArgb((int)(opacity * 255), Color);

            SharpDX.Matrix mat = (renderContext.World * renderContext.View * renderContext.Projection).Matrix11;
            mat.Transpose();

            SimpleLineShader11.WVPMatrix      = mat;
            SimpleLineShader11.CameraPosition = Vector3d.TransformCoordinate(renderContext.CameraPosition, Matrix3d.Invert(renderContext.World)).Vector3;
            SimpleLineShader11.ShowFarSide    = false;
            SimpleLineShader11.Sky            = false;

            renderContext.SetVertexBuffer(shapeFileVertex);
            SimpleLineShader11.Use(renderContext.devContext);

            if (lines)
            {
                renderContext.devContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.LineList;
                renderContext.SetIndexBuffer(shapeFileIndex);
                renderContext.devContext.DrawIndexed(shapeFileIndex.Count, 0, 0);
            }
            else
            {
                renderContext.devContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.PointList;
                renderContext.devContext.Draw(shapeVertexCount, 0);
            }

            renderContext.devContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList;

            return(true);
        }