Changeset 105
- Timestamp:
- Jun 10, 2005, 8:28:56 PM (19 years ago)
- Location:
- Swollen
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
Swollen/distros/windistro.py
r96 r105 37 37 # sample sww file for testing 38 38 localtestdir = localrootdir + os.sep + 'tests' 39 localfiles.append(localtestdir + os.sep + 'cylinders 2.sww')40 localfiles.append(localtestdir + os.sep + 'cylinders 2.tif')39 localfiles.append(localtestdir + os.sep + 'cylinders.sww') 40 localfiles.append(localtestdir + os.sep + 'cylinders.tif') 41 41 42 42 -
Swollen/include/swwreader.h
r103 r105 87 87 virtual unsigned int getNumberOfTimesteps() {return _ntimesteps;} 88 88 89 virtual float getAlphaMin() {return _alphamin;} 90 virtual float getAlphaMax() {return _alphamax;} 91 virtual float getHeightMin() {return _heightmin;} 92 virtual float getHeightMax() {return _heightmax;} 89 virtual float getAlphaMin() {return _alphamin;} 90 virtual float getAlphaMax() {return _alphamax;} 91 virtual float getHeightMin() {return _heightmin;} 92 virtual float getHeightMax() {return _heightmax;} 93 virtual float getCullAngle() {return _cullangle;} 93 94 94 virtual void setAlphaMin( float value ) {_alphamin = value;} 95 virtual void setAlphaMax( float value ) {_alphamax = value;} 96 virtual void setHeightMin( float value ) {_heightmin = value;} 97 virtual void setHeightMax( float value ) {_heightmax = value;} 95 virtual void setAlphaMin( float value ) {_alphamin = value;} 96 virtual void setAlphaMax( float value ) {_alphamax = value;} 97 virtual void setHeightMin( float value ) {_heightmin = value;} 98 virtual void setHeightMax( float value ) {_heightmax = value;} 99 100 virtual void setCullAngle( float value ) {_cullangle = value;} 101 virtual void toggleCulling() {_culling = _culling ? false : true;} 98 102 99 103 virtual triangle_list getConnectivity(unsigned int index) {return _connectivity.at(index);} … … 145 149 struct 146 150 { 147 148 149 150 151 151 bool hasData; 152 int xresolution, yresolution; 153 float xorigin, yorigin; 154 float xpixel, ypixel; 155 float rotation; 152 156 } _bedslopegeodata; 153 157 … … 174 178 float _alphamax, _alphamin, _heightmax, _heightmin; 175 179 180 // cull triangles with steepness angle above this value 181 float _cullangle; 182 bool _culling; 183 176 184 }; 177 185 -
Swollen/swollen/main.cpp
r104 r105 47 47 arguments.getApplicationUsage()->addCommandLineOption("-lightpos <float>,<float>,<float>","x,y,z of bedslope directional light (z is up, default is overhead)"); 48 48 arguments.getApplicationUsage()->addCommandLineOption("-nosky","Omit background sky"); 49 arguments.getApplicationUsage()->addCommandLineOption("-cullangle <float angle 0-90>","Cull triangles steeper than this value"); 49 50 arguments.getApplicationUsage()->addCommandLineOption("-texture <file>","Image to use for bedslope topography"); 50 51 arguments.getApplicationUsage()->addCommandLineOption("-version","Revision number and creation (not compile) date"); … … 104 105 if( arguments.read("-alphamin",tmpfloat) ) sww->setAlphaMin( tmpfloat ); 105 106 if( arguments.read("-alphamax",tmpfloat) ) sww->setAlphaMax( tmpfloat ); 107 if( arguments.read("-cullangle",tmpfloat) ) sww->setCullAngle( tmpfloat ); 106 108 107 109 std::string bedslopetexture; … … 202 204 viewer.sync(); 203 205 206 204 207 // current time 205 208 double time = viewer.getFrameStamp()->getReferenceTime(); … … 219 222 220 223 if( event_handler->toggleCulling() ) 221 std::cout << "toggle culling" << std::endl; 222 224 { 225 sww->toggleCulling(); 226 water->setTimeStep(timestep); // refresh 227 } 223 228 224 229 // update the scene by traversing with the update visitor -
Swollen/swollen/watersurface.cpp
r104 r105 67 67 68 68 osg::TexEnv* texenv = new osg::TexEnv; 69 //texenv->setMode( osg::TexEnv::DECAL );70 texenv->setMode( osg::TexEnv::BLEND );69 texenv->setMode( osg::TexEnv::DECAL ); 70 //texenv->setMode( osg::TexEnv::BLEND ); 71 71 texenv->setColor( osg::Vec4(0.6f,0.6f,0.6f,0.2f) ); 72 72 _stateset->setTextureAttributeAndModes( 1, texgen, osg::StateAttribute::ON ); -
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.