root/OpenSceneGraph/trunk/examples/osgstereoimage/osgstereoimage.cpp @ 9124

Revision 9124, 21.7 kB (checked in by robert, 6 years ago)

From Michael Platings, Converted std::fstream/ifstream/ofstream to osgDB::fstream/ifstream/ofstream and
fopen to osgDB::fopen to facilitate support for wide character filenames using UT8 encoding.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* OpenSceneGraph example, osgstereoimage.
2*
3*  Permission is hereby granted, free of charge, to any person obtaining a copy
4*  of this software and associated documentation files (the "Software"), to deal
5*  in the Software without restriction, including without limitation the rights
6*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7*  copies of the Software, and to permit persons to whom the Software is
8*  furnished to do so, subject to the following conditions:
9*
10*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13*  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15*  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
16*  THE SOFTWARE.
17*/
18
19#include <osgViewer/Viewer>
20#include <osgDB/fstream>
21#include <osgDB/ReadFile>
22#include <osgDB/WriteFile>
23#include <osgUtil/Optimizer>
24
25#include <osg/Geode>
26#include <osg/Notify>
27#include <osg/MatrixTransform>
28#include <osg/Switch>
29#include <osg/TexMat>
30#include <osg/Texture2D>
31
32#include <iostream>
33
34typedef std::vector<std::string> FileList;
35
36osg::Geode* createSectorForImage(osg::Image* image, osg::TexMat* texmat, float s,float t, float radius, float height, float length)
37{
38
39    int numSegments = 20;
40    float Theta = length/radius;
41    float dTheta = Theta/(float)(numSegments-1);
42   
43    float ThetaZero = height*s/(t*radius);
44   
45    // set up the texture.
46    osg::Texture2D* texture = new osg::Texture2D;
47    texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
48    texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
49    texture->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::CLAMP_TO_BORDER);
50    texture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::CLAMP_TO_BORDER);
51    texture->setResizeNonPowerOfTwoHint(false);
52    texture->setImage(image);
53
54    // set up the drawstate.
55    osg::StateSet* dstate = new osg::StateSet;
56    dstate->setMode(GL_CULL_FACE,osg::StateAttribute::OFF);
57    dstate->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
58    dstate->setTextureAttributeAndModes(0, texture,osg::StateAttribute::ON);
59    dstate->setTextureAttribute(0, texmat);
60
61    // set up the geoset.
62    osg::Geometry* geom = new osg::Geometry;
63    geom->setStateSet(dstate);
64
65    osg::Vec3Array* coords = new osg::Vec3Array();
66    osg::Vec2Array* tcoords = new osg::Vec2Array();
67   
68    int i;
69    float angle = -Theta/2.0f;
70    for(i=0;
71        i<numSegments;
72        ++i, angle+=dTheta)
73    {
74        coords->push_back(osg::Vec3(sinf(angle)*radius,cosf(angle)*radius,height*0.5f)); // top
75        coords->push_back(osg::Vec3(sinf(angle)*radius,cosf(angle)*radius,-height*0.5f)); // bottom.
76       
77        tcoords->push_back(osg::Vec2(angle/ThetaZero+0.5f,1.0f)); // top
78        tcoords->push_back(osg::Vec2(angle/ThetaZero+0.5f,0.0f)); // bottom.
79
80    }
81
82    osg::Vec4Array* colors = new osg::Vec4Array();
83    colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
84
85    osg::DrawArrays* elements = new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,coords->size());
86
87   
88
89    geom->setVertexArray(coords);
90    geom->setTexCoordArray(0,tcoords);
91    geom->setColorArray(colors);
92    geom->setColorBinding(osg::Geometry::BIND_OVERALL);
93
94    geom->addPrimitiveSet(elements);
95
96    // set up the geode.
97    osg::Geode* geode = new osg::Geode;
98    geode->addDrawable(geom);
99
100    return geode;
101
102}
103
104osg::Group * loadImages(std::string image1, std::string image2, osg::TexMat* texmatLeft, osg::TexMat* texmatRight, float radius, float height, float length) {
105        osg::ref_ptr<osg::Image> imageLeft = osgDB::readImageFile(image1);
106        osg::ref_ptr<osg::Image> imageRight = osgDB::readImageFile(image2);
107        if (imageLeft.valid() && imageRight.valid())
108        {
109            float average_s = (imageLeft->s()+imageRight->s())*0.5f;
110            float average_t = (imageLeft->t()+imageRight->t())*0.5f;
111            osg::Geode* geodeLeft = createSectorForImage(imageLeft.get(),texmatLeft,average_s,average_t, radius, height, length);
112            geodeLeft->setNodeMask(0x01);
113
114            osg::Geode* geodeRight = createSectorForImage(imageRight.get(),texmatRight,average_s,average_t, radius, height, length);
115            geodeRight->setNodeMask(0x02);
116
117            osg::Group * imageGroup = new osg::Group;
118           
119            imageGroup->addChild(geodeLeft);
120            imageGroup->addChild(geodeRight);
121            return imageGroup;
122        }
123        else
124        {
125            std::cout << "Warning: Unable to load both image files, '"<<image1<<"' & '"<<image2<<"', required for stereo imaging."<<std::endl;
126            return 0;
127        }
128}
129
130// create a switch containing a set of child each containing a
131// stereo image pair.
132osg::Switch* createScene(FileList fileList, osg::TexMat* texmatLeft, osg::TexMat* texmatRight, float radius, float height, float length)
133{
134    osg::Switch* sw = new osg::Switch;
135
136    // load the images.
137    for(unsigned int i=0;i+1<fileList.size();i+=2)
138    {
139        osg::Group * imageGroup = loadImages(fileList[i],fileList[i+1],texmatLeft,texmatRight, radius,  height, length);
140        if (imageGroup) sw->addChild(imageGroup);
141    }
142
143
144    if (sw->getNumChildren()>0)
145    {
146        // select first child.
147        sw->setSingleChildOn(0);
148    }
149
150    return sw;
151}
152
153class SlideEventHandler : public osgGA::GUIEventHandler
154{
155public:
156
157    SlideEventHandler();
158   
159    META_Object(osgStereImageApp,SlideEventHandler);
160
161
162    void set(osg::Switch* sw, float offsetX, float offsetY, osg::TexMat* texmatLeft, osg::TexMat* texmatRight, float timePerSlide, bool autoSteppingActive);
163
164    void set(FileList fileList, osg::Switch* sw, float offsetX, float offsetY, osg::TexMat* texmatLeft, osg::TexMat* texmatRight, float radius, float height, float length, float timePerSlide, bool autoSteppingActive);
165
166
167    virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&);
168   
169    virtual void getUsage(osg::ApplicationUsage& usage) const;
170
171    virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
172   
173    void nextSlide();
174   
175    void previousSlide();
176   
177    void scaleImage(float s);
178   
179    void offsetImage(float ds,float dt);
180
181    void rotateImage(float rx,float ry);
182
183    void initTexMatrices();
184
185protected:
186
187    ~SlideEventHandler() {}
188    SlideEventHandler(const SlideEventHandler&,const osg::CopyOp&) {}
189
190    osg::ref_ptr<osg::Switch>   _switch;
191    osg::ref_ptr<osg::TexMat>   _texmatLeft;
192    osg::ref_ptr<osg::TexMat>   _texmatRight;
193    float                        _radius;
194    float                        _height;
195    float                        _length;
196    bool                        _firstTraversal;
197    unsigned int                _activeSlide;
198    double                      _previousTime;
199    double                      _timePerSlide;
200    bool                        _autoSteppingActive;
201    float                       _initSeperationX;
202    float                       _currentSeperationX;
203    float                       _initSeperationY;
204    float                       _currentSeperationY;
205    FileList                     _fileList;
206       
207};
208
209SlideEventHandler::SlideEventHandler():
210    _switch(0),
211    _texmatLeft(0),
212    _texmatRight(0),
213    _firstTraversal(true),
214    _activeSlide(0),
215    _previousTime(-1.0f),
216    _timePerSlide(5.0),
217    _autoSteppingActive(false)
218{
219}
220
221void SlideEventHandler::set(osg::Switch* sw, float offsetX, float offsetY, osg::TexMat* texmatLeft, osg::TexMat* texmatRight, float timePerSlide, bool autoSteppingActive)
222{
223    _switch = sw;
224    _switch->setUpdateCallback(this);
225
226    _texmatLeft = texmatLeft;
227    _texmatRight = texmatRight;
228
229    _timePerSlide = timePerSlide;
230    _autoSteppingActive = autoSteppingActive;   
231   
232    _initSeperationX = offsetX;
233    _currentSeperationX = _initSeperationX;
234
235    _initSeperationY = offsetY;
236    _currentSeperationY = _initSeperationY;
237
238    initTexMatrices();
239
240}
241
242void SlideEventHandler::set(FileList fileList, osg::Switch* sw, float offsetX, float offsetY, osg::TexMat* texmatLeft, osg::TexMat* texmatRight, float radius, float height, float length, float timePerSlide, bool autoSteppingActive)
243{
244    _switch = sw;
245    _switch->setUpdateCallback(this);
246    _fileList=FileList(fileList);
247
248    osg::ref_ptr<osg::Group> imageGroup = loadImages(fileList[0],fileList[1],texmatLeft,texmatRight, radius,  height, length);
249    if (imageGroup.get())_switch->addChild(imageGroup.get());
250
251    _texmatLeft = texmatLeft;
252    _texmatRight = texmatRight;
253
254    _radius=radius;
255    _height=height;
256    _length=length;
257
258    _timePerSlide = timePerSlide;
259    _autoSteppingActive = autoSteppingActive;   
260   
261    _initSeperationX = offsetX;
262    _currentSeperationX = _initSeperationX;
263
264    _initSeperationY = offsetY;
265    _currentSeperationY = _initSeperationY;
266
267    initTexMatrices();
268}
269
270
271bool SlideEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
272{
273    switch(ea.getEventType())
274    {
275        case(osgGA::GUIEventAdapter::KEYDOWN):
276        {
277            if (ea.getKey()=='a')
278            {
279                _autoSteppingActive = !_autoSteppingActive;
280                _previousTime = ea.getTime();
281                return true;
282            }
283            else if ((ea.getKey()=='n') || (ea.getKey()==osgGA::GUIEventAdapter::KEY_Right))
284            {
285                nextSlide();
286                return true;
287            }
288            else if ((ea.getKey()=='p') || (ea.getKey()==osgGA::GUIEventAdapter::KEY_Left))
289            {
290                previousSlide();
291                return true;
292            }
293            else if ((ea.getKey()=='w') || (ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Add))
294            {
295                scaleImage(0.99f);
296                return true;
297            }
298            else if ((ea.getKey()=='s') || (ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Subtract))
299            {
300                scaleImage(1.01f);
301                return true;
302            }
303            else if (ea.getKey()=='j')
304            {
305                offsetImage(-0.001f,0.0f);
306                return true;
307            }
308            else if (ea.getKey()=='k')
309            {
310                offsetImage(0.001f,0.0f);
311                return true;
312            }
313            else if (ea.getKey()=='i')
314            {
315                offsetImage(0.0f,-0.001f);
316                return true;
317            }
318            else if (ea.getKey()=='m')
319            {
320                offsetImage(0.0f,0.001f);
321                return true;
322            }
323            else if (ea.getKey()==' ')
324            {
325                initTexMatrices();
326                return true;
327            }
328            return false;
329        }
330        case(osgGA::GUIEventAdapter::DRAG):
331        case(osgGA::GUIEventAdapter::MOVE):
332        {
333            static float px = ea.getXnormalized();
334            static float py = ea.getYnormalized();
335           
336            float dx = ea.getXnormalized()-px;
337            float dy = ea.getYnormalized()-py;
338           
339            px = ea.getXnormalized();
340            py = ea.getYnormalized();
341           
342            rotateImage(dx,dy);
343           
344            return true;
345        }
346
347        default:
348            return false;
349    }
350}
351
352void SlideEventHandler::getUsage(osg::ApplicationUsage& usage) const
353{
354    usage.addKeyboardMouseBinding("Space","Reset the image position to center");
355    usage.addKeyboardMouseBinding("a","Toggle on/off the automatic advancement for image to image");
356    usage.addKeyboardMouseBinding("n","Advance to next image");
357    usage.addKeyboardMouseBinding("p","Move to previous image");
358    usage.addKeyboardMouseBinding("q","Zoom into the image");
359    usage.addKeyboardMouseBinding("a","Zoom out of the image");
360    usage.addKeyboardMouseBinding("j","Reduce horizontal offset");
361    usage.addKeyboardMouseBinding("k","Increase horizontal offset");
362    usage.addKeyboardMouseBinding("m","Reduce vertical offset");
363    usage.addKeyboardMouseBinding("i","Increase vertical offset");
364}
365
366void SlideEventHandler::operator()(osg::Node* node, osg::NodeVisitor* nv)
367{
368    if (_autoSteppingActive && nv->getFrameStamp())
369    {
370        double time = nv->getFrameStamp()->getSimulationTime();
371       
372        if (_firstTraversal)
373        {
374            _firstTraversal = false;
375            _previousTime = time;
376        }
377        else if (time-_previousTime>_timePerSlide)
378        {
379            _previousTime = time;
380           
381            nextSlide();
382        }
383       
384    }
385
386    traverse(node,nv);
387}
388
389void SlideEventHandler::nextSlide()
390{
391
392    if (_switch->getNumChildren()==0) return;
393
394    ++_activeSlide;
395
396    if (_fileList.size()>0) {
397        if (_activeSlide>= _fileList.size()/2 ) _activeSlide = 0;
398        osg::ref_ptr<osg::Group> images = loadImages(_fileList[2*_activeSlide],_fileList[2*_activeSlide+1],_texmatLeft.get(),_texmatRight.get(),_radius,_height,_length);
399        if (images.valid()) _switch->replaceChild(_switch->getChild(0),images.get());
400
401    } else {
402        if (_activeSlide>=_switch->getNumChildren()) _activeSlide = 0;
403
404        _switch->setSingleChildOn(_activeSlide);
405    }
406}
407
408void SlideEventHandler::previousSlide()
409{
410    if (_switch->getNumChildren()==0) return;
411
412    if (_fileList.size()>0) {
413        if (_activeSlide==0) _activeSlide = _fileList.size()/2-1;
414        else --_activeSlide;
415        osg::ref_ptr<osg::Group> images = loadImages(_fileList[2*_activeSlide],_fileList[2*_activeSlide+1],_texmatLeft.get(),_texmatRight.get(),_radius,_height,_length);
416        if (images.valid()) _switch->replaceChild(_switch->getChild(0),images.get());
417    } else {   
418        if (_activeSlide==0) _activeSlide = _switch->getNumChildren()-1;
419        else --_activeSlide;
420
421        _switch->setSingleChildOn(_activeSlide);
422    }
423}
424
425void SlideEventHandler::scaleImage(float s)
426{
427    _texmatLeft->setMatrix(_texmatLeft->getMatrix()*osg::Matrix::translate(-0.5f,-0.5f,0.0f)*osg::Matrix::scale(s,s,1.0f)*osg::Matrix::translate(0.5f,0.5f,0.0f));
428    _texmatRight->setMatrix(_texmatRight->getMatrix()*osg::Matrix::translate(-0.5f,-0.5f,0.0f)*osg::Matrix::scale(s,s,1.0f)*osg::Matrix::translate(0.5f,0.5f,0.0f));
429}
430
431void SlideEventHandler::offsetImage(float ds,float dt)
432{
433    _currentSeperationX+=ds;
434    _currentSeperationY+=dt;
435    osg::notify(osg::NOTICE)<<"image offset x = "<<_currentSeperationX<<"  y ="<<_currentSeperationY<<std::endl;
436    _texmatLeft->setMatrix(_texmatLeft->getMatrix()*osg::Matrix::translate(ds,dt,0.0f));
437    _texmatRight->setMatrix(_texmatRight->getMatrix()*osg::Matrix::translate(-ds,-dt,0.0f));
438}
439
440void SlideEventHandler::rotateImage(float rx,float ry)
441{
442    const float scale = 0.5f;
443    _texmatLeft->setMatrix(_texmatLeft->getMatrix()*osg::Matrix::translate(-rx*scale,-ry*scale,0.0f));
444    _texmatRight->setMatrix(_texmatRight->getMatrix()*osg::Matrix::translate(-rx*scale,-ry*scale,0.0f));
445}
446
447void SlideEventHandler::initTexMatrices()
448{
449    _texmatLeft->setMatrix(osg::Matrix::translate(_initSeperationX,_initSeperationY,0.0f));
450    _texmatRight->setMatrix(osg::Matrix::translate(-_initSeperationX,-_initSeperationY,0.0f));
451}
452
453
454
455int main( int argc, char **argv )
456{
457    // use an ArgumentParser object to manage the program arguments.
458    osg::ArgumentParser arguments(&argc,argv);
459   
460    // set up the usage document, in case we need to print out how to use this program.
461    arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates use node masks to create stereo images.");
462    arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] image_file_left_eye image_file_right_eye");
463    arguments.getApplicationUsage()->addCommandLineOption("-d <float>","Time delay in seconds between the display of successive image pairs when in auto advance mode.");
464    arguments.getApplicationUsage()->addCommandLineOption("-a","Enter auto advance of image pairs on start up.");
465    arguments.getApplicationUsage()->addCommandLineOption("-x <float>","Horizontal offset of left and right images.");
466    arguments.getApplicationUsage()->addCommandLineOption("-y <float>","Vertical offset of left and right images.");
467    arguments.getApplicationUsage()->addCommandLineOption("--disk","Keep images on disk");
468    arguments.getApplicationUsage()->addCommandLineOption("-files <filename>","Load filenames from a file");
469    arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
470    arguments.getApplicationUsage()->addCommandLineOption("--SingleThreaded","Select SingleThreaded threading model for viewer.");
471    arguments.getApplicationUsage()->addCommandLineOption("--CullDrawThreadPerContext","Select CullDrawThreadPerContext threading model for viewer.");
472    arguments.getApplicationUsage()->addCommandLineOption("--DrawThreadPerContext","Select DrawThreadPerContext threading model for viewer.");
473    arguments.getApplicationUsage()->addCommandLineOption("--CullThreadPerCameraDrawThreadPerContext","Select CullThreadPerCameraDrawThreadPerContext threading model for viewer.");
474   
475
476    // construct the viewer.
477    osgViewer::Viewer viewer;
478
479    // register the handler to add keyboard and mouse handling.
480    SlideEventHandler* seh = new SlideEventHandler();
481    viewer.addEventHandler(seh);
482
483    // read any time delay argument.
484    float timeDelayBetweenSlides = 5.0f;
485    while (arguments.read("-d",timeDelayBetweenSlides)) {}
486
487    bool autoSteppingActive = false;
488    while (arguments.read("-a")) autoSteppingActive = true;
489
490    float offsetX=0.0f;
491    while (arguments.read("-x",offsetX)) {}
492
493    float offsetY=0.0f;
494    while (arguments.read("-y",offsetY)) {}
495
496    bool onDisk=false;
497    while (arguments.read("--disk")) { onDisk=true;}
498
499    std::string filename="";
500    FileList fileList;
501    // extract the filenames from the a file, one filename per line.
502    while (arguments.read("-files",filename)) {
503        osgDB::ifstream is(filename.c_str());
504        if (is) {
505                std::string line;
506                while (std::getline(is,line,'\n')) fileList.push_back(line);
507                is.close();
508            }
509   
510    }
511
512    // if user request help write it out to cout.
513    if (arguments.read("-h") || arguments.read("--help"))
514    {
515        arguments.getApplicationUsage()->write(std::cout);
516        return 1;
517    }
518
519    osgViewer::Viewer::ThreadingModel threading = osgViewer::Viewer::SingleThreaded;
520    while (arguments.read("--SingleThreaded")) threading = osgViewer::Viewer::SingleThreaded;
521    while (arguments.read("--CullDrawThreadPerContext")) threading = osgViewer::Viewer::CullDrawThreadPerContext;
522    while (arguments.read("--DrawThreadPerContext")) threading = osgViewer::Viewer::DrawThreadPerContext;
523    while (arguments.read("--CullThreadPerCameraDrawThreadPerContext")) threading = osgViewer::Viewer::CullThreadPerCameraDrawThreadPerContext;
524
525    viewer.setThreadingModel(threading);
526
527    // any option left unread are converted into errors to write out later.
528    arguments.reportRemainingOptionsAsUnrecognized();
529
530    // report any errors if they have occurred when parsing the program arguments.
531    if (arguments.errors())
532    {
533        arguments.writeErrorMessages(std::cout);
534        return 1;
535    }
536   
537    // extract the filenames from the arguments list.
538    for(int pos=1;pos<arguments.argc();++pos)
539    {
540        if (arguments.isString(pos)) fileList.push_back(arguments[pos]);
541    }
542
543    if (fileList.empty())
544    {
545        fileList.push_back("Images/dog_left_eye.jpg");
546         fileList.push_back("Images/dog_right_eye.jpg");
547    }
548    else if (fileList.size()<2)
549    {
550        arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
551        return 1;
552    }
553
554    // now the windows have been realized we switch off the cursor to prevent it
555    // distracting the people seeing the stereo images.
556    double fovy, aspectRatio, zNear, zFar;
557    viewer.getCamera()->getProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar);
558
559    float radius = 1.0f;
560    float height = 2*radius*tan(osg::DegreesToRadians(fovy)*0.5f);
561    float length = osg::PI*radius;  // half a cylinder.
562
563    // use a texture matrix to control the placement of the image.
564    osg::TexMat* texmatLeft = new osg::TexMat;
565    osg::TexMat* texmatRight = new osg::TexMat;
566
567    // creat the scene from the file list.
568    osg::ref_ptr<osg::Switch> rootNode;
569    if (!onDisk)  rootNode = createScene(fileList,texmatLeft,texmatRight,radius,height,length);
570    else rootNode=new osg::Switch();
571
572    //osgDB::writeNodeFile(*rootNode,"test.osg");
573
574
575    viewer.getCamera()->setCullMask(0xffffffff);
576    viewer.getCamera()->setCullMaskLeft(0x00000001);
577    viewer.getCamera()->setCullMaskRight(0x00000002);
578
579    // set up the use of stereo by default.
580    osg::DisplaySettings::instance()->setStereo(true);
581
582    // set the scene to render
583    viewer.setSceneData(rootNode.get());
584
585
586    // create the windows and run the threads.
587    viewer.realize();
588
589
590    // switch off the cursor
591    osgViewer::Viewer::Windows windows;
592    viewer.getWindows(windows);
593    for(osgViewer::Viewer::Windows::iterator itr = windows.begin();
594        itr != windows.end();
595        ++itr)
596    {
597        (*itr)->useCursor(false);
598    }
599
600    viewer.setFusionDistance(osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE,radius);
601
602    // set up the SlideEventHandler.
603    if (onDisk) seh->set(fileList,rootNode.get(),offsetX,offsetY,texmatLeft,texmatRight,radius,height,length,timeDelayBetweenSlides,autoSteppingActive);
604    else seh->set(rootNode.get(),offsetX,offsetY,texmatLeft,texmatRight,timeDelayBetweenSlides,autoSteppingActive);
605   
606    osg::Matrix homePosition;
607    homePosition.makeLookAt(osg::Vec3(0.0f,0.0f,0.0f),osg::Vec3(0.0f,1.0f,0.0f),osg::Vec3(0.0f,0.0f,1.0f));
608       
609    while( !viewer.done() )
610    {
611        viewer.getCamera()->setViewMatrix(homePosition);
612
613        // fire off the cull and draw traversals of the scene.
614        viewer.frame();
615       
616    }
617   
618    return 0;
619}
Note: See TracBrowser for help on using the browser.