Changeset 132 for Swollen/swollen
- Timestamp:
- Aug 15, 2005, 9:28:17 PM (20 years ago)
- Location:
- Swollen/swollen
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Swollen/swollen/animation.cpp
r125 r132 8 8 9 9 #include <iostream> 10 #include <string> 10 11 #include <osg/Image> 11 12 #include <osgDB/WriteFile> 12 #include <osgDB/FileNameUtils> 13 #include <osgDB/FileUtils> 14 //#include <osgDB/FileNameUtils> 13 15 #include <animation.h> 14 16 … … 16 18 Animation::Animation() 17 19 { 18 _ save= false;20 _valid = false; 19 21 _image = new osg::Image; 20 22 … … 42 44 bool Animation::saveImage( unsigned int playback_index ) 43 45 { 44 45 46 _image->readPixels( _x, _y, _width, _height, GL_RGB, GL_UNSIGNED_BYTE); 46 47 47 if ( osgDB::writeImageFile(*_image, "image.jpg") ) 48 // restricted to 9999 frames (famous last words but that should be enough ;-) 49 char nstr[5]; 50 sprintf(nstr, "%04d", playback_index); 51 52 std::string filename = std::string( _dirname + "/frame" + nstr + ".jpg" ); 53 if ( osgDB::writeImageFile(*_image, filename) ) 48 54 { 49 std::cout << "Saved image " << playback_index<< std::endl;55 std::cout << "Saved " << filename << std::endl; 50 56 return true; 51 57 } -
Swollen/swollen/animation.h
r125 r132 33 33 unsigned int _width, _height; 34 34 osg::ref_ptr<osg::Image> _image; 35 bool _ save;35 bool _valid; 36 36 }; 37 37 -
Swollen/swollen/customargumentparser.cpp
r121 r132 1 /* 2 SWWViewer 3 4 An OpenSceneGraph viewer for pyVolution SWW files. 5 copyright (C) 2004-2005 Geoscience Australia 6 */ 1 7 2 8 #include "customargumentparser.h" 3 9 #include <fstream> 4 10 #include <iostream> 11 #include <osgDB/FileNameUtils> 5 12 6 13 … … 16 23 _filename = new std::string(argv[*argc-1]); 17 24 18 // ends in .swm?19 if( _filename->substr(_filename->size()-4,4).find(".swm",0) != -1 )25 // macro file? 26 if( osgDB::getLowerCaseFileExtension(*_filename) == std::string("swm") ) 20 27 { 21 28 _isswm = true; -
Swollen/swollen/main.cpp
r125 r132 56 56 arguments.getApplicationUsage()->addCommandLineOption("-lightpos <float>,<float>,<float>", "x,y,z of bedslope directional light (z is up, default is overhead)"); 57 57 arguments.getApplicationUsage()->addCommandLineOption("-movie <dirname>", "Save numbered images to named directory and quit"); 58 arguments.getApplicationUsage()->addCommandLineOption("-loop", "Repeated (looped) playback of .swm files"); 58 59 arguments.getApplicationUsage()->addCommandLineOption("-nosky", "Omit background sky"); 59 60 arguments.getApplicationUsage()->addCommandLineOption("-cullangle <float angle 0-90>", "Cull triangles steeper than this value"); … … 78 79 bool recordingmode = false; 79 80 bool savemovie = false; 81 bool loop = false; 80 82 unsigned int playback_index = 0; 81 83 std::string moviedir; … … 92 94 animation.setViewer( viewer ); 93 95 } 96 if( arguments.read("-loop") ) 97 loop = true; 94 98 } 95 99 else … … 97 101 playbackmode = false; 98 102 savemovie = false; 103 loop = true; // playback in none macro mode should loop (otherwise you don't get a chance to save) 99 104 } 100 105 … … 123 128 std::string swwfile = arguments.argv()[lastarg]; 124 129 arguments.remove(lastarg); 125 if( swwfile.substr(swwfile.size()-4,4).find(".sww",0) == -1 ) // ensure filename ends in .sww130 if( osgDB::getLowerCaseFileExtension(swwfile) != std::string("sww") ) 126 131 { 127 132 std::cout << "Require last argument be an .sww/.swm file ... quitting" << std::endl; … … 247 252 248 253 unsigned int timestep = 0; 249 while( !viewer.done() ) 254 bool done = false; 255 while( !done ) 250 256 { 251 257 252 258 // wait for all cull and draw threads to complete. 253 259 viewer.sync(); 260 261 // user hits 'escape' to exit 262 if( viewer.done() ) 263 done = true; 254 264 255 265 … … 327 337 playback_index ++; 328 338 if( playback_index == statelist.size() ) 329 playback_index = 0; 339 { 340 if( loop ) 341 playback_index = 0; 342 else 343 done = true; 344 } 330 345 331 346 // '2' key stops playback of recorded frames … … 354 369 f.close(); 355 370 } 371 std::cout << "Wrote macro file movie.swm" << std::endl; 356 372 } 357 373 -
Swollen/swollen/main.vcproj
r120 r132 123 123 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> 124 124 <File 125 RelativePath=".\animation.cpp"> 126 </File> 127 <File 125 128 RelativePath=".\bedslope.cpp"> 126 129 </File> … … 176 179 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> 177 180 <File 181 RelativePath=".\animation.h"> 182 </File> 183 <File 178 184 RelativePath=".\bedslope.h"> 179 185 </File>
Note: See TracChangeset
for help on using the changeset viewer.