支持"拾取"的渲染器
Inheritance: Renderer, IColorCodedPicking
Exemplo n.º 1
0
        /// <summary>
        /// opengl UI for Axis
        /// </summary>
        /// <param name="anchor"></param>
        /// <param name="margin"></param>
        /// <param name="size"></param>
        /// <param name="zNear"></param>
        /// <param name="zFar"></param>
        public UIAxis(
            System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin,
            System.Drawing.Size size, int zNear, int zFar)
            : base(anchor, margin, size, zNear, zFar)
        {
            this.Name = typeof(UIAxis).Name;
            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(
            @"Resources.UIAxis.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(
            @"Resources.UIAxis.frag"), ShaderType.FragmentShader);
            var map = new PropertyNameMap();
            map.Add("in_Position", "position");
            map.Add("in_Color", "color");
            //PickableRenderer renderer = (new Axis()).GetRenderer(shaderCodes, map, "position");
            PickableRenderer renderer = new PickableRenderer(new Axis(), shaderCodes, map, "position");

            this.Renderer = renderer;
        }
Exemplo n.º 2
0
        /// <summary>
        /// opengl UI for Axis
        /// </summary>
        /// <param name="anchor"></param>
        /// <param name="margin"></param>
        /// <param name="size"></param>
        /// <param name="zNear"></param>
        /// <param name="zFar"></param>
        public GLAxis(
            System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin,
            System.Drawing.Size size, int zNear, int zFar)
            : base(null, anchor, margin, size, zNear, zFar)
        {
            this.Name = "GLAxis";
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(
                                                @"Resources.GLAxis.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(
                                                @"Resources.GLAxis.frag"), ShaderType.FragmentShader);
            var map = new PropertyNameMap();

            map.Add("in_Position", "position");
            map.Add("in_Color", "color");
            //PickableRenderer renderer = (new Axis()).GetRenderer(shaderCodes, map, "position");
            PickableRenderer renderer = new PickableRenderer(new Axis(), shaderCodes, map, "position");

            this.Renderer = renderer;
        }
 /// <summary>
 /// 高亮显示拾取的图元。
 /// </summary>
 /// <param name="highlighter"></param>
 /// <param name="pickableRenderer"></param>
 public HighlightedPickableRenderer(HighlightRenderer highlighter,
                                    PickableRenderer pickableRenderer)
 {
     this.Highlighter      = highlighter;
     this.PickableRenderer = pickableRenderer;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Get picked geometry.
 /// </summary>
 /// <param name="renderer"></param>
 public PickerBase(PickableRenderer renderer)
 {
     this.Renderer = renderer;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Get picked geometry from a <see cref="PickableRenderer"/> with <see cref="ZeroIndexBuffer"/> as index buffer.
 /// </summary>
 /// <param name="renderer"></param>
 public ZeroIndexPicker(PickableRenderer renderer) : base(renderer)
 {
 }
 /// <summary>
 /// 高亮显示拾取的图元。
 /// </summary>
 /// <param name="highlighter"></param>
 /// <param name="pickableRenderer"></param>
 public HighlightedPickableRenderer(HighlightRenderer highlighter,
     PickableRenderer pickableRenderer)
 {
     this.Highlighter = highlighter;
     this.PickableRenderer = pickableRenderer;
 }
Exemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="renderer"></param>
        /// <param name="arg"></param>
        /// <param name="stageVertexId"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public override PickedGeometry GetPickedGeometry(PickEventArgs arg, uint stageVertexId)
        {
            PickableRenderer renderer = this.Renderer;

            uint lastVertexId;

            if (!renderer.GetLastVertexIdOfPickedGeometry(stageVertexId, out lastVertexId))
            {
                return(null);
            }

            // 找到 lastIndexId
            RecognizedPrimitiveInfo lastIndexId = this.GetLastIndexIdOfPickedGeometry(
                arg, lastVertexId);

            if (lastIndexId == null)
            {
                Debug.WriteLine(string.Format(
                                    "Got lastVertexId[{0}] but no lastIndexId! Params are [{1}] [{2}] [{3}] [{4}]",
                                    lastVertexId, arg, stageVertexId));
                { return(null); }
            }

            PickingGeometryType geometryType = arg.GeometryType;
            DrawMode            mode         = renderer.IndexBuffer.Mode;
            PickingGeometryType typeOfMode   = mode.ToGeometryType();

            if (geometryType == PickingGeometryType.Point)
            {
                // 获取pickedGeometry
                if (typeOfMode == PickingGeometryType.Point)
                {
                    return(PickWhateverItIs(arg, stageVertexId, lastIndexId, typeOfMode));
                }
                else if (typeOfMode == PickingGeometryType.Line)
                {
                    if (this.OnPrimitiveTest(lastVertexId, mode))
                    {
                        return(PickPoint(arg, stageVertexId, lastVertexId));
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    OneIndexPointSearcher searcher = GetPointSearcher(mode);
                    if (searcher != null)// line is from triangle, quad or polygon
                    {
                        return(SearchPoint(arg, stageVertexId, lastVertexId, lastIndexId, searcher));
                    }
                    else
                    {
                        throw new Exception(string.Format("Lack of searcher for [{0}]", mode));
                    }
                }
            }
            else if (geometryType == PickingGeometryType.Line)
            {
                // 获取pickedGeometry
                if (geometryType == typeOfMode)
                {
                    return(PickWhateverItIs(arg, stageVertexId, lastIndexId, typeOfMode));
                }
                else
                {
                    OneIndexLineSearcher searcher = GetLineSearcher(mode);
                    if (searcher != null)// line is from triangle, quad or polygon
                    {
                        return(SearchLine(arg, stageVertexId, lastIndexId, searcher));
                    }
                    else if (mode == DrawMode.Points)// want a line when rendering GL_POINTS
                    {
                        return(null);
                    }
                    else
                    {
                        throw new Exception(string.Format("Lack of searcher for [{0}]", mode));
                    }
                }
            }
            else
            {
                if (typeOfMode == geometryType)// I want what it is
                {
                    return(PickWhateverItIs(arg, stageVertexId, lastIndexId, typeOfMode));
                }
                else
                {
                    return(null);
                }
                //{ throw new Exception(string.Format("Lack of searcher for [{0}]", mode)); }
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Get picked geometry from a <see cref="PickableRenderer"/> with <see cref="ZeroIndexBuffer"/> as index buffer.
 /// </summary>
 /// <param name="renderer"></param>
 public OneIndexPicker(PickableRenderer renderer) : base(renderer)
 {
 }