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

Revision 7446, 21.7 kB (checked in by robert, 7 years ago)

From Luc Frauciel, "A few improvements to osgstereoimage:
- When using a large numbrer of files, the command line was too long;
Added a -files option that allow to store filenames in a file (one file
per line)
- Added some more intuitive key bindings for controls (left, right, + ,
-)
- Set the texture wrapping to CLAMP_TO_EDGE (it's cleaner now)
"

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