Changeset 111 for Swollen/swwreader/swwreader.cpp
- Timestamp:
- Jun 21, 2005, 2:21:44 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Swollen/swwreader/swwreader.cpp
r107 r111 40 40 41 41 // netcdf filename 42 _ filename = new std::string(filename);42 _state.swwfilename = new std::string(filename); 43 43 44 44 // netcdf open 45 _status.push_back( nc_open( _filename->c_str(), NC_NOWRITE, &_ncid) );45 _status.push_back( nc_open(filename.c_str(), NC_NOWRITE, &_ncid) ); 46 46 if (this->_statusHasError()) return; 47 47 … … 131 131 132 132 // alpha-scaling defaults, can be overridden after construction by command line parameters 133 _ alphamin = DEFAULT_ALPHAMIN;134 _ alphamax = DEFAULT_ALPHAMAX;135 _ heightmin = DEFAULT_HEIGHTMIN;136 _ heightmax = DEFAULT_HEIGHTMAX;133 _state.alphamin = DEFAULT_ALPHAMIN; 134 _state.alphamax = DEFAULT_ALPHAMAX; 135 _state.heightmin = DEFAULT_HEIGHTMIN; 136 _state.heightmax = DEFAULT_HEIGHTMAX; 137 137 138 138 // steepness culling default, can be overridden after construction by command line parameter 139 _ cullangle = DEFAULT_CULLANGLE;140 _ culling = DEFAULT_CULLONSTART;139 _state.cullangle = DEFAULT_CULLANGLE; 140 _state.culling = DEFAULT_CULLONSTART; 141 141 142 142 // loop index … … 270 270 _valid = true; 271 271 272 std::cout << _state.alphamin << std::endl; 273 std::cout << _state.alphamax << std::endl; 274 std::cout << _state.heightmin << std::endl; 275 std::cout << _state.heightmax << std::endl; 276 std::cout << _state.cullangle << std::endl; 277 std::cout << _state.culling << std::endl; 278 279 std::cout << *_state.swwfilename << std::endl; 280 std::cout << *_state.bedslopetexturefilename << std::endl; 281 272 282 } 273 283 … … 285 295 { 286 296 osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] filename: " << filename << std::endl; 287 _ bedslopetexture = new std::string(filename);297 _state.bedslopetexturefilename = new std::string(filename); 288 298 _bedslopegeodata.hasData = false; 289 299 … … 311 321 { 312 322 _bedslopegeodata.xorigin = geodata[0]; 313 314 315 316 317 318 319 320 321 322 323 323 _bedslopegeodata.yorigin = geodata[3]; 324 _bedslopegeodata.rotation = geodata[2]; 325 _bedslopegeodata.xpixel = geodata[1]; 326 _bedslopegeodata.ypixel = geodata[5]; 327 _bedslopegeodata.hasData = true; 328 329 osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] xorigin: " << _bedslopegeodata.xorigin << std::endl; 330 osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] yorigin: " << _bedslopegeodata.yorigin << std::endl; 331 osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] xpixel: " << _bedslopegeodata.xpixel << std::endl; 332 osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] ypixel: " << _bedslopegeodata.ypixel << std::endl; 333 osg::notify(osg::INFO) << "[SWWReader::setBedslopetexture] rotation: " << _bedslopegeodata.rotation << std::endl; 324 334 } 325 335 } … … 330 340 osg::Image* SWWReader::getBedslopeTexture() 331 341 { 332 return osgDB::readImageFile( _ bedslopetexture->c_str() );342 return osgDB::readImageFile( _state.bedslopetexturefilename->c_str() ); 333 343 } 334 344 … … 350 360 else 351 361 { 352 // decal 'd using (x,y) locations scaled by extents into range [0,1]362 // decaled using (x,y) locations scaled by extents into range [0,1] 353 363 for( unsigned int iv=0; iv < _npoints; iv++ ) 354 364 _bedslopetexcoords->push_back( osg::Vec2( (_px[iv]-_xoffset)*_xscale, (_py[iv]-_yoffset)*_yscale ) ); … … 391 401 392 402 // cullangle given in degrees, test is against dot product 393 float cullthreshold = cos(osg::DegreesToRadians(_ cullangle));403 float cullthreshold = cos(osg::DegreesToRadians(_state.cullangle)); 394 404 395 405 // over all stage triangles … … 427 437 // where a = (alphamax-alphamin)/(hmax-hmin) 428 438 float alpha, height, alphascale; 429 alphascale = (_ alphamax - _alphamin) / (_heightmax - _heightmin);439 alphascale = (_state.alphamax - _state.alphamin) / (_state.heightmax - _state.heightmin); 430 440 _stagecolors = new osg::Vec4Array; 431 441 for (iv=0; iv < _npoints; iv++) … … 434 444 height = _stagevertices->at(iv).z() - _bedslopevertices->at(iv).z(); 435 445 436 if (height < _ heightmin)446 if (height < _state.heightmin) 437 447 alpha = 0.0; 438 448 else 439 449 { 440 alpha = alphascale * (height - _ heightmin) + _alphamin;441 if( alpha > _ alphamax )442 alpha = _ alphamax;450 alpha = alphascale * (height - _state.heightmin) + _state.alphamin; 451 if( alpha > _state.alphamax ) 452 alpha = _state.alphamax; 443 453 } 444 454 … … 447 457 448 458 // steep triangle vertices should have alpha=0, overwrite such vertex colours 449 if( _ culling )459 if( _state.culling ) 450 460 { 451 461 for (iv=0; iv < steeptri->size() ; iv++)
Note: See TracChangeset
for help on using the changeset viewer.