コード例 #1
0
        public static int GetPrimitiveSize(PrimitiveType primitive)
        {
            switch (primitive)
            {
            case PrimitiveType.LineList: return(IndexLine.GetSizeInShortInts());

            case PrimitiveType.PointList: return(IndexPoint.GetSizeInShortInts());

            case PrimitiveType.TriangleList: return(IndexTriangle.GetSizeInShortInts());

            default: break;
            }
            return(IndexTriangle.GetSizeInShortInts());
        }
コード例 #2
0
        // A helper function, analogous to ProcessFaces.
        private void ProcessPoints(RenderingPassBufferStorage bufferStorage)
        {
            var points = bufferStorage.Points;

            if (points.Count == 0)
            {
                return;
            }

            // Edges are encoded as line segment primitives whose vertices contain only position information.
            bufferStorage.FormatBits = VertexFormatBits.PositionColored;

            //int edgeVertexBufferSizeInFloats = VertexPosition.GetSizeInFloats() * bufferStorage.VertexBufferCount;
            int vertexBufferSizeInFloats = VertexPositionColored.GetSizeInFloats() * bufferStorage.VertexBufferCount;

            int numPoints = points.Count;

            bufferStorage.VertexBuffer = new VertexBuffer(vertexBufferSizeInFloats);
            bufferStorage.VertexBuffer.Map(vertexBufferSizeInFloats);

            var vertexStream = bufferStorage.VertexBuffer.GetVertexStreamPositionColored();

            for (int i = 0; i < numPoints; i++)
            {
                var pointInfo = points[i];
                var vertex    = pointInfo.Vertex;
                vertexStream.AddVertex(new VertexPositionColored(vertex + pointInfo.Offset, pointInfo.Color));
            }

            bufferStorage.VertexBuffer.Unmap();

            bufferStorage.IndexBufferCount = bufferStorage.PrimitiveCount * IndexPoint.GetSizeInShortInts();
            int indexBufferSizeInShortInts = 1 * bufferStorage.IndexBufferCount;

            bufferStorage.IndexBuffer = new IndexBuffer(indexBufferSizeInShortInts);
            bufferStorage.IndexBuffer.Map(indexBufferSizeInShortInts);
            {
                IndexStreamPoint indexStream = bufferStorage.IndexBuffer.GetIndexStreamPoint();
                for (int i = 0; i < numPoints; i++)
                {
                    indexStream.AddPoint(new IndexPoint(i));
                }
            }
            bufferStorage.IndexBuffer.Unmap();

            bufferStorage.VertexFormat   = new VertexFormat(bufferStorage.FormatBits);
            bufferStorage.EffectInstance = new EffectInstance(bufferStorage.FormatBits);
        }
コード例 #3
0
        static IndexBuffer IndexPointsBuffer(int pointsCount)
        {
            Debug.Assert(pointsCount <= VertexThreshold);

            if (indexPointsBuffer == null)
            {
                indexPointsBuffer = new IndexBuffer(VertexThreshold * IndexPoint.GetSizeInShortInts());
                indexPointsBuffer.Map(VertexThreshold * IndexPoint.GetSizeInShortInts());
                using (var istream = indexPointsBuffer.GetIndexStreamPoint())
                {
                    for (int vi = 0; vi < VertexThreshold; ++vi)
                    {
                        istream.AddPoint(new IndexPoint(vi));
                    }
                }
                indexPointsBuffer.Unmap();
            }

            Debug.Assert(indexPointsBuffer.IsValid());
            return(indexPointsBuffer);
        }
コード例 #4
0
ファイル: SearchEngine.cs プロジェクト: cyberdive/C-chess
        /// <summary>
        /// Sort move list using the specified point array so the highest point move come first
        /// </summary>
        /// <param name="moveList"> Source move list to sort</param>
        /// <param name="arrPoints">Array of points for each move</param>
        /// <returns>
        /// Sorted move list
        /// </returns>
        protected static List <Move> SortMoveList(List <Move> moveList, int[] arrPoints)
        {
            List <Move> moveListRetVal;

            IndexPoint[] arrIndexPoint;

            moveListRetVal = new List <Move>(moveList.Count);
            arrIndexPoint  = new IndexPoint[arrPoints.Length];
            for (int iIndex = 0; iIndex < arrIndexPoint.Length; iIndex++)
            {
                arrIndexPoint[iIndex].iPoints = arrPoints[iIndex];
                arrIndexPoint[iIndex].iIndex  = iIndex;
            }
            Array.Reverse(arrIndexPoint);
            Array.Sort <IndexPoint>(arrIndexPoint);
            for (int iIndex = 0; iIndex < arrIndexPoint.Length; iIndex++)
            {
                moveListRetVal.Add(moveList[arrIndexPoint[iIndex].iIndex]);
            }
            return(moveListRetVal);
        }
コード例 #5
0
 public IndexLine(IndexPoint point1, IndexPoint point2)
 {
     Point0 = point1;
     Point1 = point2;
 }