Work on CompositeViewer and related calsses to implement viewers with multiple views

This commit is contained in:
Robert Osfield 2007-01-16 08:56:33 +00:00
parent 6fda4a927a
commit 0873a8cea0
11 changed files with 1650 additions and 158 deletions

View File

@ -119,7 +119,7 @@ void singleWindowMultipleCameras(osgViewer::Viewer& viewer)
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
if (!wsi)
{
osg::notify(osg::NOTICE)<<"View::setUpViewAcrossAllScreens() : Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
osg::notify(osg::NOTICE)<<"Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
return;
}
@ -170,7 +170,7 @@ void multipleWindowMultipleCameras(osgViewer::Viewer& viewer)
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
if (!wsi)
{
osg::notify(osg::NOTICE)<<"View::setUpViewAcrossAllScreens() : Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
osg::notify(osg::NOTICE)<<"Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
return;
}

View File

@ -13,7 +13,6 @@
#include <osgUtil/Optimizer>
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#include <osg/Material>
#include <osg/Geode>
@ -27,37 +26,10 @@
#include <osgText/Text>
#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
osg::Node* createRearView(osg::Node* subgraph, const osg::Vec4& clearColour)
{
osg::Camera* camera = new osg::Camera;
// set the viewport
camera->setViewport(10,10,400,200);
// set the view matrix
camera->setCullingActive(false);
camera->setReferenceFrame(osg::Transform::RELATIVE_RF);
camera->setTransformOrder(osg::Camera::POST_MULTIPLY);
camera->setProjectionMatrix(osg::Matrixd::scale(-1.0f,1.0f,1.0f));
camera->setViewMatrix(osg::Matrixd::rotate(osg::inDegrees(180.0f),0.0f,1.0f,0.0f));
// set clear the color and depth buffer
camera->setClearColor(clearColour);
camera->setClearMask(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
// draw subgraph after main camera view.
camera->setRenderOrder(osg::Camera::POST_RENDER);
// add the subgraph to draw.
camera->addChild(subgraph);
// switch of back face culling as we've swapped over the projection matrix making back faces become front faces.
camera->getOrCreateStateSet()->setAttribute(new osg::FrontFace(osg::FrontFace::CLOCKWISE));
return camera;
}
#include <osgViewer/CompositeViewer>
int main( int argc, char **argv )
{
@ -65,27 +37,94 @@ int main( int argc, char **argv )
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// construct the viewer.
osgViewer::Viewer viewer;
// read the scene from the list of file specified commandline args.
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
osg::ref_ptr<osg::Group> group = new osg::Group;
if (!scene) return 1;
// construct the viewer.
osgViewer::CompositeViewer viewer;
// add the HUD subgraph.
if (scene.valid()) group->addChild(scene.get());
if (arguments.read("-1"))
{
#if 1
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
if (!wsi)
{
osg::notify(osg::NOTICE)<<"Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
return 1;
}
osg::Vec4 colour = viewer.getCamera()->getClearColor();
colour.r() *= 0.5f;
colour.g() *= 0.5f;
colour.b() *= 0.5f;
unsigned int width, height;
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height);
// note tone down the normal back ground colour to make it obvious that there is a seperate camera inserted.
group->addChild(createRearView(scene.get(), colour));
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->x = 0;
traits->y = 0;
traits->width = width;
traits->height = height;
traits->windowDecoration = true;
traits->doubleBuffer = true;
traits->sharedContext = 0;
// set the scene to render
viewer.setSceneData(group.get());
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (gc.valid())
{
osg::notify(osg::INFO)<<" GraphicsWindow has been created successfully."<<std::endl;
// need to ensure that the window is cleared make sure that the complete window is set the correct colour
// rather than just the parts of the window that are under the camera's viewports
gc->setClearColor(osg::Vec4f(0.2f,0.2f,0.6f,1.0f));
gc->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
else
{
osg::notify(osg::NOTICE)<<" GraphicsWindow has not been created successfully."<<std::endl;
}
osgViewer::View* view_one = new osgViewer::View;
view_one->setSceneData(scene.get());
view_one->getCamera()->setViewport(new osg::Viewport(0,0, width/2, height/2));
view_one->getCamera()->setGraphicsContext(gc.get());
view_one->setCameraManipulator(new osgGA::TrackballManipulator);
viewer.addView(view_one);
osgViewer::View* view_two = new osgViewer::View;
view_two->setSceneData(scene.get());
view_two->getCamera()->setViewport(new osg::Viewport(width/2,0, width/2, height/2));
view_two->getCamera()->setGraphicsContext(gc.get());
view_two->setCameraManipulator(new osgGA::TrackballManipulator);
viewer.addView(view_two);
#endif
osgViewer::View* view_three = new osgViewer::View;
view_three->setSceneData(osgDB::readNodeFile("town.ive"));
view_three->setUpViewAcrossAllScreens();
#if 0
view_three->getCamera()->setViewport(new osg::Viewport(0, height/2, width, height/2));
view_three->getCamera()->setGraphicsContext(gc.get());
#endif
view_three->setCameraManipulator(new osgGA::FlightManipulator);
viewer.addView(view_three);
}
else
{
osgViewer::View* view_one = new osgViewer::View;
view_one->setUpViewOnSingleScreen(0);
view_one->setSceneData(scene.get());
view_one->setCameraManipulator(new osgGA::TrackballManipulator);
viewer.addView(view_one);
osgViewer::View* view_two = new osgViewer::View;
view_two->setUpViewOnSingleScreen(1);
view_two->setSceneData(scene.get());
view_two->setCameraManipulator(new osgGA::TrackballManipulator);
viewer.addView(view_two);
}
while (arguments.read("-s")) { viewer.setThreadingModel(osgViewer::CompositeViewer::SingleThreaded); }
while (arguments.read("-g")) { viewer.setThreadingModel(osgViewer::CompositeViewer::ThreadPerContext); }
while (arguments.read("-c")) { viewer.setThreadingModel(osgViewer::CompositeViewer::ThreadPerCamera); }
return viewer.run();
}

View File

@ -22,7 +22,7 @@ namespace osgViewer {
// WARNING ** Under development do not use, yet :-)
/** CompsiteViewer holds a or more views to a one more scenes.*/
class OSGVIEWER_EXPORT CompositeViewer : public osg::Referenced
class OSGVIEWER_EXPORT CompositeViewer : public osg::Referenced, public osgGA::GUIActionAdapter
{
public:
@ -36,32 +36,171 @@ class OSGVIEWER_EXPORT CompositeViewer : public osg::Referenced
unsigned int getNumViews() const { return _views.size(); }
/** Get whether at least of one of this viewers windows are realized.*/
bool isRealized() const;
/** set up windows and associated threads.*/
void realize();
void setDone(bool done) { _done = done; }
bool done() const { return _done; }
void setStartTick(osg::Timer_t tick);
osg::Timer_t getStartTick() const { return _startTick; }
void setReferenceTime(double time=0.0);
void setFrameStamp(osg::FrameStamp* frameStamp);
osg::FrameStamp* getFrameStamp() { return _frameStamp.get(); }
const osg::FrameStamp* getFrameStamp() const { return _frameStamp.get(); }
enum ThreadingModel
{
SingleThreaded,
ThreadPerContext,
ThreadPerCamera
};
/** Set the threading model the rendering traversals will use.*/
void setThreadingModel(ThreadingModel threadingModel);
/** Get the threading model the rendering traversals will use.*/
ThreadingModel getThreadingModel() const { return _threadingModel; }
enum BarrierPosition
{
BeforeSwapBuffers,
AfterSwapBuffers
};
/** Set the position of the end barrier.
* AfterSwapBuffers will may result is slightly higher framerates, by may
* lead to inconcistent swapping between different windows.
* BeforeSwapBuffers may lead to slightly lower framerate, but improve consistency in timing of swap buffers,
* especially important if you are likely to consistently break frame.*/
void setEndBarrierPosition(BarrierPosition bp);
/** Get the end barrier position.*/
BarrierPosition getEndBarrierPosition() const { return _endBarrierPosition; }
void setEventQueue(osgGA::EventQueue* eventQueue) { _eventQueue = eventQueue; }
osgGA::EventQueue* getEventQueue() { return _eventQueue.get(); }
const osgGA::EventQueue* getEventQueue() const { return _eventQueue.get(); }
/** Set the key event that the viewer checks on each frame to see if the viewer's done flag should be set to
* signal end of viewers main loop.
* Default value is Escape (osgGA::GUIEVentAdapter::KEY_Escape).
* Setting to 0 switches off the feature.*/
void setKeyEventSetsDone(int key) { _keyEventSetsDone = key; }
/** get the key event that the viewer checks on each frame to see if the viewer's done flag.*/
int getKeyEventSetsDone() const { return _keyEventSetsDone; }
/** if the flag is true, the viewer set its done flag when a QUIT_APPLICATION is received, false disables this feature */
void setQuitEventSetsDone(bool flag) { _quitEventSetsDone = flag; }
/** @return true if the viewer respond to the QUIT_APPLICATION-event */
bool getQuitEventSetsDone() const { return _quitEventSetsDone; }
/** Execute a main frame loop.
* Equivialant to while (!viewer.done()) viewer.frame();
* Also calls realize() if the viewer is not already realized,
* and installs trackball manipulator if one is not already assigned.
*/
virtual int run();
/** Render a complete new frame.
* Calls frameAdvance(), frameEventTraversal(), frameUpateTraversal(), frameCullTraversal() and frameDrawTraversal().
* Note, no internal makeCurrent() is issued before, or swap buffers called after frame(), these operations are the responsibility of the calling code.*/
* Calls advance(), eventTraversal(), updateTraversal(), renderingTraversals(). */
virtual void frame();
virtual void frameAdvance();
virtual void frameEventTraversal();
virtual void frameUpdateTraversal();
virtual void frameCullTraversal();
virtual void frameDrawTraversal();
virtual void advance();
/** Release all OpenGL objects associated with this viewer's scenegraph. Note, does not deleted the actual OpenGL objects, it just releases them to the pending GL object delete lists which will need flushing once a valid graphics context is obtained.*/
virtual void releaseAllGLObjects();
virtual void eventTraversal();
/** Clean up all OpenGL objects associated with this viewer's scenegraph. Note, must only be called from the graphics context associated with this viewer.*/
virtual void cleanup();
virtual void updateTraversal();
virtual void renderingTraversals();
void setCameraWithFocus(osg::Camera* camera);
osg::Camera* getCameraWithFocus() { return _cameraWithFocus.get(); }
const osg::Camera* getCameraWithFocus() const { return _cameraWithFocus.get(); }
osgViewer::View* getViewWithFocus() { return _viewWithFocus.get(); }
const osgViewer::View* getViewWithFocus() const { return _viewWithFocus.get(); }
typedef std::vector<osg::GraphicsContext*> Contexts;
void getContexts(Contexts& contexts, bool onlyValid=true);
typedef std::vector<osgViewer::GraphicsWindow*> Windows;
void getWindows(Windows& windows, bool onlyValid=true);
typedef std::vector<osgViewer::Scene*> Scenes;
void getScenes(Scenes& scenes, bool onlyValid=true);
void stopThreading();
void startThreading();
void setUpRenderingSupport();
/** Get the camera which contains the pointer position x,y specified master cameras window/eye coords.
* Also passes back the local window coords for the graphics context associated with the camera passed back. */
const osg::Camera* getCameraContainingPosition(float x, float y, float& local_x, float& local_y) const;
/** Compute intersections between a ray through the specified master cameras window/eye coords and a specified node.
* Note, when a master cameras has slaves and no viewport itself its coordinate frame will be in clip space i.e. -1,-1 to 1,1,
* while if its has a viewport the coordintates will be relative to its viewport dimensions.
* Mouse events handled by the view will automatically be attached into the master camera window/clip coords so can be passed
* directly on to the computeIntersections method. */
bool computeIntersections(float x,float y, osgUtil::LineSegmentIntersector::Intersections& intersections,osg::Node::NodeMask traversalMask = 0xffffffff);
/** Compute intersections between a ray through the specified master cameras window/eye coords and a specified nodePath's subgraph. */
bool computeIntersections(float x,float y, osg::NodePath& nodePath, osgUtil::LineSegmentIntersector::Intersections& intersections,osg::Node::NodeMask traversalMask = 0xffffffff);
virtual void requestRedraw();
virtual void requestContinuousUpdate(bool needed=true);
virtual void requestWarpPointer(float x,float y);
public:
void init();
protected:
void init();
void checkWindowStatus();
typedef std::vector< osg::ref_ptr<osgViewer::View> > Views;
Views _views;
bool _firstFrame;
bool _done;
int _keyEventSetsDone;
bool _quitEventSetsDone;
ThreadingModel _threadingModel;
BarrierPosition _endBarrierPosition;
osg::ref_ptr<osg::BarrierOperation> _startRenderingBarrier;
osg::ref_ptr<osg::BarrierOperation> _endRenderingDispatchBarrier;
unsigned int computeNumberOfThreadsIncludingMainRequired();
unsigned int _numThreadsOnBarrier;
typedef std::map<osg::ref_ptr<osg::Camera>, osg::ref_ptr<osgUtil::SceneView> > CameraSceneViewMap;
CameraSceneViewMap _cameraSceneViewMap;
osg::Timer_t _startTick;
osg::ref_ptr<osg::FrameStamp> _frameStamp;
osg::observer_ptr<osg::Camera> _cameraWithFocus;
osg::observer_ptr<osgViewer::View> _viewWithFocus;
osg::ref_ptr<osgGA::EventQueue> _eventQueue;
osg::ref_ptr<osgGA::EventVisitor> _eventVisitor;
};

View File

@ -32,6 +32,9 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
View();
Scene* getScene() { return _scene.get(); }
const Scene* getScene() const { return _scene.get(); }
virtual void setSceneData(osg::Node* node);
osg::Node* getSceneData() { return _scene.valid() ? _scene->getSceneData() : 0; }
const osg::Node* getSceneData() const { return _scene.valid() ? _scene->getSceneData() : 0; }
@ -68,6 +71,9 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
void setUpViewOnSingleScreen(unsigned int screenNum=0);
/** Return true if this view contains a specified camera.*/
bool containsCamera(const osg::Camera* camera) const;
/** Get the camera which contains the pointer position x,y specified master cameras window/eye coords.
* Also passes back the local window coords for the graphics context associated with the camera passed back. */
const osg::Camera* getCameraContainingPosition(float x, float y, float& local_x, float& local_y) const;
@ -102,9 +108,6 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
osg::ref_ptr<osgGA::MatrixManipulator> _cameraManipulator;
EventHandlers _eventHandlers;
typedef std::map<osg::ref_ptr<osg::Camera>, osg::ref_ptr<osgUtil::SceneView> > CameraSceneViewMap;
CameraSceneViewMap _cameraSceneViewMap;
osg::ref_ptr<osg::DisplaySettings> _displaySettings;
};

View File

@ -38,7 +38,7 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
bool done() const { return _done; }
void Viewer::setStartTick(osg::Timer_t tick);
void setStartTick(osg::Timer_t tick);
osg::Timer_t getStartTick() const { return _startTick; }
void setReferenceTime(double time=0.0);
@ -48,7 +48,6 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
const osg::FrameStamp* getFrameStamp() const { return _frameStamp.get(); }
virtual void setSceneData(osg::Node* node);
enum ThreadingModel
@ -113,13 +112,6 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
virtual void updateTraversal();
virtual void renderingTraversals();
/** Release all OpenGL objects associated with this viewer's scenegraph. Note, does not deleted the actual OpenGL objects, it just releases them to the pending GL object delete lists which will need flushing once a valid graphics context is obtained.*/
virtual void releaseAllGLObjects();
/** Clean up all OpenGL objects associated with this viewer's scenegraph.*/
virtual void cleanup();
void setCameraWithFocus(osg::Camera* camera) { _cameraWithFocus = camera; }
osg::Camera* getCameraWithFocus() { return _cameraWithFocus.get(); }
@ -138,10 +130,8 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
protected:
void init();
void checkWindowStatus();
bool _firstFrame;
bool _done;
@ -158,6 +148,9 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
unsigned int _numThreadsOnBarrier;
typedef std::map<osg::ref_ptr<osg::Camera>, osg::ref_ptr<osgUtil::SceneView> > CameraSceneViewMap;
CameraSceneViewMap _cameraSceneViewMap;
osg::Timer_t _startTick;
osg::ref_ptr<osg::FrameStamp> _frameStamp;

File diff suppressed because it is too large Load Diff

View File

@ -238,6 +238,7 @@ void View::setUpViewOnSingleScreen(unsigned int screenNum)
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(screenNum), width, height);
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->screenNum = screenNum;
traits->x = 0;
traits->y = 0;
traits->width = width;
@ -327,6 +328,18 @@ void View::requestWarpPointer(float x,float y)
}
}
bool View::containsCamera(const osg::Camera* camera) const
{
if (_camera == camera) return true;
for(unsigned i=0; i<getNumSlaves(); ++i)
{
const Slave& slave = getSlave(i);
if (slave._camera == camera) return true;
}
return false;
}
const osg::Camera* View::getCameraContainingPosition(float x, float y, float& local_x, float& local_y) const
{
const osgGA::GUIEventAdapter* eventState = getEventQueue()->getCurrentEventState();

View File

@ -120,7 +120,7 @@ void Viewer::setStartTick(osg::Timer_t tick)
Contexts contexts;
getContexts(contexts,false);
getEventQueue()->setStartTick(osg::Timer::instance()->getStartTick());;
getEventQueue()->setStartTick(_startTick);
for(Contexts::iterator citr = contexts.begin();
citr != contexts.end();
++citr)
@ -128,7 +128,7 @@ void Viewer::setStartTick(osg::Timer_t tick)
osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(*citr);
if (gw)
{
gw->getEventQueue()->setStartTick(osg::Timer::instance()->getStartTick());
gw->getEventQueue()->setStartTick(_startTick);
}
}
}
@ -205,9 +205,9 @@ void Viewer::stopThreading()
}
// Compile operation, that compile OpenGL objects.
struct CompileOperation : public osg::GraphicsOperation
struct ViewerCompileOperation : public osg::GraphicsOperation
{
CompileOperation(osg::Node* scene):
ViewerCompileOperation(osg::Node* scene):
osg::GraphicsOperation("Compile",false),
_scene(scene)
{
@ -234,11 +234,10 @@ struct CompileOperation : public osg::GraphicsOperation
// Draw operation, that does a draw on the scene graph.
struct RunOperations : public osg::GraphicsOperation
struct ViewerRunOperations : public osg::GraphicsOperation
{
RunOperations(osg::GraphicsContext* gc):
osg::GraphicsOperation("RunOperation",true),
_originalContext(gc)
ViewerRunOperations():
osg::GraphicsOperation("RunOperation",true)
{
}
@ -246,8 +245,6 @@ struct RunOperations : public osg::GraphicsOperation
{
gc->runOperations();
}
osg::GraphicsContext* _originalContext;
};
unsigned int Viewer::computeNumberOfThreadsIncludingMainRequired()
@ -337,13 +334,13 @@ void Viewer::startThreading()
if (affinity) gc->getGraphicsThread()->setProcessorAffinity(processNum % numProcessors);
gc->getGraphicsThread()->add(new CompileOperation(getSceneData()));
gc->getGraphicsThread()->add(new ViewerCompileOperation(getSceneData()));
// add the startRenderingBarrier
gc->getGraphicsThread()->add(_startRenderingBarrier.get());
// add the rendering operation itself.
gc->getGraphicsThread()->add(new RunOperations(gc));
gc->getGraphicsThread()->add(new ViewerRunOperations());
if (_endBarrierPosition==BeforeSwapBuffers)
{
@ -460,9 +457,9 @@ void Viewer::getWindows(Windows& windows, bool onlyValid)
}
// Draw operation, that does a draw on the scene graph.
struct RenderingOperation : public osg::GraphicsOperation
struct ViewerRenderingOperation : public osg::GraphicsOperation
{
RenderingOperation(osgUtil::SceneView* sceneView, osgDB::DatabasePager* databasePager):
ViewerRenderingOperation(osgUtil::SceneView* sceneView, osgDB::DatabasePager* databasePager):
osg::GraphicsOperation("Render",true),
_sceneView(sceneView),
_databasePager(databasePager)
@ -526,7 +523,7 @@ void Viewer::setUpRenderingSupport()
sceneView->setSceneData(getSceneData());
sceneView->setFrameStamp(frameStamp);
_camera->getGraphicsContext()->add(new RenderingOperation(sceneView, dp));
_camera->getGraphicsContext()->add(new ViewerRenderingOperation(sceneView, dp));
}
for(unsigned i=0; i<getNumSlaves(); ++i)
@ -545,7 +542,7 @@ void Viewer::setUpRenderingSupport()
sceneView->setSceneData(getSceneData());
sceneView->setFrameStamp(frameStamp);
slave._camera->getGraphicsContext()->add(new RenderingOperation(sceneView, dp));
slave._camera->getGraphicsContext()->add(new ViewerRenderingOperation(sceneView, dp));
}
}
}
@ -800,7 +797,7 @@ void Viewer::eventTraversal()
// osg::notify(osg::NOTICE)<<"mouseEventState Xmin = "<<eventState->getXmin()<<" Ymin="<<eventState->getYmin()<<" xMax="<<eventState->getXmax()<<" Ymax="<<eventState->getYmax()<<std::endl;
if (_scene.valid()) _eventQueue->frame( getFrameStamp()->getReferenceTime() );
_eventQueue->frame( getFrameStamp()->getReferenceTime() );
_eventQueue->takeEvents(events);
@ -839,8 +836,6 @@ void Viewer::eventTraversal()
break;
case(osgGA::GUIEventAdapter::QUIT_APPLICATION):
osg::notify(osg::NOTICE)<<" QUIT_APPLICATION " << std::endl;
case(osgGA::GUIEventAdapter::RESIZE):
osg::notify(osg::NOTICE)<<" RESIZE "<<std::endl;
break;
case(osgGA::GUIEventAdapter::FRAME):
// osg::notify(osg::NOTICE)<<" FRAME "<<std::endl;
@ -998,14 +993,3 @@ void Viewer::renderingTraversals()
dp->signalEndFrame();
}
}
void Viewer::releaseAllGLObjects()
{
osg::notify(osg::NOTICE)<<"Viewer::releaseAllGLObjects() not implemented yet."<<std::endl;
}
void Viewer::cleanup()
{
osg::notify(osg::NOTICE)<<"Viewer::cleanup() not implemented yet."<<std::endl;
}

