// Pass in the render texture camera public ClipPlaneManager(Camera cam) { //Debug.Log("Cam name = " + cam.name); pos = cam.transform.position; up = cam.transform.up; forward = cam.transform.forward; right = cam.transform.right; deg = cam.fieldOfView / 2; dis = cam.farClipPlane; hypotenuse = dis / Mathf.Cos(Mathf.Deg2Rad * deg); opposite = Mathf.Sin(Mathf.Deg2Rad * deg) * hypotenuse; nearClipDis = cam.nearClipPlane; aspect = cam.aspect; //Debug.Log("Right vector is " + right); //Debug.Log("Up vector is " + up); //Debug.Log("Opposite is " + opposite); //Debug.Log("Degree is " + deg); //Debug.Log("Distance is " + dis); //Debug.Log("Hypotenuse is " + hypotenuse); //Debug.Log("ClipPlane Corner00 = " + calc00()); //Debug.Log("ClipPlane Corner01 = " + calc01()); //Debug.Log("ClipPlane Corner10 = " + calc10()); //Debug.Log("ClipPlane Corner11 = " + calc11()); clipPlane = new PlaneRect(calc00(), calc11(), -forward, false); }
public void UpdateInfo(Camera cam) { pos = cam.transform.position; up = cam.transform.up; forward = cam.transform.forward; right = cam.transform.right; deg = cam.fieldOfView / 2; dis = cam.farClipPlane; hypotenuse = dis / Mathf.Cos(Mathf.Deg2Rad * deg); opposite = Mathf.Sin(Mathf.Deg2Rad * deg) * hypotenuse; nearClipDis = cam.nearClipPlane; aspect = cam.aspect; //Debug.Log("Right vector is " + right); //Debug.Log("Up vector is " + up); //Debug.Log("Opposite is " + opposite); //Debug.Log("Degree is " + deg); //Debug.Log("Distance is " + dis); //Debug.Log("Hypotenuse is " + hypotenuse); clipPlane = new PlaneRect(calc00(), calc11(), -forward, false); //Debug.Log("deg = " + deg); //Debug.Log("New planeRect 00 = " + calc00()); //Debug.Log("New planeRect 11 = " + calc11()); //Debug.Log("opp = " + opposite); }
public PlaneRect(PlaneRect pr) { this.p00 = pr.p00; this.p01 = pr.p01; this.p10 = pr.p10; this.p11 = pr.p11; }
public void CopyTo(PlaneRect pr) { pr.p00 = this.p00; pr.p01 = this.p01; pr.p11 = this.p11; pr.p10 = this.p10; }
/// <summary> /// Generates a new plane from a given plane by shrinking the corners in /// to each other. This assumes a flat, level plane. /// </summary> /// <param name="plane"></param> /// <returns></returns> public PlaneRect ShrinkPlaneRect(PlaneRect plane, float shrinkFactor) { // Generate diagonal vectors for shrinking points Vector3 ULtoLR = plane.Corner10 - plane.Corner01; Vector3 LRtoUL = -ULtoLR; Vector3 LLtoUR = plane.Corner11 - plane.Corner00; Vector3 URtoLL = -LLtoUR; // Adjust the points that will make the new plane Vector3 newLL = plane.Corner00 + LLtoUR * shrinkFactor; Vector3 newUL = plane.Corner01 + ULtoLR * shrinkFactor; Vector3 newUR = plane.Corner11 + URtoLL * shrinkFactor; Vector3 newLR = plane.Corner10 + LRtoUL * shrinkFactor; // Make the new plane PlaneRect newPlane = new PlaneRect(newLL, newUL, newUR, newLR); Debug.Log("Shrunken plane LL = " + newLL); Debug.Log("Original plane LL = " + plane.Corner00); Debug.Log("Shrunken plane UL = " + newUL); Debug.Log("Original plane UL = " + plane.Corner01); Debug.Log("Shrunken plane UR = " + newUR); Debug.Log("Original plane UR = " + plane.Corner11); Debug.Log("Shrunken plane LR = " + newLR); Debug.Log("Original plane LR = " + plane.Corner10); return(newPlane); }
public static Vector2 UV(PlaneRect canvas, Vector3 pointOnCanvas) { Vector3 rightComp = pointOnCanvas - canvas.Corner00; float dot = Vector3.Dot(rightComp, canvas.Right); float u = dot / canvas.width; Vector3 upComp = pointOnCanvas - canvas.Corner00; dot = Vector3.Dot(upComp, canvas.Up); float v = dot / canvas.height; return(new Vector2(u, v)); }
public void Init() { //Debug.Log("Viewing cam clip plane corner01 = " + viewingCamManager.ViewingCameras[0].GetComponent<ClipPlaneManager>().ClipRect.Corner01); //Debug.Log("Clip planes array corner10 = " + viewingCamManager.ClipPlanes[0].clipPlane.Corner10); PlaneRect pr = GenerateAggregatePlaneRect(); GameObject go = GenerateAggregateClipPlaneObject(pr); go.transform.parent = gameObject.transform; InvokeRepeating("RefreshShaderInfo", 1.0f, 2.0f); //Invoke("RefreshShaderInfo", 2.0f); }
public Mesh GeneratePlaneMesh(PlaneRect plane) { if (plane != null) { Mesh planeMesh = new Mesh(); // Set mesh vertices List <Vector3> meshVertices = new List <Vector3>(); meshVertices.Add(plane.Corner00); // lower left meshVertices.Add(plane.Corner01); // upper left meshVertices.Add(plane.Corner11); // upper right meshVertices.Add(plane.Corner10); // lower right //Debug.Log("Plane corner 00 = " + plane.Corner00); //Debug.Log("Plane corner 01 = " + plane.Corner01); //Debug.Log("Plane corner 11 = " + plane.Corner11); //Debug.Log("Plane corner 10 = " + plane.Corner10); // Set mesh triangles int[] meshTriangles = new int[6]; meshTriangles[0] = 0; meshTriangles[1] = 1; meshTriangles[2] = 2; meshTriangles[3] = 0; meshTriangles[4] = 2; meshTriangles[5] = 3; planeMesh.SetVertices(meshVertices); planeMesh.SetTriangles(meshTriangles, 0); // Set the uv values List <Vector2> uvs = new List <Vector2>(); uvs.Add(new Vector2(0, 0)); uvs.Add(new Vector2(0, 1)); uvs.Add(new Vector2(1, 1)); uvs.Add(new Vector2(1, 0)); //planeMesh.uv = uvs.ToArray(); planeMesh.SetUVs(0, uvs); planeMesh.SetUVs(1, uvs); planeMesh.name = "PlaneMesh"; return(planeMesh); } else { Debug.LogError("Plane not created properly. Cannot construct plane mesh."); return(cubeMesh); } }
/// <summary> /// Impossible to fix with current implementation without tearing down the project and starting over. It seems that the representative plane constructed in teh viewing camera's uvcalc script is causing UV calculations to go awry. If we pushed the representative plane to be back as far as the main camera's interpolated plane, this should calculate correctly. However, I don't know what else this will mess up in my project's logic. /// </summary> public void AdjustViewingCams() { int numChildren = AggregateClipPlane.transform.childCount; if (numChildren.Equals(1) && AggregateClipPlane.transform.GetChild(0).gameObject.name.Equals(AggregateClipPlane.GetComponent <AggregateClipPlane>().PlaneName)) { for (int i = 0; i < viewingCamManager.ViewingCameras.Length; i++) { GameObject viewingCam = viewingCamManager.ViewingCameras[i]; Camera mainCam = MainCamera.GetComponent <Camera>(); //float mainCamPointOnPlane = (mainCam.transform.position + mainCam.transform.forward * mainCam.farClipPlane).x; PlaneRect viewingClipPlane = viewingCam.GetComponent <ClipPlaneManager>().ClipRect; //float oppositeOrig = Mathf.Abs(viewingClipPlane.Corner00.x - viewingClipPlane.center.x); float oppositeOrig = oppositeOrigs[i]; Ray ray = new Ray(viewingCam.transform.position, viewingCam.transform.forward); GameObject interpolatedPlane = AggregateClipPlane.transform.GetChild(0).gameObject; DebugPlaneRect dpr = interpolatedPlane.GetComponent <DebugPlaneRect>(); RaycastHit hit = dpr.Intersect(ray, viewingCam.transform.position); float adjacentNew = Mathf.Abs((hit.point - viewingCam.transform.position).magnitude); float theta = (Mathf.Tan(oppositeOrig / adjacentNew) * Mathf.Rad2Deg) * 2; if (theta != viewingCam.GetComponent <Camera>().fieldOfView) { //Debug.Log("Original opposite = " + oppositeOrig); //Debug.Log("Intersect hits at " + hit.point); Debug.Log("New adjacent value = " + adjacentNew); //Debug.Log("orig theta = " + viewingCam.GetComponent<Camera>().fieldOfView); Debug.Log("new theta = " + theta); //Debug.Log("Updating camera for " + viewingCam.name); } viewingCam.GetComponent <Camera>().fieldOfView = theta; viewingCam.GetComponent <ClipPlaneManager>().UpdateInfo(viewingCam.GetComponent <Camera>()); } } }
int IComparer <ClipPlaneManager> .Compare(ClipPlaneManager x, ClipPlaneManager y) { PlaneRect xRect = x.clipPlane; PlaneRect yRect = y.clipPlane; if (xRect.Corner00.x < yRect.Corner00.x) { return(-1); } else if (xRect.Corner00.x == yRect.Corner00.x) { if (xRect.center.x < yRect.Corner00.x) { return(-1); } else if (xRect.center.x == yRect.Corner00.x) { return(0); } else { return(1); } } else { return(1); } //if(xRect.center.x > yRect.center.x) //{ // return 1; //} //else if(xRect.center.x < yRect.center.x) //{ // return 1; //} //else //{ // return 0; //} }
public void Init() { SetMinMax(); GameObject mainCam = AggregateClipPlane.GetComponent <AggregateClipPlane>().MainCamera; origCamPos = new Vector3(mainCam.transform.position.x, mainCam.transform.position.y, mainCam.transform.position.z); PosX.value = origCamPos.x; PosY.value = origCamPos.y; PosZ.value = origCamPos.z; //Rotation.value = 0; int numChildren = AggregateClipPlane.transform.childCount; if (numChildren.Equals(1) && AggregateClipPlane.transform.GetChild(0).gameObject.name.Equals(AggregateClipPlane.GetComponent <AggregateClipPlane>().PlaneName)) { GameObject interpolatedPlane = AggregateClipPlane.transform.GetChild(0).gameObject; DebugPlaneRect dpr = interpolatedPlane.GetComponent <DebugPlaneRect>(); Vector3 planeCent = dpr.Center; origCent = new Vector3( planeCent.x, planeCent.y, planeCent.z); Debug.Log("origCent = " + origCent); origViewingCamDistanceRatios = new List <Vector3>(); for (int i = 0; i < viewingCamManager.ViewingCameras.Length; i++) { Vector3 simOrigCamPos = origCamPos - new Vector3(0, 0, -10); GameObject viewingCam = viewingCamManager.ViewingCameras[i]; Ray r = new Ray(simOrigCamPos, viewingCam.transform.position - simOrigCamPos); Vector3 pos = viewingCam.GetComponent <UVCalc>().IntersectRepresentativePlane(r, simOrigCamPos).point; Ray camRay = new Ray(simOrigCamPos, mainCam.transform.forward); Vector3 camPos = interpolatedPlane.GetComponent <UVCalc>().IntersectRepresentativePlane(camRay, simOrigCamPos).point; float ratioX = (viewingCam.transform.position.x - camPos.x) / (pos.x - camPos.x); float ratioY = (viewingCam.transform.position.y - camPos.y) / (pos.y - camPos.y); origViewingCamDistanceRatios.Add(new Vector3(ratioX, ratioY, 0)); } } else { origCent = new Vector3( origCamPos.x, origCamPos.y, mainCam.GetComponent <Camera>().farClipPlane); Debug.Log("origCent = " + origCent); } origObjScales = new List <Vector3>(); for (int i = 0; i < WorldObjectParent.transform.childCount; i++) { origObjScales.Add(WorldObjectParent.transform.GetChild(i).transform.localScale); } origCamPosList = new List <Vector3>(); for (int i = 0; i < viewingCamManager.ViewingCameras.Length; i++) { origCamPosList.Add(viewingCamManager.ViewingCameras[i].transform.position); } oppositeOrigs = new List <float>(); for (int i = 0; i < viewingCamManager.ViewingCameras.Length; i++) { PlaneRect viewingClipPlane = viewingCamManager.ViewingCameras[i].GetComponent <ClipPlaneManager>().ClipRect; Camera viewingCamCam = viewingCamManager.ViewingCameras[i].GetComponent <Camera>(); float oppositeOrig = Mathf.Abs(viewingClipPlane.Corner00.x - viewingClipPlane.center.x); oppositeOrigs.Add(oppositeOrig / viewingCamCam.aspect); Debug.Log("Corner00x = " + viewingClipPlane.Corner00.x); Debug.Log("centerx = " + viewingClipPlane.center.x); } //int numChildren = AggregateClipPlane.transform.childCount; //if(numChildren.Equals(1) // && AggregateClipPlane.transform.GetChild(0).gameObject.name.Equals(AggregateClipPlane.GetComponent<AggregateClipPlane>().PlaneName)) //{ //} //else //{ //} XField.text = PosX.value.ToString(); YField.text = PosY.value.ToString(); ZField.text = PosZ.value.ToString(); //RotField.text = Rotation.value.ToString(); initialized = true; }
public Vector2[] GenerateUV(int camIndex) { // Assumes LL, UL, UR, LR Vector2[] UVs = new Vector2[4]; GameObject viewingCam = viewingCamManager.ViewingCameras[camIndex]; UVCalc uvCalc = viewingCam.GetComponent <UVCalc>(); //ClipPlaneManager viewingCamClipPlane = viewingCamManager.ClipPlanes[camIndex]; //Vector3 origin = MainCamera.transform.position; Vector3 origin = viewingCam.transform.position; //PlaneRect aggregatePlane = aggregateClipPlane.GetComponent<AggregateClipPlane>().GenerateAggregatePlaneRect(viewingCamManager.ClipPlanes); Vector3[] aggregatePlaneVertices; bool interpolatedPlaneInitialized = aggregateClipPlane.transform.childCount == 1 && aggregateClipPlane.transform.GetChild(0).name.Equals(aggregateClipPlane.GetComponent <AggregateClipPlane>().PlaneName); if (interpolatedPlaneInitialized) { GameObject interpolatedPlane = aggregateClipPlane.transform.GetChild(0).gameObject; DebugPlaneRect dpr = interpolatedPlane.GetComponent <DebugPlaneRect>(); aggregatePlaneVertices = new Vector3[4] { dpr.LowerLeft, dpr.UpperLeft, dpr.UpperRight, dpr.LowerRight }; //Debug.Log("Taking UV values from Interpolated plane debug plane rectangle."); } else { PlaneRect aggregatePlane = aggregateClipPlane.GetComponent <AggregateClipPlane>().GenerateAggregatePlaneRect(); aggregatePlaneVertices = new Vector3[4] { aggregatePlane.Corner00, aggregatePlane.Corner01, aggregatePlane.Corner11, aggregatePlane.Corner10 }; Debug.Log("Taking UV values from uninitialized plane calculations."); } //Debug.Log("aggregatePlaneVertices[0] = " + aggregatePlaneVertices[0]); //Debug.Log("aggregatePlaneVertices[1] = " + aggregatePlaneVertices[1]); //Debug.Log("aggregatePlaneVertices[2] = " + aggregatePlaneVertices[2]); //Debug.Log("aggregatePlaneVertices[3] = " + aggregatePlaneVertices[3]); // Calculate the UV values of the aggregate plane in terms of the // UV for the clip plane of the given viewing camera clip plane. // This makes it so that the four corners of the aggregate plane // can be passed in as UV values and compared to each of the // textures in the texture array to determine easily if a given uv // value for the aggregate plane corresponds to a point on any of // the independent texture planes //Vector2 LL = uvCalc.UVOffCanvas(origin, viewingCamClipPlane.clipPlane.Corner00); //Vector2 UL = uvCalc.UVOffCanvas(origin, viewingCamClipPlane.clipPlane.Corner01); //Vector2 UR = uvCalc.UVOffCanvas(origin, viewingCamClipPlane.clipPlane.Corner11); //Vector2 LR = uvCalc.UVOffCanvas(origin, viewingCamClipPlane.clipPlane.Corner10); Vector2 LL = uvCalc.UVOffCanvas(origin, aggregatePlaneVertices[0]); // lower left Vector2 UL = uvCalc.UVOffCanvas(origin, aggregatePlaneVertices[1]); // upper left Vector2 UR = uvCalc.UVOffCanvas(origin, aggregatePlaneVertices[2]); // upper right Vector2 LR = uvCalc.UVOffCanvas(origin, aggregatePlaneVertices[3]); // lower right UVs[0] = LL; UVs[1] = UL; UVs[2] = UR; UVs[3] = LR; // update values shown on uvCalc script of viewing camera uvCalc.LowerLeft = LL; uvCalc.UpperLeft = UL; uvCalc.UpperRight = UR; uvCalc.LowerRight = LR; return(UVs); }
public void AssociatePlaneRect(PlaneRect pr) { this.planeRect = pr; Debug.Log("Plane Rect associated! Center = " + Center); }
// NOTE: If generating dynamic aggregate clip plane as originally intended, InterpolationManager's GenerateUV needs to call this instead of GenerateAggregatePlaneRect public PlaneRect GenerateAggregatePlaneRect(ClipPlaneManager[] clipPlanes)//, out Vector3 pos, out Vector3 forward) { // NOTE: If generating dynamic aggregate clip plane as originally intended, InterpolationManager's GenerateUV needs to call this instead of GenerateAggregatePlaneRect // Adjust all clipPlanes and viewing cameras to be in their starting position // ERROR TESTING // This is a bit of a hack to circumvent an issue encountered in ViewingCamManager in InitViewingCameras for (int i = 0; i < viewingCamManager.ViewingCameras.Length; i++) { GameObject viewingCam = viewingCamManager.ViewingCameras[i]; ClipPlaneManager clipPlane = viewingCam.GetComponent <ClipPlaneManager>(); // ERROR TESTING - this fix doesn't work either... //viewingCam.transform.Translate(viewingCamManager.CamStartingPositions[i]); //clipPlane.transform.Translate(viewingCamManager.CamStartingPositions[i]); } if (clipPlanes != null && clipPlanes.Length > 0) { List <ClipPlaneManager> clipPlaneList = ClipPlaneManager.SortClipPlanes(clipPlanes); ClipPlaneManager[] sortedClipPlanes = clipPlaneList.ToArray(); // Assumes all planes exist in the same plane and that they // are all horizontally aligned float leftX = sortedClipPlanes[0].clipPlane.Corner00.x; float rightX = sortedClipPlanes[0].clipPlane.Corner01.x; float bottomY = sortedClipPlanes[0].clipPlane.Corner00.y; float topY = sortedClipPlanes[0].clipPlane.Corner10.y; float z = sortedClipPlanes[0].clipPlane.Corner00.z; //Debug.Log("Sorted clip planes length = " + sortedClipPlanes.Length); //Debug.Log("Sorted clip planes:"); //Debug.Log("Sorted clip planes[0] corner00 = " + sortedClipPlanes[0].clipPlane.Corner00); //Debug.Log("Sorted clip planes[0] corner01 = " + sortedClipPlanes[0].clipPlane.Corner01); //Debug.Log("Sorted clip planes[0] corner11 = " + sortedClipPlanes[0].clipPlane.Corner11); //Debug.Log("Sorted clip planes[0] corner10 = " + sortedClipPlanes[0].clipPlane.Corner10); //Debug.Log("Unsorted clip planes[0] corner00 = " + clipPlanes[0].clipPlane.Corner00); //Debug.Log("Unsorted clip planes[0] corner01 = " + clipPlanes[0].clipPlane.Corner01); //Debug.Log("Unsorted clip planes[0] corner11 = " + clipPlanes[0].clipPlane.Corner11); //Debug.Log("Unsorted clip planes[0] corner10 = " + clipPlanes[0].clipPlane.Corner10); for (int i = 0; i < sortedClipPlanes.Length; i++) { Vector3[] corners = new Vector3[4] { sortedClipPlanes[i].clipPlane.Corner00, sortedClipPlanes[i].clipPlane.Corner01, sortedClipPlanes[i].clipPlane.Corner11, sortedClipPlanes[i].clipPlane.Corner10 }; foreach (Vector3 corner in corners) { if (corner.x < leftX) { leftX = corner.x; //Debug.Log(sortedClipPlanes[i].gameObject.name + "replaced leftX with: " + corner.x + " (" + corner + ")"); } if (corner.x > rightX) { rightX = corner.x; //Debug.Log(sortedClipPlanes[i].gameObject.name + "replaced rightX with: " + corner.x + " (" + corner + ")"); } if (corner.y < bottomY) { bottomY = corner.y; //Debug.Log(sortedClipPlanes[i].gameObject.name + "replaced bottomY with: " + corner.y + " (" + corner + ")"); } if (corner.y > topY) { topY = corner.y; //Debug.Log(sortedClipPlanes[i].gameObject.name + "replaced topY with: " + corner.y + " (" + corner + ")"); } } } PlaneRect newPlane = new PlaneRect( new Vector3(leftX, bottomY, z), // lower left new Vector3(leftX, topY, z), // upper left new Vector3(rightX, topY, z), // upper right new Vector3(rightX, bottomY, z) // lower right ); //int farRightIndex = sortedClipPlanes.Length - 1; //int farLeftIndex = 0; //ClipPlaneManager farLeft = sortedClipPlanes[farLeftIndex]; //ClipPlaneManager farRight = sortedClipPlanes[farRightIndex]; //PlaneRect newPlane = new PlaneRect( // farLeft.ClipRect.Corner00, // lower left // farLeft.ClipRect.Corner01, // upper left // farRight.ClipRect.Corner11, // upper right // farRight.ClipRect.Corner10 // lower right // ); //Debug.Log("Far Left C00 = " + farLeft.ClipRect.Corner00); //Debug.Log("Far Left C01 = " + farLeft.ClipRect.Corner01); //Debug.Log("Far Right C11 = " + farRight.ClipRect.Corner11); //Debug.Log("Far Right C10 = " + farRight.ClipRect.Corner10); //Debug.Log("New Plane Corner00 = " + newPlane.Corner00); //Debug.Log("New Plane Corner01 = " + newPlane.Corner01); //Debug.Log("New Plane Corner11 = " + newPlane.Corner11); //Debug.Log("New Plane Corner10 = " + newPlane.Corner10); // Generate a slightly shrunken plane for our purposes PlaneRect shrunkenPlane = ShrinkPlaneRect(newPlane, PlaneShrinkFactor); //// Form anchor for new plane (as if the image was projected from //// a camera at this point) //pos = farLeft.pos + ((farRight.pos - farLeft.pos) / 2.0f); //// ERROR TESTING - THIS NEEDS TO BE ADJUSTED TO ACCOUNT FOR STATES WHERE THE FORWARD DIRECTIONS ARE NOT THE SAME. //forward = farLeft.forward; return(shrunkenPlane); } else { //pos = Vector3.zero; //forward = new Vector3(0, 0, 1); return(null); } }
public GameObject GenerateAggregateClipPlaneObject(PlaneRect planeRect) { GameObject interpolatedPlane = new GameObject(); // Generate the plane rectangle Vector3 pos; Vector3 forward; //PlaneRect planeRect = GenerateAggregatePlaneRect(clipPlanes, out pos, out forward); //PlaneRect planeRect = GenerateAggregatePlaneRect(clipPlanes); DebugPlaneRect dpr = interpolatedPlane.AddComponent <DebugPlaneRect>(); // Allows for easy access to see where the dpr.SetCorners(planeRect.Corner00, planeRect.Corner01, planeRect.Corner11, planeRect.Corner10); dpr.AssociatePlaneRect(planeRect); // Add UVCalc script for easier UI control access and intersection calculation later var uvCalc = interpolatedPlane.AddComponent <UVCalc>(); uvCalc.SetRepresentativePlane(MainCamera.GetComponent <Camera>()); // Generate the mesh and object for the plane Mesh planeMesh = GeneratePlaneMesh(planeRect); var mf = interpolatedPlane.AddComponent <MeshFilter>(); mf.mesh = planeMesh; var mr = interpolatedPlane.AddComponent <MeshRenderer>(); // Set material Material planeMat = GeneratePlaneMaterial(); mr.material = planeMat; // Assign meta attributes interpolatedPlane.name = PlaneName; interpolatedPlane.layer = LayerManager.GetLayerMask(CloakLayers.TableView); // Adjust position and orientation of generated plane object // (Make it face the user (the forward used is the forward // of the other clip plane cameras to the clip planes. // The forward for this object has to be from the plane to // the "camera" it is associated with)) //aggregateClipPlane.transform.forward = -forward; //aggregateClipPlane.transform.position = pos + forward.normalized * FarClipDistance; interpolatedPlane.transform.position += -interpolatedPlane.transform.forward.normalized * PlanePullDistance; // -forward.normalized * 3.0f //Debug.Log("Aggregate calculated pos = " + aggregateClipPlane.transform.position); // set initialization flag appropriately if (planeRect != null && planeMesh != null && planeMat != null) { Debug.Log("Aggregate Clip Plane initialized"); initialized = true; } else { GameObject.Destroy(interpolatedPlane); } return(interpolatedPlane); }