public void PositionRaysForFarPosition() { Vector3 planeNormal = Lens.GetPlaneNormal(); Vector3 lensPosition = Lens.transform.localPosition; Vector3 parallelDirection = lensPosition - Target.transform.localPosition; parallelDirection.y = 0; Vector3 parallelHit = GetPlaneLineIntersection(planeNormal, lensPosition, FarOriginPoint, parallelDirection); Vector3 antifocusDirection = Lens.GetAntiFocusPosition() - FarOriginPoint; Vector3 antifocusHit = GetPlaneLineIntersection(planeNormal, lensPosition, FarOriginPoint, antifocusDirection); ConvergingPoint = CalculateLinesIntersection( parallelHit, Lens.GetFocusPosition(), antifocusHit, antifocusHit + parallelDirection ); ParallelRay.GetComponent <TubeRenderer>().SetPositions( new Vector3[] { FarOriginPoint, parallelHit, ConvergingPoint } ); CenterRay.GetComponent <TubeRenderer>().SetPositions( new Vector3[] { FarOriginPoint, ConvergingPoint } ); AntiFocalRay.GetComponent <TubeRenderer>().SetPositions( new Vector3[] { FarOriginPoint, antifocusHit, ConvergingPoint } ); ParallelVirtualRay.SetActive(false); AntiFocalVirtualRay.SetActive(false); CenterVirtualRay.SetActive(false); }
public void Initialize(GameObject target, ConvexMirrorBehaviour mirror) { this.Target = target; this.Mirror = mirror; ParallelRay = CreateRay("Parallel Ray"); CenterRay = CreateRay("Center Ray"); CenterRay.SetActive(false); FocalRay = CreateRay("Focal Ray"); ParallelVirtualRay = CreateVirtualRay("Parallel Virtual Ray"); CenterVirtualRay = CreateVirtualRay("Center Virtual Ray"); CenterVirtualRay.SetActive(false); FocalVirtualRay = CreateVirtualRay("Focal Virtual Ray"); PositionRays(); }