Changeset 72


Ignore:
Timestamp:
Dec 22, 2004, 6:48:22 PM (20 years ago)
Author:
darran
Message:
  • work in progress
Location:
Swollen
Files:
4 added
10 edited

Legend:

Unmodified
Added
Removed
  • Swollen/doc/contract2_hours.txt

    r68 r72  
    44
    55
    6 16 Decomber, Thursday (10am-6pm)
     622 December, Wednesday (4 hours)
     7- orientable directional light
     8
     9
     10
     11total = 135 hours (3.6 weeks)
     12subtotal = 22 hours
     13
     14
     1516 December, Thursday (8 hours)
    716- terrain manipulator added
    817- -version flag
  • Swollen/swollen/Makefile

    r69 r72  
    2727COMPILER         =  g++
    2828OBJ              =  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
    3031CPPFLAGS         =  -F/System/Library/Frameworks -Wall -DDARWIN_QUICKTIME \
    3132                    $(OPTIMIZATION)
  • Swollen/swollen/bedslope.cpp

    r65 r72  
    33#include <bedslope.h>
    44
     5#include <osg/Texture>
    56#include <osg/Texture2D>
    6 #include <osg/TexEnv>
     7
    78#include <osgUtil/SmoothingVisitor>
    89
     
    2223    // geometry from sww file
    2324    osg::Vec3Array* vertices = _sww->getBedslopeVertexArray().get();
    24     //osg::Vec3Array* normals = _sww->getBedslopeNormalArray().get();
    2525
    26     _geom->setUseDisplayList(true);
     26    _geom->setUseDisplayList( true );
    2727    _geom->setVertexArray( vertices );
    2828    _geom->addPrimitiveSet( _sww->getBedslopeIndexArray().get() );
    29     //_geom->setNormalArray( normals );
    30     //_geom->setNormalBinding( osg::Geometry::BIND_PER_PRIMITIVE );
    3129    _geom->setTexCoordArray( 0, _sww->getBedslopeTextureCoords().get() );
    3230
    3331    osg::UByte4Array* color = new osg::UByte4Array(1);
    34     (*color)[0] = osg::UByte4( 255,255,255,255 );
     32    (*color)[0] = osg::UByte4( DEF_BEDSLOPE_COLOUR );
    3533    _geom->setColorArray( color );
    3634    _geom->setColorBinding( osg::Geometry::BIND_OVERALL );
     
    4139
    4240    // bedslope texture
     41    _texture = true;
    4342    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 );
    4746    texture->setImage( _sww->getBedslopeTexture() );
    4847
    4948    // material
    5049    _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) );
    5256    _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) );
    5458    _material->setEmission( osg::Material::FRONT_AND_BACK, osg::Vec4(0.0, 0.0, 0.0, 1.0) );
    5559
     
    5862    _stateset = new osg::StateSet;
    5963    _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 );
    6165    _stateset->setMode( GL_BLEND, osg::StateAttribute::ON );
    6266    _stateset->setMode( GL_LIGHTING, osg::StateAttribute::ON );
     
    6973}
    7074
     75
     76void 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  
    2929    virtual osg::Geode* get(){ return _node; }
    3030    virtual osg::BoundingBox getBound(){ return _geom->getBound(); }
     31    virtual void toggleTexture();
     32
    3133
    3234protected:
     
    3840    osg::Material* _material;
    3941    virtual ~BedSlope(){;}
     42    bool _texture;
    4043
    4144};
  • Swollen/swollen/keyboardeventhandler.cpp

    r71 r72  
    7777                break;
    7878
    79             case 'm':
     79            case 'l':
    8080                _togglemanipulatormode = true;
    8181                handled = true;
  • Swollen/swollen/main.cpp

    r71 r72  
    2020#include <hud.h>
    2121#include <keyboardeventhandler.h>
    22 #include <spotlight.h>
     22//#include <spotlight.h>
     23#include <directionallight.h>
    2324#include <watersurface.h>
    2425
     
    4445    arguments.getApplicationUsage()->addCommandLineOption("-hmin <float>","Height below which transparency is set to zero");   
    4546    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");
    4849    arguments.getApplicationUsage()->addCommandLineOption("-nosky","Omit background sky");
    4950    arguments.getApplicationUsage()->addCommandLineOption("-texture <file>","Image to use for bedslope topography");
     
    135136
    136137    // Lighting
    137     SpotLight* spotlight = new SpotLight(rootStateSet);
    138     spotlight->setPosition( osg::Vec3(0,1,0) );  // z is up
    139     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 );
    140141
    141142
     
    143144    rootnode->setStateSet(rootStateSet);
    144145    rootnode->addChild( hud->get() );
    145     rootnode->addChild( spotlight->get() );
     146    rootnode->addChild( light->get() );
    146147    rootnode->addChild(model);
    147148    model->addChild( bedslope->get() );
     
    179180
    180181
    181     // initial camera position
     182    // initial light position
    182183    CustomTrackballManipulator* trackball = viewer.getTrackball();
    183184    trackball->setNode( model );
     
    191192
    192193
     194    // initial camera position
    193195    CustomTerrainManipulator* terrainmanipulator = viewer.getTerrainManipulator();
    194     terrainmanipulator->setNode( rootnode );
     196    terrainmanipulator->setNode( model );
    195197    terrainmanipulator->setAutoComputeHomePosition( false );
    196198    terrainmanipulator->setHomePosition(
     
    219221            water->setTimeStep(timestep);
    220222            hud->setTime( sww->getTime(timestep) );
     223
     224            // bedslope->toggleTexture();
     225
    221226        }
    222227
     
    225230        {
    226231            //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 );
    231236        }
    232237
     
    243248                trackball->disable();
    244249                terrainmanipulator->enable();
     250                light->hide();
    245251            }
    246252            else
     
    248254                trackball->enable();
    249255                terrainmanipulator->disable();
     256                light->show();
    250257            }
    251258        }
  • Swollen/swollen/spotlight.cpp

    r65 r72  
    1414{
    1515    // positioning container
    16     _group = new osg::MatrixTransform;
    17     _group->setCullingActive(false);
     16    _transform = new osg::MatrixTransform;
     17    _transform->setCullingActive(false);
    1818
    1919    // OpenGL light
     
    2121    _light->setLightNum(num);
    2222    _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));
    2424    _light->setDiffuse(osg::Vec4(1,1,1,1));
    2525    _light->setSpecular(osg::Vec4(1,1,1,1));
     
    3333    _source->setLocalStateSetModes( osg::StateAttribute::ON );
    3434    _source->setStateSetModes( *rootStateSet, osg::StateAttribute::ON );
    35     _group->addChild( _source );
     35    _transform->addChild( _source );
    3636
    3737    // create cone marker for spotlight and rotate towards origin
     
    4444
    4545    // omit marker cone for now (FIX ME)
    46     _group->addChild(_marker);
     46    _transform->addChild(_marker);
    4747
    4848    setPosition( osg::Vec3(0,0,1) );  // default overhead
     
    6767    quat.makeRotate( osg::Vec3(0,0,-1), origindir );
    6868
    69     _group->setMatrix( osg::Matrix::rotate( quat ) * osg::Matrix::translate(v) );
     69    _transform->setMatrix( osg::Matrix::rotate( quat ) * osg::Matrix::translate(v) );
    7070}
    7171
  • Swollen/swollen/spotlight.h

    r6 r72  
    3232
    3333    SpotLight(osg::StateSet* rootStateSet, int num=0);
    34     virtual osg::Group* get(){ return _group; }
     34    virtual osg::Group* get(){ return _transform; }
    3535    virtual void setPosition(osg::Vec3 v);
    3636    virtual osg::Vec3f* getPosition(){ return _position; }
    3737    void setSpotAngle( float degrees );
    38     void setMatrix( osg::Matrixf matrix ){ _group->setMatrix( matrix ); }
     38    void setMatrix( osg::Matrixf matrix ){ _transform->setMatrix( matrix ); }
    3939    void setAmbient( osg::Vec3f v ){ _light->setAmbient(osg::Vec4(v,1)); }
    4040    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(); }
    4242
    4343
    4444protected:
    4545
    46     //osg::Group* _group;
    47     osg::MatrixTransform* _group;
     46    osg::MatrixTransform* _transform;
    4847    osg::Vec3* _position;
    4948    osg::Vec3* _target;
  • Swollen/swollen/version.cpp

    r71 r72  
    1 const char* version() { const char* s = "Revision: 70M"; return s; }
     1const char* version() { const char* s = "Revision: 70:71M"; return s; }
  • Swollen/swollen/watersurface.cpp

    r64 r72  
    1616#include <osg/TexGen>
    1717
    18 #include <osgDB/Registry>
    1918#include <osgDB/ReadFile>
    20 
    2119#include <osgUtil/TriStripVisitor>
    2220
Note: See TracChangeset for help on using the changeset viewer.