Пример #1
0
        } // AddLine(startPoint, endPoint, color)

        public void UpdateVertexBuffer()
        {
            // Don't do anything if we got no lines.
            if (NumOfLines == 0 ||
                // Or if some data is invalid
                lines.Count < NumOfLines)
            {
                numOfPrimitives = 0;
                return;
            } // if (numOfLines)

            if (buildVertexBuffer || numOfPrimitives != NumOfLines)
            {
                //UpdateVertexBuffer();



                // Set all lines
                for (int lineNum = 0; lineNum < NumOfLines; lineNum++)
                {
                    LineManager3D.Line line = (LineManager3D.Line)lines[lineNum];
                    LineVertices[lineNum * 2 + 0] = new VertexPositionColor(
                        line.startPoint, line.startColor);
                    LineVertices[lineNum * 2 + 1] = new VertexPositionColor(
                        line.endPoint, line.endColor);
                } // for (lineNum)
                numOfPrimitives = NumOfLines;

                // Vertex buffer was build
                buildVertexBuffer = false;
            } // if (buildVertexBuffer)
        }     // UpdateVertexBuffer()
Пример #2
0
        /// <summary>
        /// Add line
        /// </summary>
        public void AddLine(
            Vector3 startPoint, Color startColor,
            Vector3 endPoint, Color endColor)
        {
            // Don't add new lines if limit is reached
            if (NumOfLines >= MaxNumOfLines)
            {
                /*ignore
                 * Log.Write("Too many lines requested in LineManager3D. " +
                 *  "Max lines = " + MaxNumOfLines);
                 */
                return;
            } // if (numOfLines)

            // Build line
            LineManager3D.Line line = new LineManager3D.Line(startPoint, startColor, endPoint, endColor);

            // Check if this exact line exists at the current lines position.
            if (lines.Count > NumOfLines)
            {
                if ((LineManager3D.Line)lines[NumOfLines] != line)
                {
                    // overwrite old line, otherwise just increase numOfLines
                    lines[NumOfLines] = line;
                    // Remember to build vertex buffer in Render()
                    buildVertexBuffer = true;
                } // if if
            }     // if
            else
            {
                // Then just add new line
                lines.Add(line);
                // Remember to build vertex buffer in Render()
                buildVertexBuffer = true;
            } // else

            // nextUpValue line
            NumOfLines++;
        } // AddLine(startPoint, startColor, endPoint)