Changeset 132 for Swollen/swollen


Ignore:
Timestamp:
Aug 15, 2005, 9:28:17 PM (20 years ago)
Author:
darran
Message:

Last release version changes

Location:
Swollen/swollen
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Swollen/swollen/animation.cpp

    r125 r132  
    88
    99#include <iostream>
     10#include <string>
    1011#include <osg/Image>
    1112#include <osgDB/WriteFile>
    12 #include <osgDB/FileNameUtils>
     13#include <osgDB/FileUtils>
     14//#include <osgDB/FileNameUtils>
    1315#include <animation.h>
    1416
     
    1618Animation::Animation()
    1719{
    18    _save = false;
     20   _valid = false;
    1921   _image = new osg::Image;
    2022
     
    4244bool Animation::saveImage( unsigned int playback_index )
    4345{
    44 
    4546   _image->readPixels( _x, _y, _width, _height, GL_RGB, GL_UNSIGNED_BYTE);
    4647
    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) )
    4854   {
    49       std::cout << "Saved image " << playback_index << std::endl;
     55      std::cout << "Saved " << filename << std::endl;
    5056      return true;
    5157   }
  • Swollen/swollen/animation.h

    r125 r132  
    3333   unsigned int _width, _height;
    3434   osg::ref_ptr<osg::Image> _image;
    35    bool _save;
     35   bool _valid;
    3636};
    3737
  • 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*/
    17
    28#include "customargumentparser.h"
    39#include <fstream>
    410#include <iostream>
     11#include <osgDB/FileNameUtils>
    512
    613
     
    1623   _filename = new std::string(argv[*argc-1]);
    1724
    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") )
    2027   {
    2128      _isswm = true;
  • Swollen/swollen/main.cpp

    r125 r132  
    5656   arguments.getApplicationUsage()->addCommandLineOption("-lightpos <float>,<float>,<float>", "x,y,z of bedslope directional light (z is up, default is overhead)");
    5757   arguments.getApplicationUsage()->addCommandLineOption("-movie <dirname>", "Save numbered images to named directory and quit");
     58   arguments.getApplicationUsage()->addCommandLineOption("-loop", "Repeated (looped) playback of .swm files");
    5859   arguments.getApplicationUsage()->addCommandLineOption("-nosky", "Omit background sky");
    5960   arguments.getApplicationUsage()->addCommandLineOption("-cullangle <float angle 0-90>", "Cull triangles steeper than this value");
     
    7879   bool recordingmode = false;
    7980   bool savemovie = false;
     81   bool loop = false;
    8082   unsigned int playback_index = 0;
    8183   std::string moviedir;
     
    9294         animation.setViewer( viewer );
    9395      }
     96      if( arguments.read("-loop") )
     97         loop = true;
    9498   }
    9599   else
     
    97101      playbackmode = false;
    98102      savemovie = false;
     103      loop = true;  // playback in none macro mode should loop (otherwise you don't get a chance to save)
    99104   }
    100105
     
    123128   std::string swwfile = arguments.argv()[lastarg];
    124129   arguments.remove(lastarg);
    125    if( swwfile.substr(swwfile.size()-4,4).find(".sww",0) == -1 )  // ensure filename ends in .sww
     130   if( osgDB::getLowerCaseFileExtension(swwfile) != std::string("sww") )
    126131   {
    127132      std::cout << "Require last argument be an .sww/.swm file ... quitting" << std::endl;
     
    247252 
    248253   unsigned int timestep = 0;
    249    while( !viewer.done() )
     254   bool done = false;
     255   while( !done )
    250256   {
    251257   
    252258      // wait for all cull and draw threads to complete.
    253259      viewer.sync();
     260
     261      // user hits 'escape' to exit
     262      if( viewer.done() )
     263         done = true;
    254264
    255265
     
    327337         playback_index ++;
    328338         if( playback_index == statelist.size() )
    329             playback_index = 0;
     339         {
     340            if( loop )
     341               playback_index = 0;
     342            else
     343               done = true;
     344         }
    330345
    331346         // '2' key stops playback of recorded frames
     
    354369            f.close();
    355370         }
     371         std::cout << "Wrote macro file movie.swm" << std::endl;
    356372      }
    357373
  • Swollen/swollen/main.vcproj

    r120 r132  
    123123                        UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
    124124                        <File
     125                                RelativePath=".\animation.cpp">
     126                        </File>
     127                        <File
    125128                                RelativePath=".\bedslope.cpp">
    126129                        </File>
     
    176179                        UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
    177180                        <File
     181                                RelativePath=".\animation.h">
     182                        </File>
     183                        <File
    178184                                RelativePath=".\bedslope.h">
    179185                        </File>
Note: See TracChangeset for help on using the changeset viewer.