/// Resize shape, so it fits recognition square. /// If square is 10x10, then coordinates are -5..5, -5..5 private static List <Vector3> ResizeShapeToFitRecognitionSquare(List <Vector3> points) { List <Vector3> resizedPoints = new List <Vector3>(points.Count); SymbolSize initialSize = SymbolsHelper.GetWidthAndHeightOfShape(points); for (int i = 0; i != points.Count; i++) { resizedPoints.Add(points[i] * (RecognitionSquareDimension / initialSize.MaxDimension)); } return(resizedPoints); }
public static CustomSymbol CreateSymbol(List <Vector3> points) { List <Vector3> correctedCountPoints = CorrectPointsCount(points); Vector3 spellCenter = SymbolsHelper.CalculateSymbolCenter(correctedCountPoints); Basis basisBasedOnPlayerSight = CreateBasisBasedOnPlayerSight(spellCenter, Player.instance.headCollider.transform.position); Basis basisToProjectPointsToXyPlane = CreateBasisToProjectPointsToXyPlane(basisBasedOnPlayerSight); List <Vector3> poitnsProjectedToPlaneInPlayerSightBasis = MathHelper.ProjectPointsToPlane(correctedCountPoints, spellCenter, basisBasedOnPlayerSight.Forward); List <Vector3> pointsProjectedToXyPlane = ProjectPointsToXyPlane(poitnsProjectedToPlaneInPlayerSightBasis, spellCenter, basisToProjectPointsToXyPlane); List <Vector3> resizedPoints = ResizeShapeToFitRecognitionSquare(pointsProjectedToXyPlane); SymbolAnalyzerResult result = SymbolAnalyzer.Instance.Analyze(resizedPoints); CustomSymbol newSymbol = new CustomSymbol(); newSymbol.Type = result.IsPassed() ? result.SymbolType : SymbolType.Unrecognized; newSymbol.Center = spellCenter; newSymbol.Orientation = basisBasedOnPlayerSight; newSymbol.Size = SymbolsHelper.GetWidthAndHeightOfShape(pointsProjectedToXyPlane).MaxDimension; return(newSymbol); }