#include <frustum.h>
Collaboration diagram for Frustum:

Public Types | |
| enum | { Bottom = 0, Top = 1, Left = 2, Right = 3, Near = 4, Far = 5 } |
| enum | Aspect { Outside = 0, Inside = 1, Intersect = 2 } |
Public Member Functions | |
| Frustum (float fov, float aspectRatio, float nearDist, float farDist) | |
| Frustum (float fov, float aspectRatio, float nearDist) | |
| Planef | getPlane (int) const |
| Aspect | test (const Point3f &) const |
| Aspect | testSphere (const Point3d ¢er, double radius) const |
| Aspect | testSphere (const Point3f ¢er, float radius) const |
| void | transform (const Mat4f &) |
| void | transform (const Mat3f &) |
Private Member Functions | |
| void | init (float, float, float, float) |
Private Attributes | |
| bool | infinite |
| Planef | planes [6] |
|
|
Definition at line 27 of file frustum.h. 00027 {
00028 Bottom = 0,
00029 Top = 1,
00030 Left = 2,
00031 Right = 3,
00032 Near = 4,
00033 Far = 5,
00034 };
|
|
|
Definition at line 36 of file frustum.h.
|
|
||||||||||||||||
|
Definition at line 13 of file frustum.cpp. References init().
|
|
||||||||||||||||||||
|
Definition at line 20 of file frustum.cpp. References init().
|
|
|
Definition at line 53 of file frustum.h. References planes. 00054 {
00055 return planes[which];
00056 }
|
|
||||||||||||||||||||
|
Definition at line 27 of file frustum.cpp. References Bottom, Far, Left, Near, Vector3< T >::normalize(), planes, Right, and Top. Referenced by Frustum(). 00028 {
00029 float h = (float) tan(fov / 2.0f);
00030 float w = h * aspectRatio;
00031
00032 Vec3f normals[4];
00033 normals[Bottom] = Vec3f(0, 1, -h);
00034 normals[Top] = Vec3f(0, -1, -h);
00035 normals[Left] = Vec3f(1, 0, -w);
00036 normals[Right] = Vec3f(-1, 0, -w);
00037 for (int i = 0; i < 4; i++)
00038 {
00039 normals[i].normalize();
00040 planes[i] = Planef(normals[i], Point3f(0, 0, 0));
00041 }
00042
00043 planes[Near] = Planef(Vec3f(0, 0, -1), -n);
00044 planes[Far] = Planef(Vec3f(0, 0, 1), f);
00045 }
|
|
|
Definition at line 48 of file frustum.cpp. References testSphere(). 00049 {
00050 return testSphere(p, 0);
00051 }
|
|
||||||||||||
|
Definition at line 72 of file frustum.cpp. References Plane< T >::d, infinite, Inside, Intersect, Plane< T >::normal, Outside, planes, Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z. 00073 {
00074 int nPlanes = infinite ? 5 : 6;
00075 int intersections = 0;
00076
00077 for (int i = 0; i < nPlanes; i++)
00078 {
00079 //TODO: Celestia should incorporate some casting operators overloading to accomodate all this kind of stuff:
00080 Vec3f plNormal = planes[i].normal;
00081 Vec3d plNormalDbl(plNormal.x, plNormal.y, plNormal.z);
00082
00083 double distanceToPlane = plNormalDbl.x * center.x + plNormalDbl.y * center.y + plNormalDbl.z * center.z + planes[i].d;
00084 if (distanceToPlane < -radius)
00085 return Outside;
00086 else if (distanceToPlane <= radius)
00087 intersections |= (1 << i);
00088 }
00089
00090 return (intersections == 0) ? Inside : Intersect;
00091 }
|
|
||||||||||||
|
Definition at line 54 of file frustum.cpp. References Plane< T >::distanceTo(), infinite, Inside, Intersect, Outside, and planes. Referenced by DSORenderer::process(), Renderer::render(), and test(). 00055 {
00056 int nPlanes = infinite ? 5 : 6;
00057 int intersections = 0;
00058
00059 for (int i = 0; i < nPlanes; i++)
00060 {
00061 float distanceToPlane = planes[i].distanceTo(center);
00062 if (distanceToPlane < -radius)
00063 return Outside;
00064 else if (distanceToPlane <= radius)
00065 intersections |= (1 << i);
00066 }
00067
00068 return (intersections == 0) ? Inside : Intersect;
00069 }
|
|
|
Definition at line 109 of file frustum.cpp. References Plane< T >::d, infinite, Vector3< T >::length(), Plane< T >::normal, and planes. 00110 {
00111 int nPlanes = infinite ? 5 : 6;
00112 Mat4f invTranspose = m.inverse().transpose();
00113
00114 for (int i = 0; i < nPlanes; i++)
00115 {
00116 planes[i] = planes[i] * invTranspose;
00117 float s = 1.0f / planes[i].normal.length();
00118 planes[i].normal = planes[i].normal * s;
00119 planes[i].d *= s;
00120 }
00121 }
|
|
|
Definition at line 104 of file frustum.cpp. Referenced by Renderer::renderObject(). 00105 {
00106 }
|
|
|
Definition at line 50 of file frustum.h. Referenced by testSphere(), and transform(). |
|
|
Definition at line 49 of file frustum.h. Referenced by getPlane(), init(), testSphere(), and transform(). |
1.4.1