Changeset 95
- Timestamp:
- Jun 3, 2005, 1:08:42 PM (19 years ago)
- Location:
- Swollen
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Swollen/doc/contract2_hours.txt
r90 r95 3 3 ------------------ 4 4 5 2 June, Thursday (2 hours) 6 - bedslope texture only used when specified 7 - almost finished image query of .sww global attributes 5 8 6 9 31 May, Tuesday (3 hours) -
Swollen/swollen/bedslope.cpp
r92 r95 48 48 osg::Texture2D* texture = new osg::Texture2D; 49 49 texture->setDataVariance( osg::Object::DYNAMIC ); 50 texture->setWrap( osg::Texture::WRAP_S, osg::Texture:: REPEAT);51 texture->setWrap( osg::Texture::WRAP_T, osg::Texture:: REPEAT);50 texture->setWrap( osg::Texture::WRAP_S, osg::Texture::CLAMP ); 51 texture->setWrap( osg::Texture::WRAP_T, osg::Texture::CLAMP ); 52 52 texture->setImage( _sww->getBedslopeTexture() ); 53 53 -
Swollen/swwreader/swwreader.cpp
r92 r95 4 4 Reader of SWW files from within OpenSceneGraph. 5 5 6 copyright (C) 2004 Geoscience Australia6 copyright (C) 2004-2005 Geoscience Australia 7 7 */ 8 8 … … 75 75 76 76 // sww file can optionally contain bedslope texture image filename 77 size_t attlen; 78 if( nc_inq_attlen(_ncid, NC_GLOBAL, " institution", &attlen) != NC_ENOTATT )77 size_t attlen; // length of text attribute (if it exists) 78 if( nc_inq_attlen(_ncid, NC_GLOBAL, "bedslope_image", &attlen) != NC_ENOTATT ) 79 79 { 80 std::string filename; 81 int nc_get_att_text(_ncid, NC_GLOBAL, "institution", char filename); 82 setBedslopeTexture( std::string filename ); 80 char* filename; 81 if( (filename = (char*) malloc(attlen+1)) != NULL){ 82 int status; 83 status = nc_get_att_text(_ncid, NC_GLOBAL, "bedslope_image", filename); 84 if( status == NC_NOERR ) 85 { 86 filename[attlen] = '\0'; // ensure string is terminated, not a requirement for netcdf attributes 87 osg::notify(osg::INFO) << "[SWWReader] embedded image filename: " << filename << std::endl; 88 setBedslopeTexture( std::string(filename) ); 89 } 90 free( filename ); 91 } 83 92 } 84 93 … … 99 108 for( iv=1; iv < _npoints; iv++ ) 100 109 { 101 if( _px[iv] < xmin ) xmin = _px[iv];102 if( _px[iv] > xmax ) xmax = _px[iv];103 if( _py[iv] < ymin ) ymin = _py[iv];104 if( _py[iv] > ymax ) ymax = _py[iv];105 if( _pz[iv] < zmin ) zmin = _pz[iv];106 if( _pz[iv] > zmax ) zmax = _pz[iv];110 if( _px[iv] < xmin ) xmin = _px[iv]; 111 if( _px[iv] > xmax ) xmax = _px[iv]; 112 if( _py[iv] < ymin ) ymin = _py[iv]; 113 if( _py[iv] > ymax ) ymax = _py[iv]; 114 if( _pz[iv] < zmin ) zmin = _pz[iv]; 115 if( _pz[iv] > zmax ) zmax = _pz[iv]; 107 116 } 108 117 … … 238 247 _bedslopegeodata.xresolution = pGDAL->GetRasterXSize(); 239 248 _bedslopegeodata.yresolution = pGDAL->GetRasterYSize(); 249 osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] xresolution: " << 250 _bedslopegeodata.xresolution << std::endl; 251 osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] yresolution: " << 252 _bedslopegeodata.yresolution << std::endl; 240 253 241 254 // check if image contains geodata … … 271 284 osg::ref_ptr<osg::Vec2Array> SWWReader::getBedslopeTextureCoords() 272 285 { 273 274 // bedslope texture coords based on (x,y) locations scaled by extents into range [0,1]275 286 _bedslopetexcoords = new osg::Vec2Array; 276 for( unsigned int iv=0; iv < _npoints; iv++ ) 277 _bedslopetexcoords->push_back( osg::Vec2( (_px[iv]-_xoffset)*_xscale, (_py[iv]-_yoffset)*_yscale ) ); 287 if( _bedslopegeodata.hasData ) // georeferenced bedslope texture 288 { 289 float xorigin = _bedslopegeodata.xorigin; 290 float yorigin = _bedslopegeodata.yorigin; 291 float xrange = _bedslopegeodata.xpixel * _bedslopegeodata.xresolution; 292 float yrange = _bedslopegeodata.ypixel * _bedslopegeodata.yresolution; 293 for( unsigned int iv=0; iv < _npoints; iv++ ) 294 _bedslopetexcoords->push_back( osg::Vec2( (_px[iv] - xorigin)/xrange, (_py[iv] - yorigin)/yrange ) ); } 295 else 296 { 297 // decal'd using (x,y) locations scaled by extents into range [0,1] 298 for( unsigned int iv=0; iv < _npoints; iv++ ) 299 _bedslopetexcoords->push_back( osg::Vec2( (_px[iv]-_xoffset)*_xscale, (_py[iv]-_yoffset)*_yscale ) ); 300 } 278 301 279 302 return _bedslopetexcoords;
Note: See TracChangeset
for help on using the changeset viewer.