Changeset 9415 in orxonox.OLD for branches/terrain/src/lib/graphics/importer/terrain/frustum.h
- Timestamp:
- Jul 24, 2006, 12:59:44 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/terrain/src/lib/graphics/importer/terrain/frustum.h
r9414 r9415 1 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 4 4 Copyright (C) 2006 orx 5 5 6 6 This program is free software; you can redistribute it and/or modify 7 7 it under the terms of the GNU General Public License as published by 8 8 the Free Software Foundation; either version 2, or (at your option) 9 9 any later version. 10 10 11 11 ### File Specific: 12 12 main programmer: Marco Biasini 13 13 14 14 */ 15 15 #ifndef _FRUSTUM_H … … 31 31 }\ 32 32 while ( 0 ) 33 34 /** 33 34 /** 35 35 * Code borrowed from Lighthouse 3D. Its a very good tutorial on culling. 36 36 */ … … 40 40 41 41 public: 42 42 43 43 enum { NEAR = 0 , FAR = 1, TOP = 2, BOTTOM = 3, LEFT = 4, RIGHT = 5 }; 44 enum { OUTSIDE, INTERSECT, INSIDE }; 45 44 enum { OUTSIDE, INTERSECT, INSIDE }; 45 46 46 Frustum() 47 47 { … … 65 65 setFrustum( combined ); 66 66 } 67 67 68 68 inline int boxInFrustum( const ABox& _box ) 69 69 { … … 75 75 if ( planes[i].distancePoint( _box.vertexP( planes[i].n ) ) < 0 ) 76 76 return OUTSIDE; 77 // is the negative vertex outside? 77 // is the negative vertex outside? 78 78 else if ( planes[i].distancePoint( _box.vertexN( planes[i].n ) ) < 0 ) 79 79 result = INTERSECT; … … 81 81 return result; 82 82 } 83 83 84 84 inline int pointInFrustum( const Vector& _point) 85 85 { … … 89 89 return OUTSIDE; 90 90 } 91 return result; 91 return result; 92 92 } 93 93 94 94 inline Plane getPlane( int _plane ) { return planes[_plane]; } 95 95 96 96 inline void setFrustum( float *_m ) 97 97 { 98 planes[NEAR] = Plane( Vector( 99 m(2,0) + m(3,0), 100 m(2,1) + m(3,1), 101 m(2,2) + m(3,2) ), 98 planes[NEAR] = Plane( Vector( 99 m(2,0) + m(3,0), 100 m(2,1) + m(3,1), 101 m(2,2) + m(3,2) ), 102 102 m(2,3) + m(3,3) ); 103 104 planes[FAR] = Plane( Vector( 103 104 planes[FAR] = Plane( Vector( 105 105 -m(2,0) + m(3,0), 106 106 -m(2,1) + m(3,1), 107 107 -m(2,2) + m(3,2) ), 108 108 -m(2,3) + m(3,3) ); 109 110 planes[BOTTOM] = Plane( Vector( 111 m(1,0) + m(3,0), 112 m(1,1) + m(3,1), 113 m(1,2) + m(3,2) ), 109 110 planes[BOTTOM] = Plane( Vector( 111 m(1,0) + m(3,0), 112 m(1,1) + m(3,1), 113 m(1,2) + m(3,2) ), 114 114 m(1,3) + m(3,3) ); 115 planes[TOP] = Plane( Vector( 115 planes[TOP] = Plane( Vector( 116 116 -m(1,0) + m(3,0), 117 117 -m(1,1) + m(3,1), 118 118 -m(1,2) + m(3,2) ), 119 119 -m(1,3) + m(3,3) ); 120 planes[LEFT] = Plane( Vector( 120 planes[LEFT] = Plane( Vector( 121 121 m(0,0) + m(3,0), 122 122 m(0,1) + m(3,1), 123 123 m(0,2) + m(3,2) ), 124 124 m(0,3) + m(3,3) ); 125 planes[RIGHT] = Plane( Vector( 125 planes[RIGHT] = Plane( Vector( 126 126 -m(0,0) + m(3,0), 127 127 -m(0,1) + m(3,1), 128 128 -m(0,2) + m(3,2) ), 129 129 -m(0,3) + m(3,3) ); 130 130 131 131 if ( planes[NEAR].k +planes[FAR].k > MAX_CLIP_DISTANCE ) { 132 132 planes[FAR].k = -planes[NEAR].k+MAX_CLIP_DISTANCE; 133 133 } 134 134 } 135 135 136 136 protected: 137 137 Plane *planes;
Note: See TracChangeset
for help on using the changeset viewer.