Ported osghangglider example to usg osgViewer
This commit is contained in:
@@ -18,7 +18,7 @@ HEADERFILES = \
|
|||||||
terrain_normals.h\
|
terrain_normals.h\
|
||||||
terrain_texcoords.h\
|
terrain_texcoords.h\
|
||||||
|
|
||||||
LIBS += -losgProducer -lProducer -losgText -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
LIBS += -losgViewer -losgText -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||||
|
|
||||||
INSTFILES = \
|
INSTFILES = \
|
||||||
$(CXXFILES)\
|
$(CXXFILES)\
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ CXXFILES =\
|
|||||||
terrain.cpp\
|
terrain.cpp\
|
||||||
trees.cpp\
|
trees.cpp\
|
||||||
|
|
||||||
LIBS += -losgProducer -lProducer -losgDB -losgText -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
LIBS += -losgViewer -losgDB -losgText -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||||
|
|
||||||
EXEC = osghangglide
|
EXEC = osghangglide
|
||||||
|
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ bool GliderManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
|||||||
{
|
{
|
||||||
switch(ea.getEventType())
|
switch(ea.getEventType())
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
case(GUIEventAdapter::PUSH):
|
case(GUIEventAdapter::PUSH):
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -101,7 +102,7 @@ bool GliderManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
|||||||
|
|
||||||
addMouseEvent(ea);
|
addMouseEvent(ea);
|
||||||
us.requestContinuousUpdate(true);
|
us.requestContinuousUpdate(true);
|
||||||
if (calcMovement()) us.requestRedraw();
|
// if (calcMovement()) us.requestRedraw();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +111,7 @@ bool GliderManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
|||||||
|
|
||||||
addMouseEvent(ea);
|
addMouseEvent(ea);
|
||||||
us.requestContinuousUpdate(true);
|
us.requestContinuousUpdate(true);
|
||||||
if (calcMovement()) us.requestRedraw();
|
// if (calcMovement()) us.requestRedraw();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,11 +120,11 @@ bool GliderManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
|||||||
|
|
||||||
addMouseEvent(ea);
|
addMouseEvent(ea);
|
||||||
us.requestContinuousUpdate(true);
|
us.requestContinuousUpdate(true);
|
||||||
if (calcMovement()) us.requestRedraw();
|
// if (calcMovement()) us.requestRedraw();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
case(GUIEventAdapter::KEYDOWN):
|
case(GUIEventAdapter::KEYDOWN):
|
||||||
if (ea.getKey()==' ')
|
if (ea.getKey()==' ')
|
||||||
{
|
{
|
||||||
@@ -259,6 +260,8 @@ bool GliderManipulator::calcMovement()
|
|||||||
float dx = _ga_t0->getXnormalized();
|
float dx = _ga_t0->getXnormalized();
|
||||||
float dy = _ga_t0->getYnormalized();
|
float dy = _ga_t0->getYnormalized();
|
||||||
|
|
||||||
|
// osg::notify(osg::NOTICE)<<"dx = "<<dx<<" dy = "<<dy<<"dt = "<<dt<<std::endl;
|
||||||
|
|
||||||
// mew - flag to reverse mouse-control mapping
|
// mew - flag to reverse mouse-control mapping
|
||||||
if( getenv( "OSGHANGGLIDE_REVERSE_CONTROLS" ) )
|
if( getenv( "OSGHANGGLIDE_REVERSE_CONTROLS" ) )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,12 +10,12 @@
|
|||||||
#include <osgDB/Registry>
|
#include <osgDB/Registry>
|
||||||
#include <osgDB/ReadFile>
|
#include <osgDB/ReadFile>
|
||||||
|
|
||||||
#include <osgGA/AnimationPathManipulator>
|
#include <osgViewer/Viewer>
|
||||||
|
|
||||||
#include <osgProducer/Viewer>
|
|
||||||
|
|
||||||
#include "GliderManipulator.h"
|
#include "GliderManipulator.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
extern osg::Node *makeTerrain( void );
|
extern osg::Node *makeTerrain( void );
|
||||||
extern osg::Node *makeTrees( void );
|
extern osg::Node *makeTrees( void );
|
||||||
extern osg::Node *makeTank( void );
|
extern osg::Node *makeTank( void );
|
||||||
@@ -111,17 +111,14 @@ int main( int argc, char **argv )
|
|||||||
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
|
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
|
||||||
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
|
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
|
||||||
|
|
||||||
|
osg::DisplaySettings::instance()->setMaxNumberOfGraphicsContexts(2);
|
||||||
|
osg::Referenced::setThreadSafeReferenceCounting(true);
|
||||||
|
|
||||||
// construct the viewer.
|
// construct the viewer.
|
||||||
osgProducer::Viewer viewer(arguments);
|
osgViewer::Viewer viewer;
|
||||||
|
|
||||||
// set up the value with sensible default event handlers.
|
|
||||||
viewer.setUpViewer(osgProducer::Viewer::ESCAPE_SETS_DONE);
|
|
||||||
|
|
||||||
unsigned int pos = viewer.addCameraManipulator(new GliderManipulator());
|
viewer.setCameraManipulator(new GliderManipulator());
|
||||||
viewer.selectCameraManipulator(pos);
|
|
||||||
|
|
||||||
// get details on keyboard and mouse bindings used by the viewer.
|
|
||||||
viewer.getUsage(*arguments.getApplicationUsage());
|
|
||||||
|
|
||||||
// if user request help write it out to cout.
|
// if user request help write it out to cout.
|
||||||
if (arguments.read("-h") || arguments.read("--help"))
|
if (arguments.read("-h") || arguments.read("--help"))
|
||||||
@@ -146,33 +143,19 @@ int main( int argc, char **argv )
|
|||||||
|
|
||||||
viewer.setSceneData( rootnode );
|
viewer.setSceneData( rootnode );
|
||||||
|
|
||||||
|
// set up the value with sensible default event handlers.
|
||||||
|
viewer.setUpViewAcrossAllScreens();
|
||||||
|
|
||||||
// create the windows and run the threads.
|
// create the windows and run the threads.
|
||||||
viewer.realize();
|
viewer.realize();
|
||||||
|
|
||||||
while( !viewer.done() )
|
while( !viewer.done() )
|
||||||
{
|
{
|
||||||
// wait for all cull and draw threads to complete.
|
|
||||||
viewer.sync();
|
|
||||||
|
|
||||||
// update the scene by traversing it with the the update visitor which will
|
|
||||||
// call all node update callbacks and animations.
|
|
||||||
viewer.update();
|
|
||||||
|
|
||||||
// fire off the cull and draw traversals of the scene.
|
// fire off the cull and draw traversals of the scene.
|
||||||
viewer.frame();
|
viewer.frame();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for all cull and draw threads to complete before exit.
|
|
||||||
viewer.sync();
|
|
||||||
|
|
||||||
// run a clean up frame to delete all OpenGL objects.
|
|
||||||
viewer.cleanup_frame();
|
|
||||||
|
|
||||||
// wait for all the clean up frame to complete.
|
|
||||||
viewer.sync();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user