Recognize() public method

识别出以lastVertexId结尾的图元。
public Recognize ( uint lastVertexId, IntPtr pointer, OneIndexBuffer oneIndexBuffer ) : List
lastVertexId uint
pointer System.IntPtr
oneIndexBuffer OneIndexBuffer
return List
Beispiel #1
0
        /// <summary>
        /// 遍历以<paramref name="lastVertexId"/>为最后一个顶点的图元,
        /// 瞄准每个图元的索引(例如1个三角形有3个索引)中的最后一个索引,
        /// 将此索引在<see cref="IndexBuffer"/>中的索引(位置)收集起来。
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="lastVertexId"></param>
        /// <returns></returns>
        private List <RecognizedPrimitiveInfo> GetLastIndexIdList(PickingEventArgs arg, uint lastVertexId)
        {
            var indexBuffer = this.Renderer.PickingRenderUnit.VertexArrayObject.IndexBuffer;
            PrimitiveRecognizer recognizer = PrimitiveRecognizerFactory.Create(
                (arg.GeometryType.Contains(GeometryType.Point) &&
                 indexBuffer.Mode.ToGeometryType() == GeometryType.Line) ?
                DrawMode.Points : indexBuffer.Mode);

            PrimitiveRestartState glState = GetPrimitiveRestartState();

            var    buffer  = indexBuffer as OneIndexBuffer;
            IntPtr pointer = buffer.MapBuffer(MapBufferAccess.ReadOnly);
            List <RecognizedPrimitiveInfo> primitiveInfoList = null;

            if (glState == null)
            {
                primitiveInfoList = recognizer.Recognize(lastVertexId, pointer, indexBuffer as OneIndexBuffer);
            }
            else
            {
                primitiveInfoList = recognizer.Recognize(lastVertexId, pointer, indexBuffer as OneIndexBuffer, glState.RestartIndex);
            }
            buffer.UnmapBuffer();

            return(primitiveInfoList);
        }
        /// <summary>
        /// 遍历以<see cref="lastVerteID"/>为最后一个顶点的图元,
        /// 瞄准每个图元的索引(例如1个三角形有3个索引)中的最后一个索引,
        /// 将此索引在<see cref="indexBufferPtr"/>中的索引(位置)收集起来。
        /// </summary>
        /// <param name="lastVertexId"></param>
        /// <returns></returns>
        private List <RecognizedPrimitiveIndex> GetLastIndexIdList(RenderEventArgs arg, uint lastVertexId)
        {
            PrimitiveRecognizer recognizer = PrimitiveRecognizerFactory.Create(
                (arg.RenderMode == RenderModes.ColorCodedPicking &&
                 arg.PickingGeometryType == GeometryType.Point &&
                 this.indexBufferPtr.Mode.ToGeometryType() == GeometryType.Line) ?
                DrawMode.Points : this.indexBufferPtr.Mode);

            PrimitiveRestartSwitch glSwitch = GetPrimitiveRestartSwitch();

            OpenGL.BindBuffer(BufferTarget.ElementArrayBuffer, this.indexBufferPtr.BufferId);
            IntPtr pointer = OpenGL.MapBuffer(BufferTarget.ElementArrayBuffer, MapBufferAccess.ReadOnly);
            List <RecognizedPrimitiveIndex> lastIndexIdList = null;

            if (glSwitch == null)
            {
                lastIndexIdList = recognizer.Recognize(lastVertexId, pointer, this.indexBufferPtr as OneIndexBufferPtr);
            }
            else
            {
                lastIndexIdList = recognizer.Recognize(lastVertexId, pointer, this.indexBufferPtr as OneIndexBufferPtr, glSwitch.RestartIndex);
            }
            OpenGL.UnmapBuffer(BufferTarget.ElementArrayBuffer);
            OpenGL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);

            return(lastIndexIdList);
        }
Beispiel #3
0
        /// <summary>
        /// 遍历以<paramref name="lastVertexId"/>为最后一个顶点的图元,
        /// 瞄准每个图元的索引(例如1个三角形有3个索引)中的最后一个索引,
        /// 将此索引在<see cref="IndexBuffer"/>中的索引(位置)收集起来。
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="lastVertexId"></param>
        /// <returns></returns>
        private List <RecognizedPrimitiveInfo> GetLastIndexIdList(RenderEventArgs arg, uint lastVertexId)
        {
            PrimitiveRecognizer recognizer = PrimitiveRecognizerFactory.Create(
                (arg.PickingGeometryType == PickingGeometryType.Point &&
                 this.indexBuffer.Mode.ToGeometryType() == PickingGeometryType.Line) ?
                DrawMode.Points : this.indexBuffer.Mode);

            PrimitiveRestartState glState = GetPrimitiveRestartState();

            var    buffer  = this.indexBuffer as OneIndexBuffer;
            IntPtr pointer = buffer.MapBuffer(MapBufferAccess.ReadOnly);
            List <RecognizedPrimitiveInfo> primitiveInfoList = null;

            if (glState == null)
            {
                primitiveInfoList = recognizer.Recognize(lastVertexId, pointer, this.indexBuffer as OneIndexBuffer);
            }
            else
            {
                primitiveInfoList = recognizer.Recognize(lastVertexId, pointer, this.indexBuffer as OneIndexBuffer, glState.RestartIndex);
            }
            buffer.UnmapBuffer();

            return(primitiveInfoList);
        }
