Changeset 73


Ignore:
Timestamp:
Dec 23, 2004, 7:16:44 PM (20 years ago)
Author:
darran
Message:
  • orientable light (toggle with 'l' key)
  • bedslope lighting fixed
Location:
Swollen
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • Swollen/doc/contract2_hours.txt

    r72 r73  
    33------------------
    44
     523 December, Thursday (4 hours)
     6- bedslope lighting
    57
    6822 December, Wednesday (4 hours)
  • Swollen/doc/contract2_priorities.txt

    r68 r73  
    2828
    2929
     30
    3031COMPLETED:
    3132
     
    3435- added -nosky command-line option to appease those who want a plain background [?]
    3536- add -version command line flag synced with Subversion revision number (useful for debugging) [?]
    36 
     37- Interactive positioning of light(s) [0]
     38- Ability to have shading on bed-surface. This was the case with
     39  distro31052004 and is very useful with large scale topographies.
     40  Please have a look at the file Hobart_first_order_size77670.sww using
     41  both swwviewer and swollen and let Ole know what you think.
     42  Perhaps default to that standard background in the absence of bedslope.jpg
     43  or perhaps tie in with the geotiff item by having such a default behaviour.
    3744
    3845
     
    4451- Output coordinates defining camera position [?]
    4552- Ability to handle scenes with a resolution of 500,000+ triangles [3]
    46 - Interactive positioning of light(s) [0]
    47 - Ability to have shading on bed-surface. This was the case with
    48   distro31052004 and is very useful with large scale topographies.
    49   Please have a look at the file Hobart_first_order_size77670.sww using
    50   both swwviewer and swollen and let Ole know what you think.
    51   Perhaps default to that standard background in the absence of bedslope.jpg
    52   or perhaps tie in with the geotiff item by having such a default behaviour.
    5353
    5454
     
    6262- Problems with Duncan's, Chris' and Stephen Roberts' machines at GA: Swollen won't render semi
    6363  transparency. Swwviewer works fine. (This appeared to work on Dunca's computer 13/12/4?).
    64 - toggle wireframe not working on Mac
     64
    6565
    6666
    6767BUGS FIXED:
    6868
     69- toggle wireframe not working on Mac
    6970- can no longer make model disappear by pushing back through sky [2004-12-15]
    7071- Swollen starts up showing first time step, not zeroth (even though clock shows zero). Stepping one
     
    7576- memory leak occurring when loading subsequent stages fixed by use
    7677  of ref_ptrs in SWWReader
     78
    7779
    7880
  • Swollen/swollen/directionallight.cpp

    r72 r73  
    2222    _light = new osg::Light;
    2323    _light->setLightNum(num);
    24     _light->setPosition( osg::Vec4(0,0,1,0) );
    25     _light->setAmbient( osg::Vec4(0.7,0.7,0.7,1) );
    26     _light->setDiffuse( osg::Vec4(1,1,1,1) );
    27     _light->setSpecular( osg::Vec4(1,1,1,1) );
     24
     25    // homogeneous coordinates (x,y,z,w), w=0 indicates position at infinity
     26    _light->setPosition( osg::Vec4( 0, 0, 1, 0 ) );
     27
     28    _light->setAmbient( osg::Vec4( 0.7, 0.7, 0.7, 1.0 ) );
     29    _light->setDiffuse( osg::Vec4( 1.0, 1.0, 1.0, 1.0 ) );
     30    _light->setSpecular( osg::Vec4( 1.0, 1.0, 1.0, 1.0) );
    2831
    2932    // Scenegraph node
     
    3538    _transform->addChild( _source );
    3639
    37     // create marker cylinder and rotate towards origin
    38     _marker = new osg::Geode;
    39     _marker->setName("directionallight");
    40     _shape = new osg::Cylinder;
    41     _shape->setRadius( DEF_DEFAULT_CYLINDER_RADIUS );
    42     _shape->setHeight( DEF_DEFAULT_CYLINDER_HEIGHT );
    43     _shape->setCenter( osg::Vec3(0,0,0) );
    44     _marker->addDrawable( new osg::ShapeDrawable(_shape) );
     40
     41    // marker geometry, texture and state
     42    _marker = osgDB::readNodeFile( "light.osg" );
    4543    _transform->addChild( _marker );
    46 
    47     // marker geometry texture
    48     osg::Texture2D* texture = new osg::Texture2D;
    49     texture->setDataVariance( osg::Object::STATIC );
    50     texture->setBorderColor( osg::Vec4(1.0f,1.0f,1.0f,0.5f) );
    51     texture->setWrap( osg::Texture::WRAP_S, osg::Texture::REPEAT );
    52     texture->setImage( osgDB::readImageFile("../images/gastacked.jpg") );
    53 
    54     // state
    55     _stateset = new osg::StateSet;
    56     _stateset->setTextureAttributeAndModes( 0, texture, osg::StateAttribute::ON );
    57     _marker->setStateSet( _stateset );
    5844
    5945
     
    6551void DirectionalLight::setPosition(osg::Vec3 v)
    6652{
     53
     54    //std::cout << "[DirectionalLight::setPosition] vector = " << v << std::endl;
    6755    osg::Vec3 origindir;
    6856    osg::Quat quat;
  • Swollen/swollen/directionallight.h

    r72 r73  
    5151    osg::LightSource* _source;
    5252
    53     osg::Geode* _marker;
     53    osg::Node* _marker;
    5454    osg::Cylinder* _shape;
    5555    osg::Geometry* _geom;
  • Swollen/swollen/main.cpp

    r72 r73  
    5757    viewer.setUpViewer( osgProducer::Viewer::STANDARD_SETTINGS );
    5858    viewer.setClearColor( osg::Vec4(DEF_BACKGROUND_COLOUR) );
    59     viewer.getCamera(0)->getRenderSurface()->setWindowRectangle(200,100,800,600);
     59    viewer.getCamera(0)->getRenderSurface()->setWindowRectangle(200,300,800,600);
    6060    viewer.getCullSettings().setComputeNearFarMode( osg::CullSettings::COMPUTE_NEAR_FAR_USING_PRIMITIVES );
    6161
     
    137137    // Lighting
    138138    DirectionalLight* light = new DirectionalLight(rootStateSet);
    139     light->setPosition( osg::Vec3(0,1,0) );  // z is up
    140     // spotlight->setSpotAngle( 45.0 );
     139    light->setPosition( osg::Vec3(0,0,2) );  // z is up
    141140
    142141
     
    181180
    182181    // initial light position
    183     CustomTrackballManipulator* trackball = viewer.getTrackball();
    184     trackball->setNode( model );
    185     trackball->setAutoComputeHomePosition( false );
    186     trackball->setHomePosition(
    187         osg::Vec3d(0,1,0),    // location
    188         osg::Vec3d(0,0,0),     // target
    189         osg::Vec3d(0,0,1) );   // up vector
    190     trackball->moveToHome();
    191     trackball->disable();
     182    CustomTrackballManipulator* lightmanipulator = viewer.getTrackball();
     183    lightmanipulator->setNode( model );
     184    lightmanipulator->setAutoComputeHomePosition( false );
     185    lightmanipulator->setByInverseMatrix( osg::Matrixd( -0.707107, -0.408248,  0.57735,  0.0,
     186                                                         0.0,       0.816497,  0.57735,  0.0,
     187                                                        -0.707107,  0.408248, -0.57735,  0.0,
     188                                                         0.0,       0.0,       2.0,      1.0 ) );
     189    lightmanipulator->disable();
    192190
    193191
     
    227225
    228226        // light position manipulator
    229         if( trackball->isEnabled() )
     227        if( lightmanipulator->isEnabled() )
    230228        {
    231             //osg::Matrixd matrix = trackball->getInverseMatrix();
    232             osg::Matrixd matrix = trackball->getMatrix();
     229            osg::Matrixd matrix = lightmanipulator->getInverseMatrix();
     230            //std::cout << matrix << std::endl;
    233231            osg::Vec3d position = matrix.getTrans();
    234             //std::cout << "trackball position x: " << position. << std::endl;
    235             light->setPosition( -position );
     232            light->setPosition( position );
    236233        }
    237234
     
    244241        if( event_handler->toggleManipulatorMode() )
    245242        {
    246             if( trackball->isEnabled() )
     243            if( lightmanipulator->isEnabled() )
    247244            {
    248                 trackball->disable();
     245                lightmanipulator->disable();
    249246                terrainmanipulator->enable();
    250247                light->hide();
     
    252249            else
    253250            {
    254                 trackball->enable();
     251                lightmanipulator->enable();
    255252                terrainmanipulator->disable();
    256253                light->show();
  • Swollen/swollen/version.cpp

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

    r72 r73  
    1919#include <osgUtil/TriStripVisitor>
    2020
    21 #define DEF_ALPHA_THRESHOLD 0.01
     21#define DEF_ALPHA_THRESHOLD 0.05
    2222
    2323
Note: See TracChangeset for help on using the changeset viewer.