Changeset 9147 in orxonox.OLD for branches/terrain/src/lib/graphics/importer
- Timestamp:
- Jul 4, 2006, 3:45:43 PM (18 years ago)
- Location:
- branches/terrain/src/lib/graphics/importer
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/terrain/src/lib/graphics/importer/md3/md3_animation_cfg.cc
r8724 r9147 87 87 88 88 // parse file 89 while( (read = getline(&cLine, &len, pFile)) != -1) { /*( !this->dataStream.eof()) {*/ 89 /* 90 while( (read = getline(&cLine, &len, pFile)) != -1) { 91 // ( !this->dataStream.eof()) { 90 92 std::string line(cLine); 91 93 … … 176 178 } 177 179 } 178 } 180 }*/ 179 181 } 180 182 -
branches/terrain/src/lib/graphics/importer/terrain/frustum.h
r9140 r9147 15 15 #ifndef _FRUSTUM_H 16 16 #define _FRUSTUM_H 17 #include "plane.h" 18 #include "vector.h" 17 19 #include "types.h" 18 20 #include "glincl.h" … … 71 73 72 74 // is the positive vertex outside? 73 if ( planes[i].distance ( _box.vertexP( planes[i].n ) ) < 0 )75 if ( planes[i].distancePoint( _box.vertexP( planes[i].n ) ) < 0 ) 74 76 return OUTSIDE; 75 77 // is the negative vertex outside? 76 else if ( planes[i].distance ( _box.vertexN( planes[i].n ) ) < 0 )78 else if ( planes[i].distancePoint( _box.vertexN( planes[i].n ) ) < 0 ) 77 79 result = INTERSECT; 78 80 } … … 80 82 } 81 83 82 inline int pointInFrustum( const Triple& _point)84 inline int pointInFrustum( const Vector& _point) 83 85 { 84 86 int result = INSIDE; 85 87 for(int i=0; i < 6; i++) { 86 if (planes[i].distance ( _point ) < 0)88 if (planes[i].distancePoint( _point ) < 0) 87 89 return OUTSIDE; 88 90 } … … 91 93 92 94 inline Plane getPlane( int _plane ) { return planes[_plane]; } 95 93 96 inline void setFrustum( float *_m ) 94 97 { 95 planes[NEAR].setCoefficients( m(2,0) + m(3,0), 96 m(2,1) + m(3,1), 97 m(2,2) + m(3,2), 98 m(2,3) + m(3,3)); 99 planes[FAR].setCoefficients( -m(2,0) + m(3,0), 100 -m(2,1) + m(3,1), 101 -m(2,2) + m(3,2), 102 -m(2,3) + m(3,3)); 103 planes[BOTTOM].setCoefficients( m(1,0) + m(3,0), 104 m(1,1) + m(3,1), 105 m(1,2) + m(3,2), 106 m(1,3) + m(3,3)); 107 planes[TOP].setCoefficients( -m(1,0) + m(3,0), 108 -m(1,1) + m(3,1), 109 -m(1,2) + m(3,2), 110 -m(1,3) + m(3,3)); 111 planes[LEFT].setCoefficients( m(0,0) + m(3,0), 112 m(0,1) + m(3,1), 113 m(0,2) + m(3,2), 114 m(0,3) + m(3,3)); 115 planes[RIGHT].setCoefficients(-m(0,0) + m(3,0), 116 -m(0,1) + m(3,1), 117 -m(0,2) + m(3,2), 118 -m(0,3) + m(3,3)); 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 m(2,3) + m(3,3) ); 103 104 planes[FAR] = Plane( Vector( 105 -m(2,0) + m(3,0), 106 -m(2,1) + m(3,1), 107 -m(2,2) + m(3,2) ), 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) ), 114 m(1,3) + m(3,3) ); 115 planes[TOP] = Plane( Vector( 116 -m(1,0) + m(3,0), 117 -m(1,1) + m(3,1), 118 -m(1,2) + m(3,2) ), 119 -m(1,3) + m(3,3) ); 120 planes[LEFT] = Plane( Vector( 121 m(0,0) + m(3,0), 122 m(0,1) + m(3,1), 123 m(0,2) + m(3,2) ), 124 m(0,3) + m(3,3) ); 125 planes[RIGHT] = Plane( Vector( 126 -m(0,0) + m(3,0), 127 -m(0,1) + m(3,1), 128 -m(0,2) + m(3,2) ), 129 -m(0,3) + m(3,3) ); 119 130 120 if ( planes[NEAR]. d +planes[FAR].d> MAX_CLIP_DISTANCE ) {121 planes[FAR]. d = -planes[NEAR].d+MAX_CLIP_DISTANCE;131 if ( planes[NEAR].k +planes[FAR].k > MAX_CLIP_DISTANCE ) { 132 planes[FAR].k = -planes[NEAR].k+MAX_CLIP_DISTANCE; 122 133 } 123 134 } -
branches/terrain/src/lib/graphics/importer/terrain/terrain.cc
r9140 r9147 97 97 pTerrainPage newPage = new TerrainPage( const_cast<Terrain*>( this ), _xOffset, _zOffset ); 98 98 newPage->setScale( scale ); 99 newPage->setPosition( Triple( scale.x*_xOffset, 0.0f, scale.z*_zOffset ) );99 newPage->setPosition( Vector( scale.x*_xOffset, 0.0f, scale.z*_zOffset ) ); 100 100 newPage->calculateErrors(); 101 101 return newPage; … … 248 248 //Due to some reason, the OpenGL implementors chose the plane equation 249 249 //to an array of doubles. So we will make them happy. 250 double farPlane[] = { far.n.x, far.n.y, far.n.z, far. d};250 double farPlane[] = { far.n.x, far.n.y, far.n.z, far.k }; 251 251 glEnable( GL_CLIP_PLANE0 ); 252 252 glClipPlane( GL_CLIP_PLANE0, farPlane ); … … 419 419 } 420 420 421 void Terrain::getAltitude( Triple& _alt, Triple& _normal )421 void Terrain::getAltitude( Vector& _alt, Vector& _normal ) 422 422 { 423 423 float xScaled = _alt.x / scale.x, zScaled = _alt.z / scale.z; -
branches/terrain/src/lib/graphics/importer/terrain/terrain.h
r9140 r9147 21 21 #include "buffer_broker.h" 22 22 #endif 23 #include "types.h" 23 24 #include "vector.h" 24 25 #include "terrain_page.h" 25 26 #include "terrain_quad.h" … … 30 31 #include "frustum.h" 31 32 33 class Texture; 32 34 class Terrain; 33 35 typedef Terrain *pTerrain; … … 53 55 54 56 55 inline void setCameraPosition( const Triple& _cameraPosition )57 inline void setCameraPosition( const Vector& _cameraPosition ) 56 58 { 57 59 cameraPosition = _cameraPosition; 58 60 } 59 61 60 inline const Triple& getCameraPosition() const62 inline const Vector& getCameraPosition() const 61 63 { 62 64 return cameraPosition; 63 65 } 64 66 65 void getAltitude( Triple& _alt, Triple& _normal );67 void getAltitude( Vector& _alt, Vector& _normal ); 66 68 67 69 inline void setLightmap( Texture *_lightmap ) … … 86 88 current = 0; 87 89 activePages = NULL; 88 scale = Triple( 1.0f, 3.0f, 1.0f );90 scale = Vector( 1.0f, 3.0f, 1.0f ); 89 91 frustum = new Frustum(); 90 92 activatedCount = deactivatedCount = 0; … … 114 116 void draw( ); 115 117 116 void setPageSize( const Triple& _page ) { }118 void setPageSize( const Vector& _page ) { } 117 119 118 120 void build(); … … 146 148 } 147 149 148 inline const TriplegetScale() const { return scale; }150 inline const Vector getScale() const { return scale; } 149 151 150 152 inline int getPageSize() const … … 159 161 } 160 162 161 inline void setScale( const Triple& _scale )163 inline void setScale( const Vector& _scale ) 162 164 { scale = _scale; } 163 165 #ifdef USE_VBO … … 197 199 Texture *lightmap; 198 200 Heightfield heightfield; 199 Triplescale;201 Vector scale; 200 202 int pagesX, 201 203 pagesZ; … … 213 215 std::vector<BufferInfo> buffers; 214 216 215 TriplecameraPosition;217 Vector cameraPosition; 216 218 pFrustum frustum; 217 219 pTerrainPage activePages; -
branches/terrain/src/lib/graphics/importer/terrain/terrain_page.cc
r9140 r9147 46 46 layerVisibility[i] = LV_NO; 47 47 48 position = Triple( scale.x*_xOffset,48 position = Vector( scale.x*_xOffset, 49 49 0.0f, scale.z*_zOffset ); 50 50 isVisible = false; … … 129 129 { 130 130 wantedLOD = -1; 131 Triplecam( owner->getCameraPosition() );131 Vector cam( owner->getCameraPosition() ); 132 132 133 133 for ( int i = TerrainPage::MAX_LODS-1; i >= 0; --i ) { 134 Tripledistance( cam.x-errors[i].correct.x,134 Vector distance( cam.x-errors[i].correct.x, 135 135 cam.y-errors[i].correct.y, 136 136 cam.z-errors[i].correct.z ); 137 137 138 float d = distance.len gth();138 float d = distance.len(); 139 139 140 140 float err = errors[i].diff / d ; … … 230 230 float alt = 0.0f; 231 231 232 Triplemin( xOffset*scale.x ,0.0f, zOffset*scale.z ),232 Vector min( xOffset*scale.x ,0.0f, zOffset*scale.z ), 233 233 max( (xOffset+1)*scale.x, 0.0f, (zOffset+1)*scale.z); 234 234 … … 774 774 } 775 775 776 void TerrainPage::getVertex( int _x, int _z, Triple& _vertex ) const776 void TerrainPage::getVertex( int _x, int _z, Vector& _vertex ) const 777 777 { 778 778 _vertex.x = position.x+scale.x*_x/ -
branches/terrain/src/lib/graphics/importer/terrain/terrain_page.h
r9140 r9147 28 28 struct Vertex { 29 29 TexCoord t; 30 Triplep;30 Vector p; 31 31 }; 32 32 … … 34 34 35 35 typedef struct { 36 Triplecorrect;37 Triplereal;36 Vector correct; 37 Vector real; 38 38 float diff; 39 39 } LODError, *pLODError; … … 159 159 * Sets the position of the TerrainPage. Is this needed? 160 160 */ 161 inline void setPosition( const Triple& _pos )161 inline void setPosition( const Vector& _pos ) 162 162 { 163 163 position.x = _pos.x; … … 250 250 * Fills _vertex with the vertex information at index. 251 251 */ 252 void getVertex( int _x, int _z, Triple& _vertex ) const;252 void getVertex( int _x, int _z, Vector& _vertex ) const; 253 253 254 254 /** … … 288 288 pTerrainPage previous; 289 289 LODError *errors; 290 Tripleposition;290 Vector position; 291 291 }; 292 292 -
branches/terrain/src/lib/graphics/importer/terrain/terrain_quad.cc
r9140 r9147 47 47 exit( 0 ); 48 48 } 49 Triple min = Triple( children[BL_CHILD]->getBounds().min() );50 Triple max = Triple( children[TR_CHILD]->getBounds().max() );49 Vector min = Vector( children[BL_CHILD]->getBounds().min() ); 50 Vector max = Vector( children[TR_CHILD]->getBounds().max() ); 51 51 for ( int i = 1; i < 4; ++i ) { 52 52 pTerrainQuad child = children[i]; -
branches/terrain/src/lib/graphics/importer/terrain/terrain_quad.h
r9140 r9147 66 66 return children[_child]; 67 67 } 68 inline void setScale( Triple_scale )68 inline void setScale( Vector _scale ) 69 69 { 70 70 scale = _scale; … … 94 94 int xOffset, zOffset; 95 95 int width, height; 96 Triplescale;96 Vector scale; 97 97 pTerrainQuad children[4]; 98 98 ABox bounds; -
branches/terrain/src/lib/graphics/importer/terrain/types.h
r9140 r9147 26 26 #define SAVE_DELETE( _a ) if ( _a ) { delete _a; _a = NULL; } 27 27 28 struct Triple29 {30 Triple( float _x, float _y, float _z )31 {32 x = _x; y = _y; z = _z;33 }34 Triple() { x = y = z = 0.0f; }35 inline float length() const36 { return sqrt( x*x+y*y+z*z ); }37 float x, y, z;38 };39 40 28 struct TexCoord 41 29 { … … 54 42 { 55 43 56 ABox( Triple _min, Triple_max)44 ABox( Vector _min, Vector _max) 57 45 { 58 46 corner = _min; … … 64 52 ABox() 65 53 { 66 corner = Triple( 0.0f, 0.0f, 0.0f );54 corner = Vector( 0.0f, 0.0f, 0.0f ); 67 55 x = y = z = 0.0f; 68 56 } 69 inline void set( const Triple& _min, const Triple& _max )57 inline void set( const Vector& _min, const Vector& _max ) 70 58 { 71 59 setMin( _min ); setMax( _max ); 72 60 } 73 inline void setMax( const Triple& _max )61 inline void setMax( const Vector& _max ) 74 62 { 75 63 x = _max.x-corner.x; … … 77 65 z = _max.z-corner.z; 78 66 } 79 inline void setMin( const Triple& _min )67 inline void setMin( const Vector& _min ) 80 68 { 81 69 corner = _min; 82 70 } 83 inline Triple vertexP( const Triple& _normal ) const71 inline Vector vertexP( const Vector& _normal ) const 84 72 { 85 Tripleres = corner;73 Vector res = corner; 86 74 if ( _normal.x > 0 ) 87 75 res.x+= x; … … 93 81 return res; 94 82 } 95 inline Triple vertexN( const Triple& _normal ) const83 inline Vector vertexN( const Vector& _normal ) const 96 84 { 97 Tripleres = corner;85 Vector res = corner; 98 86 if ( _normal.x < 0 ) 99 87 res.x+= x; … … 106 94 107 95 } 108 inline Triple min() const { return Triple(corner); }109 inline Triple max() const { return Triple( corner.x+x, corner.y+y, corner.z+z ); }110 Triplecorner;96 inline Vector min() const { return Vector(corner); } 97 inline Vector max() const { return Vector( corner.x+x, corner.y+y, corner.z+z ); } 98 Vector corner; 111 99 float x, y, z; 112 100 … … 115 103 // struct Plane 116 104 // { 117 // Plane() { n = Triple( 0.0f, 1.0f, 0.0f ); d = 0.0f; }105 // Plane() { n = Vector( 0.0f, 1.0f, 0.0f ); d = 0.0f; } 118 106 // inline void setCoefficients( float _nx, float _ny, float _nz, float _d ) 119 107 // { 120 // n = Triple( _nx, _ny, _nz );108 // n = Vector( _nx, _ny, _nz ); 121 109 // float l = n.length(); 122 110 // n.x /= l; n.y/=l; n.z/=l; 123 111 // d = _d/l; 124 112 // } 125 // inline float distance( const Triple& _point ) const113 // inline float distance( const Vector& _point ) const 126 114 // { 127 115 // return _point.x*n.x+_point.y*n.y+_point.z*n.z+d; 128 116 // } 129 // Triplen;117 // Vector n; 130 118 // float d; 131 119 // };
Note: See TracChangeset
for help on using the changeset viewer.