Example #1
0
        public static PositionVertexBuffer CreateEllipseVertexBufferWithoutStartPoint(int vertexCount)
        {
            PositionVertexBuffer vb = new PositionVertexBuffer(vertexCount);

            Vector3d[] verts = vb.Lock();

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

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

            vb.Unlock();

            return(vb);
        }
Example #2
0
        public static PositionVertexBuffer CreateEllipseVertexBuffer(int vertexCount)
        {
            PositionVertexBuffer vb = new PositionVertexBuffer(vertexCount);

            Vector3d[] verts = vb.Lock();
            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++] = Vector3d.Create(2.0f * (float)i / (float)vertexCount * 0.05f, 0.0f, 0.0f);
            }
            for (int i = 0; i < vertexCount / 2; ++i)
            {
                verts[index++] = Vector3d.Create(2.0f * (float)i / (float)vertexCount * 0.95f + 0.05f, 0.0f, 0.0f);
            }

            vb.Unlock();

            return(vb);
        }
Example #3
0
        void InitLineBuffer(RenderContext renderContext)
        {
            if (renderContext.gl != null)
            {
                if (lineBuffers.Count == 0)
                {
                    int count = linePoints.Count;

                    PositionVertexBuffer lineBuffer = null;


                    Vector3d[] 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 PositionVertexBuffer(thisCount);

                            linePointList = (Vector3d[])lineBuffer.Lock(); // Lock the buffer (which will return our structs)

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

                        if (UseLocalCenters)
                        {
                            temp = Vector3d.SubtractVectors(point, localCenter);
                            linePointList[counter] = temp;
                        }
                        else
                        {
                            linePointList[counter] = point;
                        }
                        index++;
                        counter++;
                    }

                    if (lineBuffer != null)
                    {
                        lineBuffer.Unlock();
                    }
                }
            }
        }