static ZeroIndexLineSearcher GetLineSearcher(DrawMode mode) { if (lineSearcherDict == null) { var dict = new Dictionary <DrawMode, ZeroIndexLineSearcher>(); dict.Add(DrawMode.Triangles, new ZeroIndexLineInTriangleSearcher()); dict.Add(DrawMode.TrianglesAdjacency, new ZeroIndexLineInTrianglesAdjacencySearcher()); dict.Add(DrawMode.TriangleStrip, new ZeroIndexLineInTriangleStripSearcher()); dict.Add(DrawMode.TriangleStripAdjacency, new ZeroIndexLineInTriangleStripAdjacencySearcher()); dict.Add(DrawMode.TriangleFan, new ZeroIndexLineInTriangleFanSearcher()); dict.Add(DrawMode.Quads, new ZeroIndexLineInQuadSearcher()); dict.Add(DrawMode.QuadStrip, new ZeroIndexLineInQuadStripSearcher()); dict.Add(DrawMode.Polygon, new ZeroIndexLineInPolygonSearcher()); lineSearcherDict = dict; } ZeroIndexLineSearcher result = null; if (lineSearcherDict.TryGetValue(mode, out result)) { return(result); } else { return(null); } }
/// <summary> /// Search line in triangles/triangle_strip/triangle_fan/ /// triangles_adjacency/triangle_strip_adjacency/ /// quads/quad_strip/polygon /// </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 SearchLine(RenderEventArgs arg, uint stageVertexId, int x, int y, uint lastVertexId, ZeroIndexLineSearcher searcher) { var vertexIds = searcher.Search(arg, x, y, lastVertexId, this); var positions = FillPickedGeometrysPosition(vertexIds); var pickedGeometry = new PickedGeometry(PickingGeometryType.Line, positions, vertexIds, stageVertexId, this); return(pickedGeometry); }
/// <summary> /// Search line in triangles/triangle_strip/triangle_fan/ /// triangles_adjacency/triangle_strip_adjacency/ /// quads/quad_strip/polygon /// </summary> /// <param name="arg"></param> /// <param name="stageVertexId"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="lastVertexId"></param> /// <param name="searcher"></param> /// <returns></returns> private PickedGeometry SearchLine(RenderEventArgs arg, uint stageVertexId, int x, int y, uint lastVertexId, ZeroIndexLineSearcher searcher) { PickedGeometry pickedGeometry = new PickedGeometry(); pickedGeometry.From = this; pickedGeometry.GeometryType = GeometryType.Line; pickedGeometry.StageVertexId = stageVertexId; pickedGeometry.VertexIds = searcher.Search(arg, x, y, lastVertexId, this); pickedGeometry.Positions = FillPickedGeometrysPosition(pickedGeometry.VertexIds); return(pickedGeometry); }
/// <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)); } } }
private static ZeroIndexLineSearcher GetLineSearcher(DrawMode mode) { ZeroIndexLineSearcher 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 = lineInTriangles; break; case DrawMode.TriangleStrip: result = lineInTriangleStrip; break; case DrawMode.TriangleFan: result = lineInTriangleFan; break; case DrawMode.Quads: result = lineInQuads; break; case DrawMode.QuadStrip: result = lineInQuadStrip; break; case DrawMode.Polygon: result = lineInPolygon; break; case DrawMode.LinesAdjacency: result = null; break; case DrawMode.LineStripAdjacency: result = null; break; case DrawMode.TrianglesAdjacency: result = lineInTrianglesAdjacency; break; case DrawMode.TriangleStripAdjacency: result = lineInTriangleStripAdjacency; break; case DrawMode.Patches: result = null; break; default: result = null; break; } return(result); }
/// <summary> /// Search line in triangles/triangle_strip/triangle_fan/ /// triangles_adjacency/triangle_strip_adjacency/ /// quads/quad_strip/polygon /// </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 SearchLine(RenderEventArgs arg, uint stageVertexId, int x, int y, uint lastVertexId, ZeroIndexLineSearcher searcher) { var vertexIds = searcher.Search(arg, x, y, lastVertexId, this); var positions = FillPickedGeometrysPosition(vertexIds); var pickedGeometry = new PickedGeometry(arg.UsingViewPort, PickingGeometryType.Line, positions, vertexIds, stageVertexId, this); return pickedGeometry; }
private static ZeroIndexLineSearcher GetLineSearcher(DrawMode mode) { ZeroIndexLineSearcher 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 = lineInTriangles; break; case DrawMode.TriangleStrip: result = lineInTriangleStrip; break; case DrawMode.TriangleFan: result = lineInTriangleFan; break; case DrawMode.Quads: result = lineInQuads; break; case DrawMode.QuadStrip: result = lineInQuadStrip; break; case DrawMode.Polygon: result = lineInPolygon; break; case DrawMode.LinesAdjacency: result = null; break; case DrawMode.LineStripAdjacency: result = null; break; case DrawMode.TrianglesAdjacency: result = lineInTrianglesAdjacency; break; case DrawMode.TriangleStripAdjacency: result = lineInTriangleStripAdjacency; break; case DrawMode.Patches: result = null; break; default: throw new NotDealWithNewEnumItemException(typeof(DrawMode)); } return(result); }
/// <summary> /// Search line in triangles/triangle_strip/triangle_fan/ /// triangles_adjacency/triangle_strip_adjacency/ /// quads/quad_strip/polygon /// </summary> /// <param name="arg"></param> /// <param name="stageVertexId"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="lastVertexId"></param> /// <param name="searcher"></param> /// <returns></returns> private PickedGeometry SearchLine(RenderEventArg arg, uint stageVertexId, int x, int y, uint lastVertexId, ZeroIndexLineSearcher searcher) { PickedGeometry pickedGeometry = new PickedGeometry(); pickedGeometry.From = this; pickedGeometry.GeometryType = GeometryType.Line; pickedGeometry.StageVertexId = stageVertexId; pickedGeometry.Indexes = searcher.Search(arg, x, y, lastVertexId, this); pickedGeometry.Positions = FillPickedGeometrysPosition(pickedGeometry.Indexes); return pickedGeometry; }