Changeset 104
- Timestamp:
- Jun 10, 2005, 5:24:31 PM (20 years ago)
- Location:
- Swollen
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
Swollen/doc/contract2_hours.txt
r103 r104 3 3 ------------------ 4 4 5 total = 163 hours (4.3 weeks) 6 subtotal = 9 hours 7 8 10 June, Friday (4 hours) 9 - sww file "texture" attribute image now found in same location as .sww 10 - steep culling reintroduced 11 - built and released distro20050610 for windows 5 12 6 13 8 June, Wednesday (3 hours) -
Swollen/swollen/bedslope.cpp
r95 r104 77 77 78 78 } 79 80 81 void BedSlope::toggleTexture()82 {83 84 // FIXME: stateset no longer defined for non-textured bedslope85 if ( _texture )86 {87 _stateset->setTextureMode( 0, GL_TEXTURE_2D, osg::StateAttribute::OFF );88 _texture = false;89 }90 else91 {92 _stateset->setTextureMode( 0, GL_TEXTURE_2D, osg::StateAttribute::ON );93 _texture = true;94 }95 96 } -
Swollen/swollen/bedslope.h
r72 r104 29 29 virtual osg::Geode* get(){ return _node; } 30 30 virtual osg::BoundingBox getBound(){ return _geom->getBound(); } 31 virtual void toggleTexture();32 31 33 32 -
Swollen/swollen/keyboardeventhandler.cpp
r92 r104 14 14 _prevtime = 0; 15 15 _togglewireframe = false; 16 _toggleculling = false; 16 17 } 17 18 … … 76 77 break; 77 78 79 case 'c': 80 _toggleculling = true; 81 handled = true; 82 break; 83 84 78 85 } 79 86 … … 120 127 121 128 129 bool KeyboardEventHandler::toggleCulling() 130 { 131 if( _toggleculling ) 132 { 133 _toggleculling = false; 134 return true; 135 } 136 return false; 137 } 138 139 -
Swollen/swollen/keyboardeventhandler.h
r92 r104 23 23 virtual bool timestepChanged(); 24 24 virtual bool toggleWireframe(); 25 virtual bool toggleCulling(); 25 26 virtual int getTimestep(){return (unsigned int) _timestep;} 26 27 virtual void setTime(float time); … … 29 30 int _direction, _timestep, _ntimesteps; 30 31 float _tps, _prevtime, _tpsorig; 31 bool _paused, _timestepchanged, _togglewireframe ;32 bool _paused, _timestepchanged, _togglewireframe, _toggleculling; 32 33 }; 33 34 -
Swollen/swollen/main.cpp
r103 r104 131 131 // Lighting 132 132 DirectionalLight* light = new DirectionalLight(rootStateSet); 133 light->setPosition( osg::Vec3( 0,0,2) ); // z is up133 light->setPosition( osg::Vec3(1,1,1) ); // z is up 134 134 135 135 std::string lightposstr; … … 218 218 water->toggleWireframe(); 219 219 220 if( event_handler->toggleCulling() ) 221 std::cout << "toggle culling" << std::endl; 222 223 220 224 // update the scene by traversing with the update visitor 221 225 viewer.update(); -
Swollen/swollen/watersurface.cpp
r73 r104 67 67 68 68 osg::TexEnv* texenv = new osg::TexEnv; 69 texenv->setMode( osg::TexEnv::DECAL ); 69 //texenv->setMode( osg::TexEnv::DECAL ); 70 texenv->setMode( osg::TexEnv::BLEND ); 70 71 texenv->setColor( osg::Vec4(0.6f,0.6f,0.6f,0.2f) ); 71 72 _stateset->setTextureAttributeAndModes( 1, texgen, osg::StateAttribute::ON ); -
Swollen/swwreader/swwreader.cpp
r103 r104 8 8 9 9 #include <SWWReader.h> 10 #include <cstdlib> 10 11 #include <string> 11 12 #include <fstream> … … 15 16 #include <osgDB/Registry> 16 17 #include <osgDB/ReadFile> 18 #include <osgDB/FileNameUtils> 17 19 18 20 #include <stdlib.h> … … 78 80 if( nc_inq_attlen(_ncid, NC_GLOBAL, "texture", &attlen) != NC_ENOTATT ) 79 81 { 80 char*filename;81 if( (filename = (char*) malloc(attlen+1)) != NULL){82 int status;83 status = nc_get_att_text(_ncid, NC_GLOBAL, "texture",filename);84 if( status == NC_NOERR )85 {86 filename[attlen] = '\0'; // ensure string is terminated, not a requirement for netcdf attributes87 osg::notify(osg::INFO) << "[SWWReader] embedded image filename: " <<filename << std::endl;88 setBedslopeTexture( std::string(filename) );89 }90 free(filename );91 }82 char* texfilename; 83 if( (texfilename = (char*) malloc(attlen+1)) != NULL){ 84 int status; 85 status = nc_get_att_text(_ncid, NC_GLOBAL, "texture", texfilename); 86 if( status == NC_NOERR ) 87 { 88 texfilename[attlen] = '\0'; // ensure string is terminated, not a requirement for netcdf attributes 89 osg::notify(osg::INFO) << "[SWWReader] embedded image filename: " << texfilename << std::endl; 90 setBedslopeTexture( osgDB::getFilePath(filename) + std::string("/") + std::string(texfilename) ); 91 } 92 free( texfilename ); 93 } 92 94 } 93 95 … … 163 165 } 164 166 165 166 167 osg::notify(osg::INFO) << "[SWWReader] xscale: " << _xscale << std::endl; 167 168 osg::notify(osg::INFO) << "[SWWReader] yscale: " << _yscale << std::endl; … … 169 170 osg::notify(osg::INFO) << "[SWWReader] zmax: " << zmax << std::endl; 170 171 osg::notify(osg::INFO) << "[SWWReader] zscale: " << _zscale << std::endl; 171 172 173 174 // alpha-scaling defaults175 _alphamin = 0.8;176 _alphamax = 1.0;177 _heightmin = 0.0;178 _heightmax = 1.0;179 172 180 173 … … 198 191 _bedslopevertices->push_back( osg::Vec3( (_px[iv]-_xoffset)*_scale - _xcenter, 199 192 (_py[iv]-_yoffset)*_scale - _ycenter, 200 (_pz[iv]-_zoffset)*_scale - _zcenter ) );193 (_pz[iv]-_zoffset)*_scale - _zcenter - 0.00) ); 201 194 202 195 // bedslope index array, pvolumes array indexes into x, y and z … … 334 327 count[1] = _npoints; 335 328 329 // empty array for storing list of steep triangles 330 osg::ref_ptr<osg::IntArray> steeptri = new osg::IntArray; 331 332 // alpha-scaling defaults 333 _alphamin = 0.8; 334 _alphamax = 1.0; 335 _heightmin = 0.00; 336 _heightmax = 1.0; 337 336 338 // stage heights from netcdf file (x and y are same as bedslope) 337 339 int status = nc_get_vars_float (_ncid, _stageid, start, count, stride, _pstage); … … 375 377 _stagecentroids->push_back( (v1s+v2s+v3s)/3.0 ); 376 378 _stageprimitivenormals->push_back( nrm ); 377 } 378 379 380 // identify steep triangles 381 if( fabs(nrm * osg::Vec3f(0,0,1)) < 0.4 ) 382 { 383 steeptri->push_back( iv ); 384 } 385 } 386 387 388 int seed = 5; 389 srand(seed); 390 float r, g, b; 379 391 380 392 // stage height above bedslope mapped as alpha value … … 387 399 for (iv=0; iv < _npoints; iv++) 388 400 { 389 401 height = _stagevertices->at(iv).z() - _bedslopevertices->at(iv).z(); 390 402 391 if (height < _heightmin) 392 { 393 alpha = 0.0; 394 } 395 else 396 { 397 alpha = alphascale * (height - _heightmin) + _alphamin; 398 if( alpha > _alphamax ) 399 alpha = _alphamax; 400 } 401 _stagecolors->push_back( osg::Vec4( 1.0, 1.0, 1.0, alpha ) ); 402 } 403 if (height < _heightmin) 404 { 405 alpha = 0.0; 406 } 407 else 408 { 409 alpha = alphascale * (height - _heightmin) + _alphamin; 410 if( alpha > _alphamax ) 411 alpha = _alphamax; 412 } 413 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 403 439 404 440
Note: See TracChangeset
for help on using the changeset viewer.