Changeset 66
- Timestamp:
- Dec 16, 2004, 5:29:40 PM (20 years ago)
- Location:
- Swollen/swollen
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
Swollen/swollen/Makefile
r6 r66 27 27 COMPILER = g++ 28 28 OBJ = customviewer.o hud.o keyboardeventhandler.o watersurface.o main.o \ 29 bedslope.o createSky.o customtrackball.o spotlight.o29 bedslope.o createSky.o customtrackball.o customterrainmanipulator.o spotlight.o 30 30 CPPFLAGS = -F/System/Library/Frameworks -Wall -DDARWIN_QUICKTIME \ 31 31 $(OPTIMIZATION) -
Swollen/swollen/customtrackball.cpp
r6 r66 6 6 */ 7 7 8 #include <iostream> 8 9 #include "customtrackball.h" 10 9 11 10 12 void CustomTrackballManipulator::moveToHome() 11 13 { 12 computePosition( _homeEye, _homeCenter, _homeUp);14 computePosition( _homeEye, _homeCenter, _homeUp ); 13 15 } 16 17 18 bool 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 1 6 2 7 #include <project.h> 3 8 #include <osgGA/TrackballManipulator> 9 #include <osgGA/GUIActionAdapter> 10 #include <osgGA/GUIEventAdapter> 11 4 12 5 13 class CustomTrackballManipulator : public osgGA::TrackballManipulator … … 7 15 8 16 public: 17 9 18 void moveToHome(); 19 virtual bool handle( const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us ); 20 void disable(){ _disabled = true ;} 21 void enable(){ _disabled = false ;} 22 10 23 11 24 protected: 12 25 26 bool _disabled; 27 13 28 }; 14 29 30 #endif // CUSTOMTRACKBALL_H -
Swollen/swollen/customviewer.cpp
r65 r66 60 60 _updateVisitor->setFrameStamp(_frameStamp.get()); 61 61 62 62 63 _trackball = new CustomTrackballManipulator; 64 _eventHandlerList.push_back( _trackball ); 63 65 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 67 70 68 71 if (options&STATE_MANIPULATOR) 69 72 { 70 73 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() ); 73 76 } 74 77 -
Swollen/swollen/customviewer.h
r6 r66 3 3 #include <osgProducer/Viewer> 4 4 #include "customtrackball.h" 5 #include "customterrainmanipulator.h" 5 6 6 7 … … 12 13 void setUpViewer(unsigned int options=STANDARD_SETTINGS); 13 14 virtual CustomTrackballManipulator* getTrackball(){return _trackball;} 15 virtual CustomTerrainManipulator* getTerrainManipulator(){return _terrainmanipulator;} 14 16 15 17 protected: 16 18 CustomTrackballManipulator* _trackball; 19 CustomTerrainManipulator* _terrainmanipulator; 17 20 18 21 }; -
Swollen/swollen/keyboardeventhandler.h
r48 r66 17 17 18 18 public: 19 19 KeyboardEventHandler( int nTimesteps, float tps); 20 20 virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&); 21 22 23 24 25 26 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); 27 27 28 28 private: 29 30 31 29 int _direction, _timestep, _ntimesteps; 30 float _tps, _prevtime, _tpsorig; 31 bool _paused, _timestepchanged, _togglewireframe; 32 32 }; 33 33 -
Swollen/swollen/main.cpp
r65 r66 16 16 #include <SWWReader.h> 17 17 #include <bedslope.h> 18 #include <customtrackball.h> 18 19 #include <customviewer.h> 19 20 #include <hud.h> … … 21 22 #include <spotlight.h> 22 23 #include <watersurface.h> 24 #include <version.h> 23 25 24 26 … … 46 48 arguments.getApplicationUsage()->addCommandLineOption("-nosky","Omit background sky"); 47 49 arguments.getApplicationUsage()->addCommandLineOption("-texture <file>","Image to use for bedslope topography"); 50 arguments.getApplicationUsage()->addCommandLineOption("-version","Revision number and creation (not compile) date"); 48 51 49 52 // construct the viewer. … … 66 69 return 1; 67 70 } 71 72 // version info 73 if( arguments.read("-version") ) 74 { 75 std::cout << version() << std::endl; 76 return 1; 77 } 78 68 79 69 80 … … 169 180 170 181 // initial camera position 182 CustomTrackballManipulator* trackball = viewer.getTrackball(); 171 183 viewer.getTrackball()->setNode( rootnode ); 172 184 viewer.getTrackball()->setAutoComputeHomePosition( false ); … … 176 188 osg::Vec3d(0,0,1) ); // camera up vector 177 189 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(); 178 201 179 202 … … 194 217 water->setTimeStep(timestep); 195 218 hud->setTime( sww->getTime(timestep) ); 219 220 // light position manipulator matrix 221 osg::Matrixd matrix = trackball->getInverseMatrix(); 222 std::cout << matrix << std::endl; 223 196 224 } 197 225 … … 199 227 if( event_handler->toggleWireframe() ) 200 228 water->toggleWireframe(); 201 202 229 203 230 // update the scene by traversing with the update visitor
Note: See TracChangeset
for help on using the changeset viewer.