Changeset 105 for Swollen/swwreader/swwreader.cpp
- Timestamp:
- Jun 10, 2005, 8:28:56 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Swollen/swwreader/swwreader.cpp
r104 r105 21 21 #include <stdio.h> 22 22 #include <gdal_priv.h> 23 24 25 // compile time defaults 26 #define DEFAULT_CULLANGLE 85.0 27 #define DEFAULT_ALPHAMIN 0.8 28 #define DEFAULT_ALPHAMAX 1.0 29 #define DEFAULT_HEIGHTMIN 0.0 30 #define DEFAULT_HEIGHTMAX 1.0 31 #define DEFAULT_BEDSLOPEOFFSET 0.0 32 #define DEFAULT_CULLONSTART false 23 33 24 34 … … 108 118 } 109 119 120 121 // alpha-scaling defaults, can be overridden after construction by command line parameters 122 _alphamin = DEFAULT_ALPHAMIN; 123 _alphamax = DEFAULT_ALPHAMAX; 124 _heightmin = DEFAULT_HEIGHTMIN; 125 _heightmax = DEFAULT_HEIGHTMAX; 126 127 // steepness culling default, can be overridden after construction by command line parameter 128 _cullangle = DEFAULT_CULLANGLE; 129 _culling = DEFAULT_CULLONSTART; 110 130 111 131 // loop index … … 191 211 _bedslopevertices->push_back( osg::Vec3( (_px[iv]-_xoffset)*_scale - _xcenter, 192 212 (_py[iv]-_yoffset)*_scale - _ycenter, 193 (_pz[iv]-_zoffset)*_scale - _zcenter - 0.00) );213 (_pz[iv]-_zoffset)*_scale - _zcenter - DEFAULT_BEDSLOPEOFFSET) ); 194 214 195 215 // bedslope index array, pvolumes array indexes into x, y and z … … 330 350 osg::ref_ptr<osg::IntArray> steeptri = new osg::IntArray; 331 351 332 // alpha-scaling defaults333 _alphamin = 0.8;334 _alphamax = 1.0;335 _heightmin = 0.00;336 _heightmax = 1.0;337 338 352 // stage heights from netcdf file (x and y are same as bedslope) 339 353 int status = nc_get_vars_float (_ncid, _stageid, start, count, stride, _pstage); … … 354 368 unsigned int v1index, v2index, v3index; 355 369 370 // cullangle given in degrees, test is against dot product 371 float cullthreshold = cos(osg::DegreesToRadians(_cullangle)); 372 356 373 // over all stage triangles 357 374 for (iv=0; iv < _nvolumes; iv++) … … 378 395 _stageprimitivenormals->push_back( nrm ); 379 396 380 // identify steep triangles 381 if( fabs(nrm * osg::Vec3f(0,0,1)) < 0.4 ) 382 { 397 // identify steep triangles, store index 398 if( fabs(nrm * osg::Vec3f(0,0,1)) < cullthreshold ) 383 399 steeptri->push_back( iv ); 384 } 385 } 386 387 388 int seed = 5; 389 srand(seed); 390 float r, g, b; 400 } 391 401 392 402 // stage height above bedslope mapped as alpha value … … 399 409 for (iv=0; iv < _npoints; iv++) 400 410 { 411 // water height above corresponding bedslope 401 412 height = _stagevertices->at(iv).z() - _bedslopevertices->at(iv).z(); 402 413 403 414 if (height < _heightmin) 404 {405 415 alpha = 0.0; 406 }407 416 else 408 417 { 409 418 alpha = alphascale * (height - _heightmin) + _alphamin; 410 419 if( alpha > _alphamax ) 411 alpha = _alphamax; 420 alpha = _alphamax; 412 421 } 413 422 414 r = ((float) rand())/RAND_MAX; 415 g = ((float) rand())/RAND_MAX; 416 b = ((float) rand())/RAND_MAX; 417 //alpha = ((float) rand())/RAND_MAX; 418 alpha = 0.9; 419 _stagecolors->push_back( osg::Vec4( r, g, b, alpha ) ); 420 } 421 422 for (iv=0; iv < steeptri->size() ; iv++) 423 { 424 int tri = steeptri->at(iv); 425 v1index = _pvolumes[3*tri+0]; 426 v2index = _pvolumes[3*tri+1]; 427 v3index = _pvolumes[3*tri+2]; 428 429 r = ((float) rand())/RAND_MAX; 430 g = ((float) rand())/RAND_MAX; 431 b = ((float) rand())/RAND_MAX; 432 433 std::cout << tri << std::endl; 434 435 // FIXME: needs to be an overwrite rather than a push 436 //_stagecolors->push_back( osg::Vec4( 1, 1, 1, alpha ) ); 437 } 438 439 423 _stagecolors->push_back( osg::Vec4( 1.0, 1.0, 1.0, alpha ) ); 424 } 425 426 // steep triangle vertices should have alpha=0, overwrite such vertex colours 427 if( _culling ) 428 { 429 for (iv=0; iv < steeptri->size() ; iv++) 430 { 431 int tri = steeptri->at(iv); 432 v1index = _pvolumes[3*tri+0]; 433 v2index = _pvolumes[3*tri+1]; 434 v3index = _pvolumes[3*tri+2]; 435 436 _stagecolors->at(v1index) = osg::Vec4( 1, 1, 1, 0 ); 437 _stagecolors->at(v2index) = osg::Vec4( 1, 1, 1, 0 ); 438 _stagecolors->at(v3index) = osg::Vec4( 1, 1, 1, 0 ); 439 } 440 } 440 441 441 442 // per-vertex normals calculated as average of primitive normals
Note: See TracChangeset
for help on using the changeset viewer.