public override PickedGeometry GetPickedGeometry(RenderEventArgs arg, uint stageVertexId,
int x, int y)
{
uint lastVertexId;
if (!this.GetLastVertexIdOfPickedGeometry(stageVertexId, out lastVertexId))
{ return null; }
// 找到 lastIndexId
RecognizedPrimitiveInfo lastIndexId = this.GetLastIndexIdOfPickedGeometry(
arg, lastVertexId, x, y);
if (lastIndexId == null)
{
Debug.WriteLine(string.Format(
"Got lastVertexId[{0}] but no lastIndexId! Params are [{1}] [{2}] [{3}] [{4}]",
lastVertexId, arg, stageVertexId, x, y));
{ return null; }
}
PickingGeometryType geometryType = arg.PickingGeometryType;
DrawMode mode = this.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, x, y, 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, x, y, lastVertexId, 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)); }
}
}