4

I understand that CalculateFrustumPlanes() in Unity3D returns an array of Plane objects, each representing a different frustum plane, but I can't find any documentation to suggest which element is which?

for example

[0] = Front  
[1] = Back

etc.

I need to calculate whether a point in space (like the centre point of a Bounding volume) is in the camera frustum, for a Quad tree system.

Heisenbug
  • 38,762
  • 28
  • 132
  • 190
Alex Hopkins
  • 872
  • 9
  • 11

2 Answers2

3

What is exactly the order of the Planes in the returned array is not documented (and I don't know it).

Anyway I think you can figure it out without much effort: you just need to put the camera in a well know orientation and check the normal value's of each Plane.

I need to calculate whether a point in space (like the centre point of a Bounding volume) is in the camera frustum, for a Quad tree system.

For a Quad Tree system, I think the intersection between the frustum and a GameObject's AABB is enough, so you don't even need to know exactly the order of the Plane's in the array to compute it. You can just use GeometryUtility.TestPlanesAABB.

Heisenbug
  • 38,762
  • 28
  • 132
  • 190
  • 2
    Also easy, [Camera.WorldToViewportPoint](http://docs.unity3d.com/Documentation/ScriptReference/Camera.WorldToViewportPoint.html)(center_point) If viewportPoint x/y are outside [0,1], point is not in frustum (or if z is negative) – Jerdak May 13 '13 at 03:39
  • @Jerdak: I think Camera.WorldToViewPoint could have even better performances in this case. – Heisenbug May 13 '13 at 08:02
  • Sure, a couple less divisions. I was too lazy to type 'if point x/y are inside [0,0] to [pixelWidth,pixelHeight].' :) – Jerdak May 13 '13 at 12:35
3

Order: left, right, bottom, top, near, far.

jew
  • 31
  • 2