Пример #1
0
        /// <summary>
        /// Pick geometry at specified positon.
        /// </summary>
        /// <param name="x">Left Down is (0, 0)</param>
        /// <param name="y">Left Down is (0, 0)</param>
        /// <param name="geometryType"></param>
        /// <returns></returns>
        public PickedGeometry Pick(int x, int y, GeometryType geometryType)
        {
            PickedGeometry pickedGeometry = null;

            Framebuffer framebuffer = GetPickingFramebuffer();

            framebuffer.Bind();
            {
                const float one = 1.0f;
                GL.Instance.ClearColor(one, one, one, one);
                GL.Instance.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);

                var arg = new PickingEventArgs(this.Scene, x, y, geometryType.ToFlags());
                this.RenderForPicking(this.Scene.RootElement, arg);

                uint stageVertexId = ColorCodedPicking.ReadStageVertexId(x, y);

                pickedGeometry = Pick(stageVertexId, arg, this.Scene.RootElement);
            }
            framebuffer.Unbind();

            return(pickedGeometry);
        }
Пример #2
0
 /// <summary>
 /// Pick geometry at specified positon.
 /// </summary>
 /// <param name="x">Left Down is (0, 0)</param>
 /// <param name="y">Left Down is (0, 0)</param>
 /// <param name="geometryType"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 /// <returns></returns>
 public PickedGeometry Pick(int x, int y, GeometryType geometryType, int width, int height)
 {
     return(Pick(x, y, geometryType.ToFlags(), width, height));
 }