Quantcast
Channel: Answers by "KevinCodes4Food"
Viewing all articles
Browse latest Browse all 30

Answer by KevinCodes4Food

$
0
0
The answer proved by AlwaysSunny above recommends checking the normal of each plane against the camera's forward. Unfortunately, the near and far planes have the same forward :( The easiest solution I have found is to move each plane along the normal. Then I look at the location of the plane relative to the camera's position while the camera is at a zeroed rotational position: GameObject[] frustumBounginObjects = new GameObject[6]; public void CreateScreenBoundingObjects () { Camera cam = Camera.main; Plane[] frustumPlanes = GeometryUtility.CalculateFrustumPlanes(cam); for (int i=0; i < frustumPlanes.Length; ++i) { frustumBounginObjects[i] = GameObject.CreatePrimitive(PrimitiveType.Plane); frustumBounginObjects[i].transform.position = -frustumPlanes[i].normal * frustumPlanes[i].distance; // Which plane? if(frustumBounginObjects[i].transform.position.y > 0) // Top? { frustumBounginObjects[i].name = "Top"; } else if(frustumBounginObjects[i].transform.position.y < 0) // Bottom? { frustumBounginObjects[i].name = "Bottom"; } else if(frustumBounginObjects[i].transform.position.x > 0) // Right? { frustumBounginObjects[i].name = "Right"; } else if(frustumBounginObjects[i].transform.position.x < 0) // Left? { frustumBounginObjects[i].name = "Left"; } else if(frustumBounginObjects[i].transform.position.z > Camera.main.nearClipPlane) // Far? { frustumBounginObjects[i].name = "Far"; } else // Near? { frustumBounginObjects[i].name = "Near"; } frustumBounginObjects[i].name += "Plane "; } }

Viewing all articles
Browse latest Browse all 30

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>