Beispiel #4
0
        /// <summary>
        /// 遍历以<paramref name="lastVertexId"/>为最后一个顶点的图元,
        /// 瞄准每个图元的索引(例如1个三角形有3个索引)中的最后一个索引,
        /// 将此索引在<see cref="IndexBuffer"/>中的索引(位置)收集起来。
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="lastVertexId"></param>
        /// <returns></returns>
        private List <RecognizedPrimitiveInfo> GetLastIndexIdList(PickingEventArgs arg, uint lastVertexId)
        {
            var drawCmd = this.DrawCommand;
            PrimitiveRecognizer recognizer = PrimitiveRecognizerFactory.Create(
                (arg.GeometryType.Contains(GeometryType.Point) &&
                 drawCmd.Mode.ToGeometryType() == GeometryType.Line) ?
                DrawMode.Points : drawCmd.Mode);

            PrimitiveRestartState glState = GetPrimitiveRestartState();

            var    buffer  = (drawCmd as IHasIndexBuffer).IndexBufferObject;
            IntPtr pointer = buffer.MapBuffer(MapBufferAccess.ReadOnly);
            List <RecognizedPrimitiveInfo> primitiveInfoList = null;

            if (glState == null)
            {
                primitiveInfoList = recognizer.Recognize(lastVertexId, pointer, drawCmd as DrawElementsCmd);
            }
            else
            {
                primitiveInfoList = recognizer.Recognize(lastVertexId, pointer, drawCmd as DrawElementsCmd, glState.RestartIndex);
            }
            buffer.UnmapBuffer();

            return(primitiveInfoList);
        }
Beispiel #5
0
        /// <summary>
        /// 遍历以<paramref name="flatColorVertexId"/>为最后一个顶点的图元,
        /// 瞄准每个图元的索引(例如1个三角形有3个索引)中的最后一个索引,
        /// 将此索引在<see cref="IndexBuffer"/>中的索引(位置)收集起来。
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="flatColorVertexId"></param>
        /// <returns></returns>
        private List <RecognizedPrimitiveInfo> GetPossiblePrimitives(PickingEventArgs arg, uint flatColorVertexId)
        {
            var                 drawCmd    = this.DrawCommand;
            DrawMode            mode       = drawCmd.CurrentMode;
            PrimitiveRecognizer recognizer = PrimitiveRecognizerFactory.Create(
                (arg.GeometryType.Contains(GeometryType.Point) &&
                 mode.ToGeometryType() == GeometryType.Line) ?
                DrawMode.Points : mode);

            List <RecognizedPrimitiveInfo> primitiveInfoList = recognizer.Recognize(flatColorVertexId, drawCmd);

            return(primitiveInfoList);
        }
        /// <summary>
        /// 遍历以<paramref name="lastVertexId"/>为最后一个顶点的图元,
        /// 瞄准每个图元的索引(例如1个三角形有3个索引)中的最后一个索引,
        /// 将此索引在<see cref="IndexBuffer"/>中的索引(位置)收集起来。
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="lastVertexId"></param>
        /// <returns></returns>
        private List <RecognizedPrimitiveInfo> GetLastIndexIdList(PickingEventArgs arg, uint lastVertexId)
        {
            var                 drawCmd    = this.DrawCommand;
            DrawMode            mode       = drawCmd.Mode;
            PrimitiveRecognizer recognizer = PrimitiveRecognizerFactory.Create(
                (arg.GeometryType.Contains(GeometryType.Point) &&
                 mode.ToGeometryType() == GeometryType.Line) ?
                DrawMode.Points : mode);

            PrimitiveRestartState glState = GetPrimitiveRestartState();

            List <RecognizedPrimitiveInfo> primitiveInfoList = null;

            if (glState == null)
            {
                primitiveInfoList = recognizer.Recognize(lastVertexId, drawCmd);
            }
            else
            {
                primitiveInfoList = recognizer.Recognize(lastVertexId, drawCmd, glState.RestartIndex);
            }

            return(primitiveInfoList);
        }