Changeset 72
- Timestamp:
- Dec 22, 2004, 6:48:22 PM (20 years ago)
- Location:
- Swollen
- Files:
-
- 4 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
Swollen/doc/contract2_hours.txt
r68 r72 4 4 5 5 6 16 Decomber, Thursday (10am-6pm) 6 22 December, Wednesday (4 hours) 7 - orientable directional light 8 9 10 11 total = 135 hours (3.6 weeks) 12 subtotal = 22 hours 13 14 15 16 December, Thursday (8 hours) 7 16 - terrain manipulator added 8 17 - -version flag -
Swollen/swollen/Makefile
r69 r72 27 27 COMPILER = g++ 28 28 OBJ = customviewer.o hud.o keyboardeventhandler.o watersurface.o main.o version.o \ 29 bedslope.o createSky.o customtrackball.o customterrainmanipulator.o spotlight.o 29 bedslope.o createSky.o customtrackball.o customterrainmanipulator.o spotlight.o \ 30 directionallight.o 30 31 CPPFLAGS = -F/System/Library/Frameworks -Wall -DDARWIN_QUICKTIME \ 31 32 $(OPTIMIZATION) -
Swollen/swollen/bedslope.cpp
r65 r72 3 3 #include <bedslope.h> 4 4 5 #include <osg/Texture> 5 6 #include <osg/Texture2D> 6 #include <osg/TexEnv> 7 7 8 #include <osgUtil/SmoothingVisitor> 8 9 … … 22 23 // geometry from sww file 23 24 osg::Vec3Array* vertices = _sww->getBedslopeVertexArray().get(); 24 //osg::Vec3Array* normals = _sww->getBedslopeNormalArray().get();25 25 26 _geom->setUseDisplayList( true);26 _geom->setUseDisplayList( true ); 27 27 _geom->setVertexArray( vertices ); 28 28 _geom->addPrimitiveSet( _sww->getBedslopeIndexArray().get() ); 29 //_geom->setNormalArray( normals );30 //_geom->setNormalBinding( osg::Geometry::BIND_PER_PRIMITIVE );31 29 _geom->setTexCoordArray( 0, _sww->getBedslopeTextureCoords().get() ); 32 30 33 31 osg::UByte4Array* color = new osg::UByte4Array(1); 34 (*color)[0] = osg::UByte4( 255,255,255,255);32 (*color)[0] = osg::UByte4( DEF_BEDSLOPE_COLOUR ); 35 33 _geom->setColorArray( color ); 36 34 _geom->setColorBinding( osg::Geometry::BIND_OVERALL ); … … 41 39 42 40 // bedslope texture 41 _texture = true; 43 42 osg::Texture2D* texture = new osg::Texture2D; 44 texture->setDataVariance( osg::Object::DYNAMIC);45 texture->setWrap( osg::Texture::WRAP_S, osg::Texture::REPEAT);46 texture->setWrap( osg::Texture::WRAP_T, osg::Texture::REPEAT);43 texture->setDataVariance( osg::Object::DYNAMIC ); 44 texture->setWrap( osg::Texture::WRAP_S, osg::Texture::REPEAT ); 45 texture->setWrap( osg::Texture::WRAP_T, osg::Texture::REPEAT ); 47 46 texture->setImage( _sww->getBedslopeTexture() ); 48 47 49 48 // material 50 49 _material = new osg::Material(); 51 _material->setAmbient( osg::Material::FRONT_AND_BACK, osg::Vec4(0.2, 0.2, 0.2, 1.0) ); 50 _material->setAmbient( osg::Material::FRONT_AND_BACK, osg::Vec4(0.2, 0.15, 0.06, 1.0) ); 51 _material->setDiffuse( osg::Material::FRONT_AND_BACK, osg::Vec4(0.6, 0.5, 0.2, 1.0) ); 52 _material->setSpecular( osg::Material::FRONT_AND_BACK, osg::Vec4(0.0, 0.0, 0.0, 1.0) ); 53 _material->setEmission( osg::Material::FRONT_AND_BACK, osg::Vec4(0.0, 0.0, 0.0, 1.0) ); 54 55 _material->setAmbient( osg::Material::FRONT_AND_BACK, osg::Vec4(0.0, 0.0, 0.0, 1.0) ); 52 56 _material->setDiffuse( osg::Material::FRONT_AND_BACK, osg::Vec4(1.0, 1.0, 1.0, 1.0) ); 53 _material->setSpecular( osg::Material::FRONT_AND_BACK, osg::Vec4(0. 8, 0.8, 0.8, 1.0) );57 _material->setSpecular( osg::Material::FRONT_AND_BACK, osg::Vec4(0.0, 0.0, 0.0, 1.0) ); 54 58 _material->setEmission( osg::Material::FRONT_AND_BACK, osg::Vec4(0.0, 0.0, 0.0, 1.0) ); 55 59 … … 58 62 _stateset = new osg::StateSet; 59 63 _stateset->setTextureAttributeAndModes( 0, texture, osg::StateAttribute::ON ); 60 _stateset->setAttributeAndModes( _material, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE );64 _stateset->setAttributeAndModes( _material, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE ); 61 65 _stateset->setMode( GL_BLEND, osg::StateAttribute::ON ); 62 66 _stateset->setMode( GL_LIGHTING, osg::StateAttribute::ON ); … … 69 73 } 70 74 75 76 void BedSlope::toggleTexture() 77 { 78 79 if ( _texture ) 80 { 81 _stateset->setTextureMode( 0, GL_TEXTURE_2D, osg::StateAttribute::OFF ); 82 _texture = false; 83 } 84 else 85 { 86 _stateset->setTextureMode( 0, GL_TEXTURE_2D, osg::StateAttribute::ON ); 87 _texture = true; 88 } 89 90 } -
Swollen/swollen/bedslope.h
r65 r72 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 34 protected: … … 38 40 osg::Material* _material; 39 41 virtual ~BedSlope(){;} 42 bool _texture; 40 43 41 44 }; -
Swollen/swollen/keyboardeventhandler.cpp
r71 r72 77 77 break; 78 78 79 case ' m':79 case 'l': 80 80 _togglemanipulatormode = true; 81 81 handled = true; -
Swollen/swollen/main.cpp
r71 r72 20 20 #include <hud.h> 21 21 #include <keyboardeventhandler.h> 22 #include <spotlight.h> 22 //#include <spotlight.h> 23 #include <directionallight.h> 23 24 #include <watersurface.h> 24 25 … … 44 45 arguments.getApplicationUsage()->addCommandLineOption("-hmin <float>","Height below which transparency is set to zero"); 45 46 arguments.getApplicationUsage()->addCommandLineOption("-hmax <float>","Height above which transparency is set to alphamax"); 46 arguments.getApplicationUsage()->addCommandLineOption("-alphamin <float >","Transparency value at hmin");47 arguments.getApplicationUsage()->addCommandLineOption("-alphamax <float >","Maximum transparency clamp value");47 arguments.getApplicationUsage()->addCommandLineOption("-alphamin <float 0-1>","Transparency value at hmin"); 48 arguments.getApplicationUsage()->addCommandLineOption("-alphamax <float 0-1>","Maximum transparency clamp value"); 48 49 arguments.getApplicationUsage()->addCommandLineOption("-nosky","Omit background sky"); 49 50 arguments.getApplicationUsage()->addCommandLineOption("-texture <file>","Image to use for bedslope topography"); … … 135 136 136 137 // Lighting 137 SpotLight* spotlight = new SpotLight(rootStateSet);138 spotlight->setPosition( osg::Vec3(0,1,0) ); // z is up139 spotlight->setSpotAngle( 45.0 );138 DirectionalLight* light = new DirectionalLight(rootStateSet); 139 light->setPosition( osg::Vec3(0,1,0) ); // z is up 140 // spotlight->setSpotAngle( 45.0 ); 140 141 141 142 … … 143 144 rootnode->setStateSet(rootStateSet); 144 145 rootnode->addChild( hud->get() ); 145 rootnode->addChild( spotlight->get() );146 rootnode->addChild( light->get() ); 146 147 rootnode->addChild(model); 147 148 model->addChild( bedslope->get() ); … … 179 180 180 181 181 // initial cameraposition182 // initial light position 182 183 CustomTrackballManipulator* trackball = viewer.getTrackball(); 183 184 trackball->setNode( model ); … … 191 192 192 193 194 // initial camera position 193 195 CustomTerrainManipulator* terrainmanipulator = viewer.getTerrainManipulator(); 194 terrainmanipulator->setNode( rootnode);196 terrainmanipulator->setNode( model ); 195 197 terrainmanipulator->setAutoComputeHomePosition( false ); 196 198 terrainmanipulator->setHomePosition( … … 219 221 water->setTimeStep(timestep); 220 222 hud->setTime( sww->getTime(timestep) ); 223 224 // bedslope->toggleTexture(); 225 221 226 } 222 227 … … 225 230 { 226 231 //osg::Matrixd matrix = trackball->getInverseMatrix(); 227 osg::Matrixd matrix = trackball->getMatrix();228 osg::Vec3d position = matrix.getTrans();229 //std::cout << "trackball position x: " << position. << std::endl;230 spotlight->setPosition(position );232 osg::Matrixd matrix = trackball->getMatrix(); 233 osg::Vec3d position = matrix.getTrans(); 234 //std::cout << "trackball position x: " << position. << std::endl; 235 light->setPosition( -position ); 231 236 } 232 237 … … 243 248 trackball->disable(); 244 249 terrainmanipulator->enable(); 250 light->hide(); 245 251 } 246 252 else … … 248 254 trackball->enable(); 249 255 terrainmanipulator->disable(); 256 light->show(); 250 257 } 251 258 } -
Swollen/swollen/spotlight.cpp
r65 r72 14 14 { 15 15 // positioning container 16 _ group= new osg::MatrixTransform;17 _ group->setCullingActive(false);16 _transform = new osg::MatrixTransform; 17 _transform->setCullingActive(false); 18 18 19 19 // OpenGL light … … 21 21 _light->setLightNum(num); 22 22 _light->setPosition(osg::Vec4(0,0,0,1)); 23 _light->setAmbient(osg::Vec4(0. 0,0.0,0.0,1));23 _light->setAmbient(osg::Vec4(0.7,0.7,0.7,1)); 24 24 _light->setDiffuse(osg::Vec4(1,1,1,1)); 25 25 _light->setSpecular(osg::Vec4(1,1,1,1)); … … 33 33 _source->setLocalStateSetModes( osg::StateAttribute::ON ); 34 34 _source->setStateSetModes( *rootStateSet, osg::StateAttribute::ON ); 35 _ group->addChild( _source );35 _transform->addChild( _source ); 36 36 37 37 // create cone marker for spotlight and rotate towards origin … … 44 44 45 45 // omit marker cone for now (FIX ME) 46 _ group->addChild(_marker);46 _transform->addChild(_marker); 47 47 48 48 setPosition( osg::Vec3(0,0,1) ); // default overhead … … 67 67 quat.makeRotate( osg::Vec3(0,0,-1), origindir ); 68 68 69 _ group->setMatrix( osg::Matrix::rotate( quat ) * osg::Matrix::translate(v) );69 _transform->setMatrix( osg::Matrix::rotate( quat ) * osg::Matrix::translate(v) ); 70 70 } 71 71 -
Swollen/swollen/spotlight.h
r6 r72 32 32 33 33 SpotLight(osg::StateSet* rootStateSet, int num=0); 34 virtual osg::Group* get(){ return _ group; }34 virtual osg::Group* get(){ return _transform; } 35 35 virtual void setPosition(osg::Vec3 v); 36 36 virtual osg::Vec3f* getPosition(){ return _position; } 37 37 void setSpotAngle( float degrees ); 38 void setMatrix( osg::Matrixf matrix ){ _ group->setMatrix( matrix ); }38 void setMatrix( osg::Matrixf matrix ){ _transform->setMatrix( matrix ); } 39 39 void setAmbient( osg::Vec3f v ){ _light->setAmbient(osg::Vec4(v,1)); } 40 40 void setDiffuse( osg::Vec3f v ){ _light->setDiffuse(osg::Vec4(v,1)); } 41 const osg::Matrix getMatrix(){ return _ group->getMatrix(); }41 const osg::Matrix getMatrix(){ return _transform->getMatrix(); } 42 42 43 43 44 44 protected: 45 45 46 //osg::Group* _group; 47 osg::MatrixTransform* _group; 46 osg::MatrixTransform* _transform; 48 47 osg::Vec3* _position; 49 48 osg::Vec3* _target; -
Swollen/swollen/version.cpp
r71 r72 1 const char* version() { const char* s = "Revision: 70 M"; return s; }1 const char* version() { const char* s = "Revision: 70:71M"; return s; } -
Swollen/swollen/watersurface.cpp
r64 r72 16 16 #include <osg/TexGen> 17 17 18 #include <osgDB/Registry>19 18 #include <osgDB/ReadFile> 20 21 19 #include <osgUtil/TriStripVisitor> 22 20
Note: See TracChangeset
for help on using the changeset viewer.