``````Plane * planes [MAX_VERTICES];
// planes, build on vertices and org int numPlanes; public:
Frustrum ();
Frustrum ( const Vector3D& theOrg, int num,
const Vector3D * v ); Frustrum ( const Frustrum& frustrum ) ,--Frustrum ()
{
reset ();
}
void set ( const Vector3D& theOrg, int num, const Vector3D * v );
Plane * getNearPlane () const {
return nearPlane;
}
void setNearPlane ( const Plane& p ) {
delete nearPlane;
nearPlane = new Plane ( p );
}
Plane * getFarPlane () const {
return farPlane;
}``````
``````void setFarPlane ( const Plane& p ) {
delete farPlane,-
farPlane = new Plane ( p );
}
void reset () {
delete farPlane; delete nearPlane;
for ( int i = 0; i < numPlanes; i++ ) delete planes [i];
numPlanes = 0; farPlane = NULL; nearPlane = NULL;
}
int getNumPlanes () const {
return numPlanes;
}
Plane * getPlane ( int index ) const {
return index >= 0 && index < numPlanes ? planes [index] : NULL;
}
bool contains ( const Vector3D& v ) const {
for ( register int i = 0; i < numPlanes; i++ )
if ( planes [i] -> classify ( v ) == IN_BACK ) return false;
if ( nearPlane != NULL )
if ( nearPlane -> classify ( v ) == IN_BACK ) return false;
if ( farPlane != NULL )
if ( farPlane -> classify ( v ) == IN_BACK ) return false;
return true;
}``````

## Простейшие геометрические алгоритмы и структуры

``````bool contains ( const BoundingBox& box ) const {
for ( register int i = 0; i < numPlanes; i++ )
if ( box.classify ( * planes [i] ) == IN_BACK ) return false;
if ( nearPlane != NULL )
if ( box.classify ( *nearPlane ) == IN_BACK ) return false;
if ( farPlane != NULL )
if ( box.classify ( *farPlane ) == IN_BACK ) return false;
return true;
}
bool containslnside ( const BoundingBox& box ) const {
for ( register int i = 0; i < numPlanes; i++ )
if ( box.classify ( *planes [i] ) != IN_FRONT ) return false;
if ( box.classify ( *nearPlane ) != IN_FRONT ) return false;
if ( box.classify ( *farPlane ) != IN_FRONT ) return false;``````

⇐ Предыдущая| |Следующая ⇒