Changeset 125
- Timestamp:
- Jul 11, 2005, 5:45:03 PM (20 years ago)
- Location:
- Swollen/swollen
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
Swollen/swollen/Makefile
r121 r125 29 29 OBJ = customviewer.o hud.o keyboardeventhandler.o watersurface.o main.o version.o \ 30 30 bedslope.o createSky.o customtrackball.o customterrainmanipulator.o spotlight.o \ 31 directionallight.o state.o customviewereventhandler.o customargumentparser.o 31 directionallight.o state.o customviewereventhandler.o customargumentparser.o \ 32 animation.o 32 33 CPPFLAGS = -F/System/Library/Frameworks -Wall -DDARWIN_QUICKTIME \ 33 34 $(OPTIMIZATION) -
Swollen/swollen/customargumentparser.h
r121 r125 20 20 void write(std::ostream& s); 21 21 bool isSWM(){ return _isswm; }; 22 std::string getFilename(){ return *_filename; } 22 23 23 24 -
Swollen/swollen/customviewer.h
r116 r125 1 /* 2 CustomViewer Class 3 4 An OpenSceneGraph viewer for pyVolution .sww files. 5 copyright (C) 2004-2005 Geoscience Australia 6 */ 7 8 9 #ifndef CUSTOMVIEWER_H 10 #define CUSTOMVIEWER_H 11 1 12 2 13 #include <project.h> … … 25 36 }; 26 37 38 #endif // CUSTOMVIEWER_H -
Swollen/swollen/main.cpp
r121 r125 17 17 #include <osgDB/FileNameUtils> 18 18 19 #include <animation.h> 19 20 #include <project.h> 20 21 #include <SWWReader.h> … … 37 38 38 39 // use an ArgumentParser object to manage the program arguments. 39 // this custom version handlesdetects if the last argument is a macro file40 // this custom version detects if the last argument is a macro file 40 41 // and modifies the argument list accordingly so the following code works ... 41 42 CustomArgumentParser arguments( &argc, argv ); … … 72 73 73 74 75 // animation 76 StateList statelist; 77 bool playbackmode; 78 bool recordingmode = false; 79 bool savemovie = false; 80 unsigned int playback_index = 0; 81 std::string moviedir; 82 Animation animation; 83 84 if( arguments.isSWM() ) 85 { 86 playbackmode = true; 87 statelist.read( arguments.getFilename() ); 88 if( arguments.read("-movie",moviedir) ) 89 { 90 savemovie = true; // flag to store frames and quit ... 91 animation.setDirectory( moviedir ); 92 animation.setViewer( viewer ); 93 } 94 } 95 else 96 { 97 playbackmode = false; 98 savemovie = false; 99 } 100 101 74 102 // get details on keyboard and mouse bindings used by the viewer 75 103 viewer.getUsage(*arguments.getApplicationUsage()); 76 104 77 105 // if user requested help, write it out to cout 78 if( arguments.read("-help") )106 if( arguments.read("-help") || arguments.read("--help") || arguments.read("-h") ) 79 107 { 80 108 arguments.getApplicationUsage()->write(std::cout); … … 147 175 HeadsUpDisplay* hud = new HeadsUpDisplay(); 148 176 hud->setTitle("pyVolution SWW Viewer"); 177 if( arguments.isSWM() ) 178 hud->setMode("playback"); 149 179 150 180 … … 214 244 terrainmanipulator->moveToHome(); 215 245 terrainmanipulator->enable(); 216 217 218 // animation219 StateList statelist;220 bool recordingmode = false;221 bool playbackmode = arguments.isSWM() ? true : false;222 unsigned int playback_index = 0;223 246 224 247 … … 290 313 291 314 { 315 // might need to save image from previous pass ... 316 if( savemovie ) 317 animation.saveImage( playback_index ); 318 292 319 // in playback mode 293 320 State state = statelist.at( playback_index ); … … 313 340 } 314 341 342 315 343 // '3' key causes compiled animation to be saved to disk 316 344 if( event_handler->toggleSave() ) -
Swollen/swollen/state.cpp
r121 r125 6 6 */ 7 7 8 9 #define MAX_LINE_LENGTH 200 8 10 9 11 #include <state.h> … … 34 36 35 37 // reconstitute self from named stream 36 void State::read(std::istreams)38 bool State::read(std::istream& s) 37 39 { 38 s >> _timestep; 39 s >> _position.x() >> _position.y() >> _position.z(); 40 s >> _orientation.x() >> _orientation.y() >> _orientation.z() >> _orientation.w(); 41 s >> _culling; 42 s >> _wireframe; 40 s >> _timestep 41 >> _position.x() >> _position.y() >> _position.z() 42 >> _orientation.x() >> _orientation.y() >> _orientation.z() >> _orientation.w() 43 >> _culling 44 >> _wireframe; 45 46 return s.fail() ? false : true; 43 47 } 44 48 … … 81 85 82 86 83 bool StateList::read(std::istream& s) 87 88 89 90 bool StateList::read(std::string filename) 84 91 { 85 // s >> "# SWM DATA" >> std::endl;86 92 87 return true; 93 // attempt to open the macro file ... 94 std::fstream f; 95 f.open( filename.c_str(), std::fstream::in ); 96 if( f.is_open() ) 97 { 98 char str[MAX_LINE_LENGTH]; 99 char *p; 100 int index = 0; 101 102 // search for data section 103 // FIXME: not very safe, what if data section missing? 104 do 105 { 106 f.getline(str, MAX_LINE_LENGTH); 107 p = strstr(str, "# SWM DATA"); 108 index++; 109 110 } while( p != str ); 111 112 113 bool valid; 114 index = 0; 115 do 116 { 117 State* s = new State(); 118 valid = s->read(f); 119 if( valid ) 120 { 121 this->push_back( *s ); 122 index++; 123 } 124 } while( valid ); 125 126 std::cout << "Read " << index << " frames of animation for playback ..." << std::endl; 127 128 f.close(); 129 130 // success only on non-empty animation 131 if( index ) 132 return true; 133 } 134 135 return false; 136 88 137 } -
Swollen/swollen/state.h
r121 r125 65 65 66 66 virtual void write(std::ostream &s); 67 virtual void read(std::istreams);67 virtual bool read(std::istream& s); 68 68 69 69 virtual ~State(); … … 91 91 StateList(); 92 92 bool write(std::ostream& s); 93 bool read(std:: istream& s);93 bool read(std::string filename); 94 94 95 95 //void ~StateList(); -
Swollen/swollen/version.cpp
r121 r125 1 const char* version() { const char* s = "Revision: 120 M"; return s; }1 const char* version() { const char* s = "Revision: 120:121M"; return s; }
Note: See TracChangeset
for help on using the changeset viewer.