/// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="lastVertexId"></param>
        /// <param name="picker"></param>
        /// <returns></returns>
        internal override uint[] Search(PickingEventArgs arg,
                                        uint lastVertexId, DrawArraysPicker picker)
        {
            IndexBuffer buffer = GLBuffer.Create(IndexBufferElementType.UInt, 6, BufferUsage.StaticDraw);

            unsafe
            {
                var array = (uint *)buffer.MapBuffer(MapBufferAccess.WriteOnly);
                array[0] = lastVertexId - 2; array[1] = lastVertexId - 0;
                array[2] = lastVertexId - 4; array[3] = lastVertexId - 2;
                array[4] = lastVertexId - 0; array[5] = lastVertexId - 4;
                buffer.UnmapBuffer();
            }
            var cmd = new DrawElementsCmd(buffer, DrawMode.Lines);

            picker.Node.Render4InnerPicking(arg, ControlMode.ByFrame, cmd);
            uint id = ColorCodedPicking.ReadStageVertexId(arg.X, arg.Y);

            buffer.Dispose();

            if (id + 4 == lastVertexId)
            {
                return(new uint[] { id + 4, id, });
            }
            else
            {
                return(new uint[] { id - 2, id, });
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 在三角形图元中拾取指定位置的Line
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="flatColorVertexId">三角形图元的最后一个顶点</param>
        /// <param name="picker"></param>
        /// <returns></returns>
        internal override uint[] Search(PickingEventArgs arg,
                                        uint flatColorVertexId, DrawArraysPicker picker)
        {
            // 创建临时索引
            IndexBuffer buffer = GLBuffer.Create(IndexBufferElementType.UInt, 6, BufferUsage.StaticDraw);

            unsafe
            {
                var array = (uint *)buffer.MapBuffer(MapBufferAccess.WriteOnly);
                array[0] = flatColorVertexId - 1; array[1] = flatColorVertexId - 0;
                array[2] = flatColorVertexId - 2; array[3] = flatColorVertexId - 1;
                array[4] = flatColorVertexId - 0; array[5] = flatColorVertexId - 2;
                buffer.UnmapBuffer();
            }
            var cmd = new DrawElementsCmd(buffer, DrawMode.Lines);

            // 用临时索引渲染此三角形图元(仅渲染此三角形图元)
            picker.Node.Render4InnerPicking(arg, cmd);
            // id是拾取到的Line的Last Vertex Id
            uint id = ColorCodedPicking.ReadStageVertexId(arg.X, arg.Y);

            buffer.Dispose();

            // 对比临时索引,找到那个Line
            if (id + 2 == flatColorVertexId)
            {
                return(new uint[] { id + 2, id, });
            }
            else
            {
                return(new uint[] { id - 1, id, });
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="lastVertexId"></param>
        /// <param name="picker"></param>
        /// <returns></returns>
        internal override uint[] Search(PickingEventArgs arg, uint lastVertexId, DrawArraysPicker picker)
        {
            var cmd = picker.DrawCommand as DrawArraysCmd;
            // when the temp index buffer could be long, it's no longer needed.
            // what a great OpenGL API design!
            DrawArraysCmd drawCmd = new DrawArraysCmd(DrawMode.LineLoop, cmd.FirstVertex, cmd.RenderingVertexCount, cmd.InstanceCount, cmd.FrameCount);

            picker.Node.Render4InnerPicking(arg, ControlMode.ByFrame, drawCmd);
            uint id = ColorCodedPicking.ReadStageVertexId(arg.X, arg.Y);

            if (id == cmd.FirstVertex)
            {
                return(new uint[] { (uint)(cmd.FirstVertex + cmd.RenderingVertexCount - 1), id, });
            }
            else
            {
                return(new uint[] { id - 1, id, });
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="arg"></param>
 /// <param name="lastVertexId"></param>
 /// <param name="picker"></param>
 /// <returns></returns>
 internal abstract uint[] Search(PickingEventArgs arg,
                                 uint lastVertexId, DrawArraysPicker picker);
 /// <summary>
 ///
 /// </summary>
 /// <param name="arg"></param>
 /// <param name="singleNodeVertexId">identify location inside this node.</param>
 /// <param name="stageVertexId">identify location when rendering multiple nodes.</param>
 /// <param name="picker"></param>
 /// <returns></returns>
 internal abstract uint Search(PickingEventArgs arg,
                               uint singleNodeVertexId, uint stageVertexId, DrawArraysPicker picker);
Ejemplo n.º 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="arg"></param>
 /// <param name="flatColorVertexId"></param>
 /// <param name="picker"></param>
 /// <returns></returns>
 internal abstract uint Search(PickingEventArgs arg,
                               uint flatColorVertexId, DrawArraysPicker picker);