View File

@ -10,6 +10,12 @@
#include <osgIntrospection/StaticMethodInfo>
#include <osgIntrospection/Attributes>
#include <osg/Camera>
#include <osg/FrameStamp>
#include <osg/Node>
#include <osg/Timer>
#include <osgGA/EventQueue>
#include <osgUtil/LineSegmentIntersector>
#include <osgViewer/CompositeViewer>
#include <osgViewer/View>
@ -21,8 +27,26 @@
#undef OUT
#endif
TYPE_NAME_ALIAS(std::vector< osg::GraphicsContext * >, osgViewer::CompositeViewer::Contexts);
TYPE_NAME_ALIAS(std::vector< osgViewer::GraphicsWindow * >, osgViewer::CompositeViewer::Windows);
TYPE_NAME_ALIAS(std::vector< osgViewer::Scene * >, osgViewer::CompositeViewer::Scenes);
BEGIN_ENUM_REFLECTOR(osgViewer::CompositeViewer::ThreadingModel)
I_EnumLabel(osgViewer::CompositeViewer::SingleThreaded);
I_EnumLabel(osgViewer::CompositeViewer::ThreadPerContext);
I_EnumLabel(osgViewer::CompositeViewer::ThreadPerCamera);
END_REFLECTOR
BEGIN_ENUM_REFLECTOR(osgViewer::CompositeViewer::BarrierPosition)
I_EnumLabel(osgViewer::CompositeViewer::BeforeSwapBuffers);
I_EnumLabel(osgViewer::CompositeViewer::AfterSwapBuffers);
END_REFLECTOR
BEGIN_OBJECT_REFLECTOR(osgViewer::CompositeViewer)
I_BaseType(osg::Referenced);
I_BaseType(osgGA::GUIActionAdapter);
I_Constructor0(____CompositeViewer,
"",
"");
@ -42,42 +66,212 @@ BEGIN_OBJECT_REFLECTOR(osgViewer::CompositeViewer)
__unsigned_int__getNumViews,
"",
"");
I_Method0(bool, isRealized,
__bool__isRealized,
"Get whether at least of one of this viewers windows are realized. ",
"");
I_Method0(void, realize,
__void__realize,
"set up windows and associated threads. ",
"");
I_Method1(void, setDone, IN, bool, done,
__void__setDone__bool,
"",
"");
I_Method0(bool, done,
__bool__done,
"",
"");
I_Method1(void, setStartTick, IN, osg::Timer_t, tick,
__void__setStartTick__osg_Timer_t,
"",
"");
I_Method0(osg::Timer_t, getStartTick,
__osg_Timer_t__getStartTick,
"",
"");
I_MethodWithDefaults1(void, setReferenceTime, IN, double, time, 0.0,
__void__setReferenceTime__double,
"",
"");
I_Method1(void, setFrameStamp, IN, osg::FrameStamp *, frameStamp,
__void__setFrameStamp__osg_FrameStamp_P1,
"",
"");
I_Method0(osg::FrameStamp *, getFrameStamp,
__osg_FrameStamp_P1__getFrameStamp,
"",
"");
I_Method0(const osg::FrameStamp *, getFrameStamp,
__C5_osg_FrameStamp_P1__getFrameStamp,
"",
"");
I_Method1(void, setThreadingModel, IN, osgViewer::CompositeViewer::ThreadingModel, threadingModel,
__void__setThreadingModel__ThreadingModel,
"Set the threading model the rendering traversals will use. ",
"");
I_Method0(osgViewer::CompositeViewer::ThreadingModel, getThreadingModel,
__ThreadingModel__getThreadingModel,
"Get the threading model the rendering traversals will use. ",
"");
I_Method1(void, setEndBarrierPosition, IN, osgViewer::CompositeViewer::BarrierPosition, bp,
__void__setEndBarrierPosition__BarrierPosition,
"Set the position of the end barrier. ",
"AfterSwapBuffers will may result is slightly higher framerates, by may lead to inconcistent swapping between different windows. BeforeSwapBuffers may lead to slightly lower framerate, but improve consistency in timing of swap buffers, especially important if you are likely to consistently break frame. ");
I_Method0(osgViewer::CompositeViewer::BarrierPosition, getEndBarrierPosition,
__BarrierPosition__getEndBarrierPosition,
"Get the end barrier position. ",
"");
I_Method1(void, setEventQueue, IN, osgGA::EventQueue *, eventQueue,
__void__setEventQueue__osgGA_EventQueue_P1,
"",
"");
I_Method0(osgGA::EventQueue *, getEventQueue,
__osgGA_EventQueue_P1__getEventQueue,
"",
"");
I_Method0(const osgGA::EventQueue *, getEventQueue,
__C5_osgGA_EventQueue_P1__getEventQueue,
"",
"");
I_Method1(void, setKeyEventSetsDone, IN, int, key,
__void__setKeyEventSetsDone__int,
"Set the key event that the viewer checks on each frame to see if the viewer's done flag should be set to signal end of viewers main loop. ",
"Default value is Escape (osgGA::GUIEVentAdapter::KEY_Escape). Setting to 0 switches off the feature. ");
I_Method0(int, getKeyEventSetsDone,
__int__getKeyEventSetsDone,
"get the key event that the viewer checks on each frame to see if the viewer's done flag. ",
"");
I_Method1(void, setQuitEventSetsDone, IN, bool, flag,
__void__setQuitEventSetsDone__bool,
"if the flag is true, the viewer set its done flag when a QUIT_APPLICATION is received, false disables this feature ",
"");
I_Method0(bool, getQuitEventSetsDone,
__bool__getQuitEventSetsDone,
"",
"true if the viewer respond to the QUIT_APPLICATION-event ");
I_Method0(int, run,
__int__run,
"Execute a main frame loop. ",
"Equivialant to while (!viewer.done()) viewer.frame(); Also calls realize() if the viewer is not already realized, and installs trackball manipulator if one is not already assigned.");
I_Method0(void, frame,
__void__frame,
"Render a complete new frame. ",
"Calls frameAdvance(), frameEventTraversal(), frameUpateTraversal(), frameCullTraversal() and frameDrawTraversal(). Note, no internal makeCurrent() is issued before, or swap buffers called after frame(), these operations are the responsibility of the calling code. ");
I_Method0(void, frameAdvance,
__void__frameAdvance,
"Calls advance(), eventTraversal(), updateTraversal(), renderingTraversals(). ");
I_Method0(void, advance,
__void__advance,
"",
"");
I_Method0(void, frameEventTraversal,
__void__frameEventTraversal,
I_Method0(void, eventTraversal,
__void__eventTraversal,
"",
"");
I_Method0(void, frameUpdateTraversal,
__void__frameUpdateTraversal,
I_Method0(void, updateTraversal,
__void__updateTraversal,
"",
"");
I_Method0(void, frameCullTraversal,
__void__frameCullTraversal,
I_Method0(void, renderingTraversals,
__void__renderingTraversals,
"",
"");
I_Method0(void, frameDrawTraversal,
__void__frameDrawTraversal,
I_Method1(void, setCameraWithFocus, IN, osg::Camera *, camera,
__void__setCameraWithFocus__osg_Camera_P1,
"",
"");
I_Method0(void, releaseAllGLObjects,
__void__releaseAllGLObjects,
"Release all OpenGL objects associated with this viewer's scenegraph. ",
"Note, does not deleted the actual OpenGL objects, it just releases them to the pending GL object delete lists which will need flushing once a valid graphics context is obtained. ");
I_Method0(void, cleanup,
__void__cleanup,
"Clean up all OpenGL objects associated with this viewer's scenegraph. ",
"Note, must only be called from the graphics context associated with this viewer. ");
I_Method0(void, init,
__void__init,
I_Method0(osg::Camera *, getCameraWithFocus,
__osg_Camera_P1__getCameraWithFocus,
"",
"");
I_Method0(const osg::Camera *, getCameraWithFocus,
__C5_osg_Camera_P1__getCameraWithFocus,
"",
"");
I_Method0(osgViewer::View *, getViewWithFocus,
__osgViewer_View_P1__getViewWithFocus,
"",
"");
I_Method0(const osgViewer::View *, getViewWithFocus,
__C5_osgViewer_View_P1__getViewWithFocus,
"",
"");
I_MethodWithDefaults2(void, getContexts, IN, osgViewer::CompositeViewer::Contexts &, contexts, , IN, bool, onlyValid, true,
__void__getContexts__Contexts_R1__bool,
"",
"");
I_MethodWithDefaults2(void, getWindows, IN, osgViewer::CompositeViewer::Windows &, windows, , IN, bool, onlyValid, true,
__void__getWindows__Windows_R1__bool,
"",
"");
I_MethodWithDefaults2(void, getScenes, IN, osgViewer::CompositeViewer::Scenes &, scenes, , IN, bool, onlyValid, true,
__void__getScenes__Scenes_R1__bool,
"",
"");
I_Method0(void, stopThreading,
__void__stopThreading,
"",
"");
I_Method0(void, startThreading,
__void__startThreading,
"",
"");
I_Method0(void, setUpRenderingSupport,
__void__setUpRenderingSupport,
"",
"");
I_Method4(const osg::Camera *, getCameraContainingPosition, IN, float, x, IN, float, y, IN, float &, local_x, IN, float &, local_y,
__C5_osg_Camera_P1__getCameraContainingPosition__float__float__float_R1__float_R1,
"Get the camera which contains the pointer position x,y specified master cameras window/eye coords. ",
"Also passes back the local window coords for the graphics context associated with the camera passed back. ");
I_MethodWithDefaults4(bool, computeIntersections, IN, float, x, , IN, float, y, , IN, osgUtil::LineSegmentIntersector::Intersections &, intersections, , IN, osg::Node::NodeMask, traversalMask, 0xffffffff,
__bool__computeIntersections__float__float__osgUtil_LineSegmentIntersector_Intersections_R1__osg_Node_NodeMask,
"Compute intersections between a ray through the specified master cameras window/eye coords and a specified node. ",
"Note, when a master cameras has slaves and no viewport itself its coordinate frame will be in clip space i.e. -1,-1 to 1,1, while if its has a viewport the coordintates will be relative to its viewport dimensions. Mouse events handled by the view will automatically be attached into the master camera window/clip coords so can be passed directly on to the computeIntersections method. ");
I_MethodWithDefaults5(bool, computeIntersections, IN, float, x, , IN, float, y, , IN, osg::NodePath &, nodePath, , IN, osgUtil::LineSegmentIntersector::Intersections &, intersections, , IN, osg::Node::NodeMask, traversalMask, 0xffffffff,
__bool__computeIntersections__float__float__osg_NodePath_R1__osgUtil_LineSegmentIntersector_Intersections_R1__osg_Node_NodeMask,
"Compute intersections between a ray through the specified master cameras window/eye coords and a specified nodePath's subgraph. ",
"");
I_Method0(void, requestRedraw,
__void__requestRedraw,
"requestRedraw() requests a single redraw. ",
"");
I_MethodWithDefaults1(void, requestContinuousUpdate, IN, bool, needed, true,
__void__requestContinuousUpdate__bool,
"requestContinousUpdate(bool) is for en/disabling a throw or idle callback to be requested by a GUIEventHandler (typically a MatrixManipulator, though other GUIEventHandler's may also provide functionality). ",
"GUI toolkits can respond to this immediately by registering an idle/timed callback, or can delay setting the callback and update at their own leisure.");
I_Method2(void, requestWarpPointer, IN, float, x, IN, float, y,
__void__requestWarpPointer__float__float,
"requestWarpPointer(int,int) is requesting a repositioning of the mouse pointer to a specified x,y location on the window. ",
"This is used by some camera manipulators to initialise the mouse pointer when mouse position relative to a controls neutral mouse position is required, i.e when mimicking a aircrafts joystick.");
I_SimpleProperty(osg::Camera *, CameraWithFocus,
__osg_Camera_P1__getCameraWithFocus,
__void__setCameraWithFocus__osg_Camera_P1);
I_SimpleProperty(bool, Done,
0,
__void__setDone__bool);
I_SimpleProperty(osgViewer::CompositeViewer::BarrierPosition, EndBarrierPosition,
__BarrierPosition__getEndBarrierPosition,
__void__setEndBarrierPosition__BarrierPosition);
I_SimpleProperty(osgGA::EventQueue *, EventQueue,
__osgGA_EventQueue_P1__getEventQueue,
__void__setEventQueue__osgGA_EventQueue_P1);
I_SimpleProperty(osg::FrameStamp *, FrameStamp,
__osg_FrameStamp_P1__getFrameStamp,
__void__setFrameStamp__osg_FrameStamp_P1);
I_SimpleProperty(int, KeyEventSetsDone,
__int__getKeyEventSetsDone,
__void__setKeyEventSetsDone__int);
I_SimpleProperty(bool, QuitEventSetsDone,
__bool__getQuitEventSetsDone,
__void__setQuitEventSetsDone__bool);
I_SimpleProperty(double, ReferenceTime,
0,
__void__setReferenceTime__double);
I_SimpleProperty(osg::Timer_t, StartTick,
__osg_Timer_t__getStartTick,
__void__setStartTick__osg_Timer_t);
I_SimpleProperty(osgViewer::CompositeViewer::ThreadingModel, ThreadingModel,
__ThreadingModel__getThreadingModel,
__void__setThreadingModel__ThreadingModel);
I_ArrayProperty(osgViewer::View *, View,
__osgViewer_View_P1__getView__unsigned,
0,
@ -85,5 +279,14 @@ BEGIN_OBJECT_REFLECTOR(osgViewer::CompositeViewer)
__void__addView__osgViewer_View_P1,
0,
0);
I_SimpleProperty(osgViewer::View *, ViewWithFocus,
__osgViewer_View_P1__getViewWithFocus,
0);
END_REFLECTOR
STD_VECTOR_REFLECTOR(std::vector< osg::GraphicsContext * >);
STD_VECTOR_REFLECTOR(std::vector< osgViewer::GraphicsWindow * >);
STD_VECTOR_REFLECTOR(std::vector< osgViewer::Scene * >);

View File

@ -17,6 +17,7 @@
#include <osgGA/GUIEventHandler>
#include <osgGA/MatrixManipulator>
#include <osgUtil/LineSegmentIntersector>
#include <osgViewer/Scene>
#include <osgViewer/View>
// Must undefine IN and OUT macros defined in Windows headers
@ -35,6 +36,14 @@ BEGIN_OBJECT_REFLECTOR(osgViewer::View)
I_Constructor0(____View,
"",
"");
I_Method0(osgViewer::Scene *, getScene,
__Scene_P1__getScene,
"",
"");
I_Method0(const osgViewer::Scene *, getScene,
__C5_Scene_P1__getScene,
"",
"");
I_Method1(void, setSceneData, IN, osg::Node *, node,
__void__setSceneData__osg_Node_P1,
"",
@ -103,6 +112,10 @@ BEGIN_OBJECT_REFLECTOR(osgViewer::View)
__void__setUpViewOnSingleScreen__unsigned_int,
"Convinience method for a single Camara associated with a single full screen GraphicsWindow. ",
"");
I_Method1(bool, containsCamera, IN, const osg::Camera *, camera,
__bool__containsCamera__C5_osg_Camera_P1,
"Return true if this view contains a specified camera. ",
"");
I_Method4(const osg::Camera *, getCameraContainingPosition, IN, float, x, IN, float, y, IN, float &, local_x, IN, float &, local_y,
__C5_osg_Camera_P1__getCameraContainingPosition__float__float__float_R1__float_R1,
"Get the camera which contains the pointer position x,y specified master cameras window/eye coords. ",
@ -143,6 +156,9 @@ BEGIN_OBJECT_REFLECTOR(osgViewer::View)
I_SimpleProperty(osgGA::EventQueue *, EventQueue,
__osgGA_EventQueue_P1__getEventQueue,
__void__setEventQueue__osgGA_EventQueue_P1);
I_SimpleProperty(osgViewer::Scene *, Scene,
__Scene_P1__getScene,
0);
I_SimpleProperty(osg::Node *, SceneData,
__osg_Node_P1__getSceneData,
__void__setSceneData__osg_Node_P1);

View File

@ -144,14 +144,6 @@ BEGIN_OBJECT_REFLECTOR(osgViewer::Viewer)
__void__renderingTraversals,
"",
"");
I_Method0(void, releaseAllGLObjects,
__void__releaseAllGLObjects,
"Release all OpenGL objects associated with this viewer's scenegraph. ",
"Note, does not deleted the actual OpenGL objects, it just releases them to the pending GL object delete lists which will need flushing once a valid graphics context is obtained. ");
I_Method0(void, cleanup,
__void__cleanup,
"Clean up all OpenGL objects associated with this viewer's scenegraph. ",
"");
I_Method1(void, setCameraWithFocus, IN, osg::Camera *, camera,
__void__setCameraWithFocus__osg_Camera_P1,
"",
@ -216,7 +208,3 @@ BEGIN_OBJECT_REFLECTOR(osgViewer::Viewer)
__void__setThreadingModel__ThreadingModel);
END_REFLECTOR
STD_VECTOR_REFLECTOR(std::vector< osg::GraphicsContext * >);
STD_VECTOR_REFLECTOR(std::vector< osgViewer::GraphicsWindow * >);