Changeset 53
- Timestamp:
- Dec 14, 2004, 1:38:33 PM (20 years ago)
- Location:
- Swollen
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Swollen/include/swwreader.h
r48 r53 81 81 virtual unsigned int getNumberOfTimesteps() {return _ntimesteps;} 82 82 83 virtual float getAlphaScale() {return _alphascale;} 84 virtual float getAlphaMax() {return _alphamax;} 85 virtual float getAlphaThreshold() {return _alphathreshold;} 86 virtual void setAlphaScale( float value ) {_alphascale = value;} 87 virtual void setAlphaMax( float value ) {_alphamax = value;} 88 virtual void setAlphaThreshold( float value ) {_alphathreshold = value;} 83 virtual float getAlphaMin() {return _alphamin;} 84 virtual float getAlphaMax() {return _alphamax;} 85 virtual float getHeightMin() {return _heightmin;} 86 virtual float getHeightMax() {return _heightmax;} 89 87 88 virtual void setAlphaMin( float value ) {_alphamin = value;} 89 virtual void setAlphaMax( float value ) {_alphamax = value;} 90 virtual void setHeightMin( float value ) {_heightmin = value;} 91 virtual void setHeightMax( float value ) {_heightmax = value;} 92 93 90 94 virtual triangle_list getConnectivity(unsigned int index) {return _connectivity.at(index);} 91 95 … … 146 150 147 151 // alpha based culling 148 float _alphamax, _alpha scale, _alphathreshold;152 float _alphamax, _alphamin, _heightmax, _heightmin; 149 153 150 154 }; -
Swollen/swollen/main.cpp
r48 r53 40 40 arguments.getApplicationUsage()->addCommandLineOption("-scale <float>","Vertical scale factor"); 41 41 arguments.getApplicationUsage()->addCommandLineOption("-tps <rate>","timesteps per second"); 42 arguments.getApplicationUsage()->addCommandLineOption("-alphascale <float>","physical height to transparency scale factor"); 43 arguments.getApplicationUsage()->addCommandLineOption("-alphathreshold <float>","transparency lower bound 0-1"); 42 arguments.getApplicationUsage()->addCommandLineOption("-hmin <float>","height below which transparency is set to zero"); 43 arguments.getApplicationUsage()->addCommandLineOption("-hmax <float>","Height above which transparency is set to alphamax"); 44 arguments.getApplicationUsage()->addCommandLineOption("-alphamin <float>","transparency value at hmin"); 44 45 arguments.getApplicationUsage()->addCommandLineOption("-alphamax <float>","maximum transparency clamp value"); 45 46 arguments.getApplicationUsage()->addCommandLineOption("-nosky","omit background sky"); … … 90 91 91 92 float tmpfloat; 92 if( arguments.read("-alphascale",tmpfloat) ) sww->setAlphaScale( tmpfloat ); 93 if( arguments.read("-hmin",tmpfloat) ) sww->setHeightMin( tmpfloat ); 94 if( arguments.read("-hmax",tmpfloat) ) sww->setHeightMax( tmpfloat ); 95 if( arguments.read("-alphamin",tmpfloat) ) sww->setAlphaMin( tmpfloat ); 93 96 if( arguments.read("-alphamax",tmpfloat) ) sww->setAlphaMax( tmpfloat ); 94 if( arguments.read("-alphathreshold",tmpfloat) ) sww->setAlphaThreshold( tmpfloat ); 95 97 96 98 97 99 // root node -
Swollen/swwreader/swwreader.cpp
r48 r53 118 118 _xscale = 1.0 / xrange; 119 119 _yscale = 1.0 / yrange; 120 _zscale = (zmax == 0.0) ? 1.0 : 1.0 / zrange; 120 121 //_zscale = (zmax == 0.0) ? 1.0 : 1.0 / zrange; 122 //I think this is the right one (OMN) incase of a flat bed that 123 //isn't necessarily going through z==0 124 _zscale = (zrange == 0.0) ? 1.0 : 1.0 / zrange; 121 125 _xoffset = xmin; 122 126 _yoffset = ymin; … … 138 142 139 143 // alpha-scaling defaults 144 _alphamin = 0.4; 140 145 _alphamax = 0.9; 141 _ alphascale = 1.0;142 _ alphathreshold = 0.0;146 _heightmin = 1.e-3; 147 _heightmax = 1.0; 143 148 144 149 … … 279 284 280 285 // stage height above bedslope mapped as alpha value 281 float alpha, height; 286 // 287 // Transparancy alpha is calculated as 288 // 289 // alpha = min( a(h-hmin) + alphamin, alphamax), h >= hmin 290 // alpha = 0, h < hmin 291 // 292 // where a = (alphamax-alphamin)/(hmax-hmin) 293 294 float alpha, height, _alphascale; 295 _alphascale = (_alphamax - _alphamin) / (_heightmax - _heightmin); 282 296 _stagecolors = new osg::Vec4Array; 283 297 for (iv=0; iv < _npoints; iv++) 284 298 { 285 299 height = _stagevertices->at(iv).z() - _bedslopevertices->at(iv).z(); 286 alpha = height / _alphascale; 287 if( alpha > _alphamax ) alpha = _alphamax; 300 301 if (height < _heightmin) { 302 alpha = 0.0; 303 } else { 304 alpha = _alphascale*(height - _heightmin) + _alphamin; 305 if( alpha > _alphamax ) alpha = _alphamax; 306 } 288 307 _stagecolors->push_back( osg::Vec4( 1.0, 1.0, 1.0, alpha ) ); 289 308 }
Note: See TracChangeset
for help on using the changeset viewer.