Changeset 48
- Timestamp:
- Dec 13, 2004, 11:42:36 PM (20 years ago)
- Location:
- Swollen
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
Swollen/INSTALL
r45 r48 5 5 1) The pyVolution Visualizer has several dependencies. 6 6 7 Open SceneGraph, OpenThreads, and Producer7 OpenThreads, Producer, OpenSceneGraph: 8 8 - http://openscenegraph.sourceforge.net 9 - available as a bundle, OSG_OP_OT-0.9.8 9 - available as a bundle, OSG_OP_OT-0.9.8, that contains 10 OpenThreads, (Open)Producer and OpenSceneGraph as 11 subdirectories. 10 12 - OpenSceneGraph has 3rd party dependencies, these are 11 available as a downloadable .zip for Windows. 13 available as a downloadable .zip for Windows. Extracted 14 .zip directory (3rdParty) lives alongside other three 15 subdirectories. 16 - Build "release" versions in above order 12 17 - ensure you can run the examples that come with OSG 13 prior to building the viewer 18 prior to building the viewer (these live in the 19 OpenSceneGraph/bin directory on Windows). 14 20 15 21 NetCDF - a self-describing binary file format I/O library … … 45 51 46 52 CPPUNIT : root of c++ unit testing framework with needed subdirs 47 /lib and /include 53 /lib and /include (optional) 48 54 49 55 … … 53 59 WINDOWS 54 60 55 (i) Open the solution in visualstudio subdir.61 (i) Within VisualStudio, Open the solution in Swollen visualstudio subdirectory 56 62 (ii) Open Menu Tools|Options|Projects|VC++Directories and add a 57 63 path to $(NETCDF_DIR)/bin and $(OSG_ROOT)/bin. -
Swollen/doc/contract2_hours.txt
r46 r48 3 3 ------------------ 4 4 5 6 14 December, Monday (6 hours) 7 - visit to GA, swollen now compiling on-site under Windows/Visual Studio .NET 8 - added command line params for tweaking transparency (see "swollen -help") 5 9 6 10 12 December, Saturday (4 hours) -
Swollen/doc/contract2_priorities.txt
r43 r48 29 29 from camera) [1] 30 30 - z-scaling to emphasize vertical details (via -scale command line parameter) [1] 31 31 - Optional height-dependent semi-transparent water surface [0] 32 - added -nosky command-line option to appease those who want a plain background [?] 33 - Duncan and Ole able to compile Swollen from source under Windows/Visual Studio .NET [?] 32 34 33 35 … … 38 40 (e.g. stage, speed, ..) [4] 39 41 - Output coordinates defining camera position [?] 40 - Interactive positioning of light(s) [?] 41 42 - Ability to handle scenes with a resolution of 500,000+ triangles [3] 42 43 43 44 … … 49 50 - Problems with Duncan's, Chris' and Stephen Roberts' machines at GA: Swollen won't render semi transparency. 50 51 Swwviewer works fine. 51 52 53 52 54 53 … … 64 63 65 64 66 67 68 65 -------------------------------------------------- 69 66 … … 72 69 - Scene augmentation with OSG models [2] 73 70 - Optional contour lines of water surface [1] 74 - Optional height-dependent semi-transparent water surface [0] 71 75 72 76 77 73 FUNCTIONALITY: 78 74 … … 86 82 - Ability to show earthquakes [0] 87 83 - Concept of 'buildings' and shaking them [0] 88 89 84 - Interactive positioning of light(s) [?] 85 - key binding 'h' for home camera position [?] 86 - key binding 't' for top camera position [?] 87 - user feedback should differentiate between "sww file not found" and 88 "sww file couldn't read" [?] 89 - add -version command line flag synced with Subversion revision number (useful for debugging) [?] 90 90 91 91 … … 93 93 94 94 - Scene optimization via geometry and texture level-of-detail (LOD) [3] 95 - Ability to handle scenes with a resolution of 500,000+ triangles [3]96 95 - Separate thread for loading a ring buffer of stage data [1] 97 96 … … 109 108 - Revisit use of culling steep epsilon [3] 110 109 - SWW netcdf meta information [0] 111 112 -
Swollen/include/swwreader.h
r45 r48 80 80 virtual size_t getNumberOfVertices() {return _npoints;} 81 81 virtual unsigned int getNumberOfTimesteps() {return _ntimesteps;} 82 //virtual int getNumberOfBedslopeIndices() {return _bedslopeindices->size();}83 //virtual int getNumberOfStageIndices() {return _stageindices->size();}84 82 85 // stage culling86 virtual void toggleCullSetting();87 virtual float get CullNearZero() {return _cullnearzero;}88 virtual float getCullSteepAngle() {return _cullsteepangle;}89 virtual void set CullNearZero( float value ) {_cullnearzero = value;}90 virtual void set CullSteepAngle( float value ) {_cullsteepangle = value;}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;} 91 89 92 90 virtual triangle_list getConnectivity(unsigned int index) {return _connectivity.at(index);} … … 147 145 std::vector<triangle_list> _connectivity; 148 146 149 // stage culling 150 float _cullnearzero; 151 float _cullsteepangle; 152 enum cullstate { CULLALL, CULLNEARZERO, CULLSTEEPANGLE, CULLNONE }; 153 cullstate _cullsetting; 147 // alpha based culling 148 float _alphamax, _alphascale, _alphathreshold; 154 149 155 150 }; -
Swollen/swollen/keyboardeventhandler.cpp
r13 r48 14 14 _prevtime = 0; 15 15 _togglewireframe = false; 16 _togglecullsetting = false;17 16 } 18 17 … … 76 75 handled = true; 77 76 break; 78 79 case 'c':80 _togglecullsetting = true;81 handled = true;82 break;83 77 } 84 78 … … 125 119 126 120 127 bool KeyboardEventHandler::toggleCullSetting()128 {129 if( _togglecullsetting )130 {131 _togglecullsetting = false;132 return true;133 }134 return false;135 }136 -
Swollen/swollen/keyboardeventhandler.h
r13 r48 23 23 virtual bool timestepChanged(); 24 24 virtual bool toggleWireframe(); 25 virtual bool toggleCullSetting();26 25 virtual int getTimestep(){return (unsigned int) _timestep;} 27 26 virtual void setTime(float time); … … 30 29 int _direction, _timestep, _ntimesteps; 31 30 float _tps, _prevtime, _tpsorig; 32 bool _paused, _timestepchanged, _togglewireframe , _togglecullsetting;31 bool _paused, _timestepchanged, _togglewireframe; 33 32 }; 34 33 -
Swollen/swollen/main.cpp
r45 r48 37 37 arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()); 38 38 arguments.getApplicationUsage()->setCommandLineUsage("swollen [options] swwfile ..."); 39 arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");40 arguments.getApplicationUsage()->addCommandLineOption("-scale < s>","Vertical scale factor");39 arguments.getApplicationUsage()->addCommandLineOption("-help","Display this information"); 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"); 44 arguments.getApplicationUsage()->addCommandLineOption("-alphamax <float>","maximum transparency clamp value"); 45 arguments.getApplicationUsage()->addCommandLineOption("-nosky","omit background sky"); 42 46 43 47 // construct the viewer. … … 54 58 55 59 // if user request help write it out to cout. 56 if (arguments.read("-h") || arguments.read("--help"))60 if( arguments.read("-help") ) 57 61 { 58 62 arguments.getApplicationUsage()->write(std::cout); … … 61 65 62 66 63 // load sww file specified as final argument on command line (static 67 // load sww file specified as final argument on command line (static bedslope 64 68 // geometry only, per timestep height field geometry is done in loop below) 65 69 int lastarg = arguments.argc()-1; … … 79 83 80 84 81 // default arguments 85 // default arguments and command line parameters 82 86 float tps; 83 87 if( !arguments.read("-tps",tps) || tps <= 0.0 ) tps = DEF_TPS; … … 85 89 if( !arguments.read("-scale",vscale) ) vscale = 1.0; 86 90 91 float tmpfloat; 92 if( arguments.read("-alphascale",tmpfloat) ) sww->setAlphaScale( tmpfloat ); 93 if( arguments.read("-alphamax",tmpfloat) ) sww->setAlphaMax( tmpfloat ); 94 if( arguments.read("-alphathreshold",tmpfloat) ) sww->setAlphaThreshold( tmpfloat ); 95 87 96 88 97 // root node … … 91 100 // transform 92 101 osg::PositionAttitudeTransform* model = new osg::PositionAttitudeTransform; 93 model->setName(" model_transform");102 model->setName("position_attitude_transform"); 94 103 95 104 // enscapsulates OpenGL state … … 122 131 123 132 124 // FIXME: should be reasonable default and adjustable133 // allow vertical scaling from command line parameter 125 134 model->setScale( osg::Vec3(1.0, 1.0, vscale) ); 126 135 127 // sky 128 rootnode->addChild( createSky(10.0, "sky_small.jpg") ); 136 // surrounding sky sphere 137 if( !arguments.read("-nosky") ) 138 rootnode->addChild( createSky(10.0, "sky_small.jpg") ); 129 139 130 140 … … 153 163 // initial camera position 154 164 viewer.getTrackball()->setNode( rootnode ); 155 viewer.getTrackball()->setAutoComputeHomePosition( false);165 viewer.getTrackball()->setAutoComputeHomePosition( false ); 156 166 viewer.getTrackball()->setHomePosition( 157 osg::Vec3d(0,- 4,1), // camera location167 osg::Vec3d(0,-3,2), // camera location 158 168 osg::Vec3d(0,0,0), // camera target 159 169 osg::Vec3d(0,0,1) ); // camera up vector … … 182 192 if( event_handler->toggleWireframe() ) 183 193 water->toggleWireframe(); 184 if( event_handler->toggleCullSetting() )185 {186 sww->toggleCullSetting();187 water->setTimeStep(timestep); // forced reload188 }189 194 190 195 -
Swollen/swollen/watersurface.cpp
r45 r48 22 22 23 23 24 #define DEF_WATER_COLOUR 0, 0, 0.5, 1 // R, G, B, Alpha (blue)25 #define DEF_WATER_TRANSPARENCY 0.1 // 0=opaque, 1=transparent26 #define DEF_ZOFFSET 0.0127 28 24 // constructor 29 25 WaterSurface::WaterSurface(SWWReader* sww) … … 34 30 _geom = new osg::Geometry; 35 31 _stateset = new osg::StateSet; 36 _zoffset = DEF_ZOFFSET;37 32 38 33 // construct local scenegraph hierarchy … … 62 57 63 58 osg::AlphaFunc* alphaFunc = new osg::AlphaFunc; 64 //alphaFunc->setFunction(osg::AlphaFunc::GEQUAL,0.1f); 65 alphaFunc->setFunction(osg::AlphaFunc::ALWAYS); 59 alphaFunc->setFunction( osg::AlphaFunc::GEQUAL, _sww->getAlphaThreshold() ); 66 60 _stateset->setAttributeAndModes( alphaFunc, osg::StateAttribute::ON ); 67 68 61 _stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); 69 70 62 71 63 // automatically generate texture coords … … 92 84 // delete if exists 93 85 if( _geom->getNumPrimitiveSets() ) 94 _geom->removePrimitiveSet(0); // reference counting actually does thedelete86 _geom->removePrimitiveSet(0); // reference counting does actual delete 95 87 96 88 // local reference to raw height field data … … 99 91 osg::ref_ptr<osg::Vec4Array> colors = _sww->getStageColorArray(); 100 92 101 // vertical (z) offset to eliminate potential zbuffer problems with bedslope102 osg::UIntArray* colorindices = new osg::UIntArray(vertices.get()->size());103 for( unsigned int iv=0; iv < vertices.get()->size(); iv++ )104 {105 vertices.get()->at(iv) += osg::Vec3f( 0.0, 0.0, _zoffset );106 colorindices->at(iv) = iv;107 }108 109 93 // geometry 110 94 _geom->setVertexArray( vertices.get() ); 111 95 _geom->addPrimitiveSet( _sww->getBedslopeIndexArray().get() ); 112 96 113 // per vertex colors ( using only alpha)97 // per vertex colors (we only modulate the alpha for transparency) 114 98 _geom->setColorArray( colors.get() ); 115 99 _geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX); -
Swollen/swollen/watersurface.h
r45 r48 18 18 19 19 20 21 20 class WaterSurface 22 21 { … … 28 27 virtual void setTimeStep( unsigned int ts ); 29 28 virtual void toggleWireframe(); 30 virtual void setOffset( float amount ){ _zoffset = amount; }31 virtual float getOffset(){ return _zoffset; }32 29 33 30 protected: … … 38 35 osg::StateSet* _stateset; 39 36 virtual ~WaterSurface(); 40 float _zoffset;41 37 42 38 }; -
Swollen/swwreader/swwreader.cpp
r45 r48 35 35 #include <stdio.h> 36 36 37 #define DEF_CULLNEARZERO 0.00138 #define DEF_CULLSTEEPANGLE 0.939 #define DEF_CULLSTART CULLNONE40 41 #define MIN(a, b) (a < b ? a : b)42 #define MAX(a, b) (a > b ? a : b)43 44 37 45 38 // only constructor, requires netcdf file … … 144 137 } 145 138 139 // alpha-scaling defaults 140 _alphamax = 0.9; 141 _alphascale = 1.0; 142 _alphathreshold = 0.0; 143 144 146 145 osg::notify(osg::INFO) << "[SWWReader] xmin: " << xmin << std::endl; 147 146 osg::notify(osg::INFO) << "[SWWReader] xmax: " << xmax << std::endl; … … 155 154 156 155 157 // culling defaults158 _cullsetting = DEF_CULLSTART;159 _cullnearzero = DEF_CULLNEARZERO;160 _cullsteepangle = DEF_CULLSTEEPANGLE;161 162 156 // compute triangle connectivity, a list (indexed by vertex number) 163 157 // of lists (indices of triangles sharing this vertex) … … 191 185 for( iv=0; iv < _npoints; iv++ ) 192 186 _bedslopetexcoords->push_back( osg::Vec2( (_px[iv]-_xoffset)*_xscale, (_py[iv]-_yoffset)*_yscale ) ); 193 194 187 195 188 … … 251 244 (_pstage[iv]-_zoffset)*_scale - _zcenter) ); 252 245 253 254 246 // stage index, per primitive normal and centroid arrays 255 247 _stageprimitivenormals = new osg::Vec3Array; … … 261 253 262 254 // over all stage triangles 263 for (iv=0; iv < _nvolumes; iv++) {264 255 for (iv=0; iv < _nvolumes; iv++) 256 { 265 257 v1index = _pvolumes[3*iv+0]; 266 258 v2index = _pvolumes[3*iv+1]; … … 283 275 _stagecentroids->push_back( (v1s+v2s+v3s)/3.0 ); 284 276 _stageprimitivenormals->push_back( nrm ); 285 286 } 287 288 289 float alpha ;277 } 278 279 280 // stage height above bedslope mapped as alpha value 281 float alpha, height; 290 282 _stagecolors = new osg::Vec4Array; 291 283 for (iv=0; iv < _npoints; iv++) 292 284 { 293 // FIXME: needs to be scaled appropriately 294 alpha = ( _stagevertices->at(iv).z() - _bedslopevertices->at(iv).z() ) * 100.0; 285 height = _stagevertices->at(iv).z() - _bedslopevertices->at(iv).z(); 286 alpha = height / _alphascale; 287 if( alpha > _alphamax ) alpha = _alphamax; 295 288 _stagecolors->push_back( osg::Vec4( 1.0, 1.0, 1.0, alpha ) ); 296 289 } … … 321 314 322 315 323 void SWWReader::toggleCullSetting()324 {325 326 switch( _cullsetting )327 {328 329 case CULLALL:330 _cullsetting = CULLNEARZERO;331 osg::notify(osg::INFO) << "[SWWReader::toggleCullSetting] CULLNEARZERO" << std::endl;332 break;333 334 case CULLNEARZERO:335 _cullsetting = CULLSTEEPANGLE;336 osg::notify(osg::INFO) << "[SWWReader::toggleCullSetting] CULLSTEEPANGLE" << std::endl;337 break;338 339 case CULLSTEEPANGLE:340 _cullsetting = CULLNONE;341 osg::notify(osg::INFO) << "[SWWReader::toggleCullSetting] CULLNONE" << std::endl;342 break;343 344 case CULLNONE:345 _cullsetting = CULLALL;346 osg::notify(osg::INFO) << "[SWWReader::toggleCullSetting] CULLALL" << std::endl;347 break;348 349 }350 }351 352 353 316 354 317 bool SWWReader::_statusHasError()
Note: See TracChangeset
for help on using the changeset viewer.