Changeset 66


Ignore:
Timestamp:
Dec 16, 2004, 5:29:40 PM (19 years ago)
Author:
darran
Message:
 
Location:
Swollen/swollen
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • Swollen/swollen/Makefile

    r6 r66  
    2727COMPILER         =  g++
    2828OBJ              =  customviewer.o hud.o keyboardeventhandler.o watersurface.o main.o \
    29                     bedslope.o createSky.o customtrackball.o spotlight.o
     29                    bedslope.o createSky.o customtrackball.o customterrainmanipulator.o spotlight.o
    3030CPPFLAGS         =  -F/System/Library/Frameworks -Wall -DDARWIN_QUICKTIME \
    3131                    $(OPTIMIZATION)
  • Swollen/swollen/customtrackball.cpp

    r6 r66  
    66*/
    77
     8#include <iostream>
    89#include "customtrackball.h"
     10
    911
    1012void CustomTrackballManipulator::moveToHome()
    1113{
    12     computePosition(_homeEye, _homeCenter, _homeUp);
     14    computePosition( _homeEye, _homeCenter, _homeUp );
    1315}
     16
     17
     18bool CustomTrackballManipulator::handle( const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us )
     19{
     20    if( _disabled )
     21        return false;
     22    else
     23    {
     24        // std::cout << "customtrackballmanipulator active" << std::endl;
     25        return osgGA::TrackballManipulator::handle( ea, us );
     26    }
     27}
     28
  • Swollen/swollen/customtrackball.h

    r6 r66  
     1
     2
     3#ifndef CUSTOMTRACKBALL_H
     4#define CUSTOMTRACKBALL_H
     5
    16
    27#include <project.h>
    38#include <osgGA/TrackballManipulator>
     9#include <osgGA/GUIActionAdapter>
     10#include <osgGA/GUIEventAdapter>
     11
    412
    513class CustomTrackballManipulator : public osgGA::TrackballManipulator
     
    715
    816public:
     17
    918    void moveToHome();
     19    virtual bool handle( const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us );
     20    void disable(){ _disabled = true ;}
     21    void enable(){ _disabled = false ;}
     22
    1023
    1124protected:
    1225
     26    bool _disabled;
     27
    1328};
    1429
     30#endif  // CUSTOMTRACKBALL_H
  • Swollen/swollen/customviewer.cpp

    r65 r66  
    6060    _updateVisitor->setFrameStamp(_frameStamp.get());
    6161
     62
    6263    _trackball = new CustomTrackballManipulator;
     64    _eventHandlerList.push_back( _trackball );
    6365
    64     // FIXME: trying to eliminate need for keyswitchmanipulator
    65     //_eventHandlerList.push_back( _trackball );
    66     if (options&TRACKBALL_MANIPULATOR) addCameraManipulator(_trackball);
     66    _terrainmanipulator = new CustomTerrainManipulator;
     67    if (options&TERRAIN_MANIPULATOR) addCameraManipulator( _terrainmanipulator );
     68    //if (options&TRACKBALL_MANIPULATOR) addCameraManipulator( _trackball );
     69
    6770   
    6871    if (options&STATE_MANIPULATOR)
    6972    {
    7073        osg::ref_ptr<osgGA::StateSetManipulator> statesetManipulator = new osgGA::StateSetManipulator;
    71         statesetManipulator->setStateSet(getGlobalStateSet());
    72         _eventHandlerList.push_back(statesetManipulator.get());
     74        statesetManipulator->setStateSet( getGlobalStateSet() );
     75        _eventHandlerList.push_back( statesetManipulator.get() );
    7376    }
    7477       
  • Swollen/swollen/customviewer.h

    r6 r66  
    33#include <osgProducer/Viewer>
    44#include "customtrackball.h"
     5#include "customterrainmanipulator.h"
    56
    67
     
    1213    void setUpViewer(unsigned int options=STANDARD_SETTINGS);
    1314    virtual CustomTrackballManipulator* getTrackball(){return _trackball;}
     15    virtual CustomTerrainManipulator* getTerrainManipulator(){return _terrainmanipulator;}
    1416
    1517protected:
    1618    CustomTrackballManipulator* _trackball;
     19    CustomTerrainManipulator* _terrainmanipulator;
    1720
    1821};
  • Swollen/swollen/keyboardeventhandler.h

    r48 r66  
    1717
    1818public:
    19         KeyboardEventHandler( int nTimesteps, float tps);
     19    KeyboardEventHandler( int nTimesteps, float tps);
    2020    virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&);
    21         virtual void accept(osgGA::GUIEventHandlerVisitor&) {}
    22         virtual bool isPaused(){return _paused;}
    23         virtual bool timestepChanged();
    24         virtual bool toggleWireframe();
    25         virtual int getTimestep(){return (unsigned int) _timestep;}
    26         virtual void setTime(float time);
     21    virtual void accept(osgGA::GUIEventHandlerVisitor&) {}
     22    virtual bool isPaused(){return _paused;}
     23    virtual bool timestepChanged();
     24    virtual bool toggleWireframe();
     25    virtual int getTimestep(){return (unsigned int) _timestep;}
     26    virtual void setTime(float time);
    2727
    2828private:
    29         int _direction, _timestep, _ntimesteps;
    30         float _tps, _prevtime, _tpsorig;
    31         bool _paused, _timestepchanged, _togglewireframe;
     29    int _direction, _timestep, _ntimesteps;
     30    float _tps, _prevtime, _tpsorig;
     31    bool _paused, _timestepchanged, _togglewireframe;
    3232};
    3333
  • Swollen/swollen/main.cpp

    r65 r66  
    1616#include <SWWReader.h>
    1717#include <bedslope.h>
     18#include <customtrackball.h>
    1819#include <customviewer.h>
    1920#include <hud.h>
     
    2122#include <spotlight.h>
    2223#include <watersurface.h>
     24#include <version.h>
    2325
    2426
     
    4648    arguments.getApplicationUsage()->addCommandLineOption("-nosky","Omit background sky");
    4749    arguments.getApplicationUsage()->addCommandLineOption("-texture <file>","Image to use for bedslope topography");
     50    arguments.getApplicationUsage()->addCommandLineOption("-version","Revision number and creation (not compile) date");
    4851
    4952    // construct the viewer.
     
    6669        return 1;
    6770    }
     71
     72    // version info
     73    if( arguments.read("-version") )
     74    {
     75        std::cout << version() << std::endl;
     76        return 1;
     77    }
     78
    6879
    6980
     
    169180
    170181    // initial camera position
     182    CustomTrackballManipulator* trackball = viewer.getTrackball();
    171183    viewer.getTrackball()->setNode( rootnode );
    172184    viewer.getTrackball()->setAutoComputeHomePosition( false );
     
    176188        osg::Vec3d(0,0,1) );   // camera up vector
    177189    viewer.getTrackball()->moveToHome();
     190    viewer.getTrackball()->disable();
     191
     192
     193    viewer.getTerrainManipulator()->setNode( rootnode );
     194    viewer.getTerrainManipulator()->setAutoComputeHomePosition( false );
     195    viewer.getTerrainManipulator()->setHomePosition(
     196        osg::Vec3d(0,-3,0),    // camera location
     197        osg::Vec3d(0,0,0),     // camera target
     198        osg::Vec3d(0,0,1) );   // camera up vector
     199    viewer.getTerrainManipulator()->moveToHome();
     200    viewer.getTerrainManipulator()->enable();
    178201
    179202
     
    194217            water->setTimeStep(timestep);
    195218            hud->setTime( sww->getTime(timestep) );
     219
     220            // light position manipulator matrix
     221            osg::Matrixd matrix = trackball->getInverseMatrix();
     222            std::cout << matrix << std::endl;
     223
    196224        }
    197225
     
    199227        if( event_handler->toggleWireframe() )
    200228            water->toggleWireframe();
    201 
    202229
    203230        // update the scene by traversing with the update visitor
Note: See TracChangeset for help on using the changeset viewer.