Пример #1
0
        private static DrawArraysPointSearcher GetPointSearcher(DrawMode mode)
        {
            DrawArraysPointSearcher result = null;

            switch (mode)
            {
            case DrawMode.Points:
                result = null;
                break;

            case DrawMode.Lines:
                result = null;
                break;

            case DrawMode.LineLoop:
                result = null;
                break;

            case DrawMode.LineStrip:
                result = null;
                break;

            case DrawMode.Triangles:
                result = pointInTriangles;
                break;

            case DrawMode.TriangleStrip:
                result = pointInTriangleStrip;
                break;

            case DrawMode.TriangleFan:
                result = pointInTriangleFan;
                break;

            case DrawMode.Quads:
                result = pointInQuads;
                break;

            case DrawMode.QuadStrip:
                result = pointInQuadStrip;
                break;

            case DrawMode.Polygon:
                result = pointInPolygon;
                break;

            case DrawMode.LinesAdjacency:
                result = null;
                break;

            case DrawMode.LineStripAdjacency:
                result = null;
                break;

            case DrawMode.TrianglesAdjacency:
                result = pointInTrianglesAdjacency;
                break;

            case DrawMode.TriangleStripAdjacency:
                result = pointInTriangleStripAdjacency;
                break;

            case DrawMode.Patches:
                result = null;
                break;

            default:
                throw new NotDealWithNewEnumItemException(typeof(DrawMode));
            }

            return(result);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="stageVertexId"></param>
        /// <param name="singleNodeVertexId"></param>
        /// <param name="searcher"></param>
        /// <returns></returns>
        private PickedGeometry SearchPoint(PickingEventArgs arg, uint stageVertexId, uint singleNodeVertexId, DrawArraysPointSearcher searcher)
        {
            uint baseId    = stageVertexId - singleNodeVertexId;
            var  vertexIds = new uint[] { searcher.Search(arg, singleNodeVertexId, stageVertexId, this) - baseId };

            vec3[] positions      = FillPickedGeometrysPosition(vertexIds);
            var    pickedGeometry = new PickedGeometry(GeometryType.Point, positions, vertexIds, stageVertexId, this.Node);

            return(pickedGeometry);
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="stageVertexId">The last vertex's id that constructs the picked primitive.
        /// <para>This id is in scene's all <see cref="IPickable"/>s' order.</para></param>
        /// <param name="baseId">Index of first vertex of the buffer that The geometry belongs to.
        /// <para>This id is in scene's all <see cref="IPickable"/>s' order.</para></param>
        /// <returns></returns>
        public override PickedGeometry GetPickedGeometry(PickingEventArgs arg, uint stageVertexId, uint baseId)
        {
            if (stageVertexId < baseId)
            {
                return(null);
            }
            uint singleNodeVertexId = stageVertexId - baseId;

            if (this.PositionBuffer.Length <= singleNodeVertexId)
            {
                return(null);
            }

            PickingGeometryTypes pickingType = arg.GeometryType;

            if ((pickingType & PickingGeometryTypes.Point) == PickingGeometryTypes.Point)
            {
                DrawMode     mode       = this.DrawCommand.CurrentMode;
                GeometryType typeOfMode = mode.ToGeometryType();
                if (typeOfMode == GeometryType.Point)
                {
                    return(PickWhateverItIs(arg, stageVertexId, singleNodeVertexId, mode, typeOfMode));
                }
                else if (typeOfMode == GeometryType.Line)
                {
                    if (this.OnPrimitiveTest(singleNodeVertexId, mode))
                    {
                        return(PickPoint(arg, stageVertexId, singleNodeVertexId));
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    DrawArraysPointSearcher searcher = GetPointSearcher(mode);
                    if (searcher != null)// point is from triangle, quad or polygon
                    {
                        return(SearchPoint(arg, stageVertexId, singleNodeVertexId, searcher));
                    }
                    else
                    {
                        throw new Exception(string.Format("Lack of searcher for [{0}]", mode));
                    }
                }
            }
            else if ((pickingType & PickingGeometryTypes.Line) == PickingGeometryTypes.Line)
            {
                DrawMode     mode       = this.DrawCommand.CurrentMode;
                GeometryType typeOfMode = mode.ToGeometryType();
                if (pickingType.Contains(typeOfMode))
                {
                    return(PickWhateverItIs(arg, stageVertexId, singleNodeVertexId, mode, typeOfMode));
                }
                else
                {
                    DrawArraysLineSearcher searcher = GetLineSearcher(mode);
                    if (searcher != null)// line is from triangle, quad or polygon
                    {
                        return(SearchLine(arg, stageVertexId, singleNodeVertexId, 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
            {
                DrawMode     mode       = this.DrawCommand.CurrentMode;
                GeometryType typeOfMode = mode.ToGeometryType();
                if (pickingType.Contains(typeOfMode)) // I want what it is
                {
                    return(PickWhateverItIs(arg, stageVertexId, singleNodeVertexId, mode, typeOfMode));
                }
                else
                {
                    return(null);
                }
                //{ throw new Exception(string.Format("Lack of searcher for [{0}]", mode)); }
            }
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="stageVertexId"></param>
        /// <param name="flatColorVertexId"></param>
        /// <param name="searcher"></param>
        /// <returns></returns>
        private PickedGeometry SearchPoint(PickingEventArgs arg, uint stageVertexId, uint flatColorVertexId, DrawArraysPointSearcher searcher)
        {
            var vertexIds = new uint[] { searcher.Search(arg, flatColorVertexId, this), };

            vec3[] positions      = FillPickedGeometrysPosition(vertexIds);
            var    pickedGeometry = new PickedGeometry(GeometryType.Point, positions, vertexIds, stageVertexId, this.Node);

            return(pickedGeometry);
        }