コード例 #1
0
        static ZeroIndexPointSearcher GetPointSearcher(DrawMode mode)
        {
            if (pointSearcherDict == null)
            {
                var dict = new Dictionary <DrawMode, ZeroIndexPointSearcher>();
                dict.Add(DrawMode.Triangles, new ZeroIndexPointInTriangleSearcher());
                dict.Add(DrawMode.TrianglesAdjacency, new ZeroIndexPointInTrianglesAdjacencySearcher());
                dict.Add(DrawMode.TriangleStrip, new ZeroIndexPointInTriangleStripSearcher());
                dict.Add(DrawMode.TriangleStripAdjacency, new ZeroIndexPointInTriangleStripAdjacencySearcher());
                dict.Add(DrawMode.TriangleFan, new ZeroIndexPointInTriangleFanSearcher());
                dict.Add(DrawMode.Quads, new ZeroIndexPointInQuadSearcher());
                dict.Add(DrawMode.QuadStrip, new ZeroIndexPointInQuadStripSearcher());
                dict.Add(DrawMode.Polygon, new ZeroIndexPointInPolygonSearcher());

                pointSearcherDict = dict;
            }

            ZeroIndexPointSearcher result = null;

            if (pointSearcherDict.TryGetValue(mode, out result))
            {
                return(result);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="stageVertexId"></param>
        /// <param name="x">mouse position(Left Down is (0, 0)).</param>
        /// <param name="y">mouse position(Left Down is (0, 0)).</param>
        /// <returns></returns>
        public override PickedGeometry GetPickedGeometry(RenderEventArgs arg, uint stageVertexId,
                                                         int x, int y)
        {
            uint lastVertexId;

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

            PickingGeometryType geometryType = arg.PickingGeometryType;

            if (geometryType == PickingGeometryType.Point)
            {
                DrawMode            mode       = this.indexBuffer.Mode;
                PickingGeometryType typeOfMode = mode.ToGeometryType();
                if (typeOfMode == PickingGeometryType.Point)
                {
                    return(PickWhateverItIs(arg, stageVertexId, lastVertexId, mode, typeOfMode));
                }
                else if (typeOfMode == PickingGeometryType.Line)
                {
                    if (this.OnPrimitiveTest(lastVertexId, mode))
                    {
                        return(PickPoint(arg, stageVertexId, lastVertexId));
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    ZeroIndexPointSearcher searcher = GetPointSearcher(mode);
                    if (searcher != null)// point is from triangle, quad or polygon
                    {
                        return(SearchPoint(arg, stageVertexId, x, y, lastVertexId, searcher));
                    }
                    else
                    {
                        throw new Exception(string.Format("Lack of searcher for [{0}]", mode));
                    }
                }
            }
            else if (geometryType == PickingGeometryType.Line)
            {
                DrawMode            mode       = this.indexBuffer.Mode;
                PickingGeometryType typeOfMode = mode.ToGeometryType();
                if (geometryType == typeOfMode)
                {
                    return(PickWhateverItIs(arg, stageVertexId, lastVertexId, mode, typeOfMode));
                }
                else
                {
                    ZeroIndexLineSearcher searcher = GetLineSearcher(mode);
                    if (searcher != null)// line is from triangle, quad or polygon
                    {
                        return(SearchLine(arg, stageVertexId, x, y, lastVertexId, 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.indexBuffer.Mode;
                PickingGeometryType typeOfMode = mode.ToGeometryType();
                if (typeOfMode == geometryType)// I want what it is
                {
                    return(PickWhateverItIs(arg, stageVertexId, lastVertexId, mode, typeOfMode));
                }
                else
                {
                    return(null);
                }
                //{ throw new Exception(string.Format("Lack of searcher for [{0}]", mode)); }
            }
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="stageVertexId"></param>
        /// <param name="x">mouse position(Left Down is (0, 0)).</param>
        /// <param name="y">mouse position(Left Down is (0, 0)).</param>
        /// <param name="lastVertexId"></param>
        /// <param name="searcher"></param>
        /// <returns></returns>
        private PickedGeometry SearchPoint(RenderEventArgs arg, uint stageVertexId, int x, int y, uint lastVertexId, ZeroIndexPointSearcher searcher)
        {
            var vertexIds = new uint[] { searcher.Search(arg, x, y, lastVertexId, this), };

            vec3[] positions      = FillPickedGeometrysPosition(vertexIds);
            var    pickedGeometry = new PickedGeometry(PickingGeometryType.Line, positions, vertexIds, stageVertexId, this);

            return(pickedGeometry);
        }
コード例 #4
0
        private static ZeroIndexPointSearcher GetPointSearcher(DrawMode mode)
        {
            ZeroIndexPointSearcher 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:
                result = null;
                break;
            }

            return(result);
        }
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="stageVertexId"></param>
        /// <param name="x">mouse position(Left Down is (0, 0)).</param>
        /// <param name="y">mouse position(Left Down is (0, 0)).</param>
        /// <param name="lastVertexId"></param>
        /// <param name="searcher"></param>
        /// <returns></returns>
        private PickedGeometry SearchPoint(RenderEventArgs arg, uint stageVertexId, int x, int y, uint lastVertexId, ZeroIndexPointSearcher searcher)
        {
            var vertexIds = new uint[] { searcher.Search(arg, x, y, lastVertexId, this), };
            vec3[] positions = FillPickedGeometrysPosition(vertexIds);
            var pickedGeometry = new PickedGeometry(arg.UsingViewPort, PickingGeometryType.Line, positions, vertexIds, stageVertexId, this);

            return pickedGeometry;
        }
コード例 #6
0
        private static ZeroIndexPointSearcher GetPointSearcher(DrawMode mode)
        {
            ZeroIndexPointSearcher 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);
        }
コード例 #7
0
        private PickedGeometry SearchPoint(RenderEventArgs arg, uint stageVertexId, int x, int y, uint lastVertexId, ZeroIndexPointSearcher searcher)
        {
            PickedGeometry pickedGeometry = new PickedGeometry();

            pickedGeometry.From          = this;
            pickedGeometry.GeometryType  = GeometryType.Line;
            pickedGeometry.StageVertexId = stageVertexId;
            pickedGeometry.VertexIds     = new uint[] { searcher.Search(arg, x, y, lastVertexId, this), };
            pickedGeometry.Positions     = FillPickedGeometrysPosition(pickedGeometry.VertexIds);

            return(pickedGeometry);
        }
コード例 #8
0
        private PickedGeometry SearchPoint(RenderEventArg arg, uint stageVertexId, int x, int y, uint lastVertexId, ZeroIndexPointSearcher searcher)
        {
            PickedGeometry pickedGeometry = new PickedGeometry();
            pickedGeometry.From = this;
            pickedGeometry.GeometryType = GeometryType.Line;
            pickedGeometry.StageVertexId = stageVertexId;
            pickedGeometry.Indexes = new uint[] { searcher.Search(arg, x, y, lastVertexId, this), };
            pickedGeometry.Positions = FillPickedGeometrysPosition(pickedGeometry.Indexes);

            return pickedGeometry;
        }