source: Swollen/swollen/animation.cpp @ 125

Last change on this file since 125 was 125, checked in by darran, 19 years ago
  • adding -movie ability ...
File size: 896 bytes
Line 
1/*
2  SWWViewer
3
4  An OpenSceneGraph viewer for pyVolution SWW files.
5  copyright (C) 2004-2005 Geoscience Australia
6*/
7
8
9#include <iostream>
10#include <osg/Image>
11#include <osgDB/WriteFile>
12#include <osgDB/FileNameUtils>
13#include <animation.h>
14
15
16Animation::Animation()
17{
18   _save = false;
19   _image = new osg::Image;
20
21}
22
23
24
25void Animation::setDirectory( std::string dirname )
26{
27   osgDB::makeDirectory( dirname );
28   _dirname = dirname;
29   _valid = true;
30}
31
32
33
34void Animation::setViewer( CustomViewer viewer )
35{
36   viewer.getCamera(0)->getProjectionRectangle( _x, _y, _width, _height );
37}
38
39
40
41
42bool Animation::saveImage( unsigned int playback_index )
43{
44
45   _image->readPixels( _x, _y, _width, _height, GL_RGB, GL_UNSIGNED_BYTE);
46
47   if ( osgDB::writeImageFile(*_image, "image.jpg") )
48   {
49      std::cout << "Saved image " << playback_index << std::endl;
50      return true;
51   }
52
53   return false;
54
55}
Note: See TracBrowser for help on using the repository browser.