Renamed osg::CameraNode to osg::Camera, cleaned up osg::View.
Added beginnings of new osgViewer::Scene,View,Viewer,CompositeViewer and GraphicsWindowProxy files.
This commit is contained in:
68
include/osgViewer/CompositeViewer
Normal file
68
include/osgViewer/CompositeViewer
Normal file
@@ -0,0 +1,68 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSGVIEWER_CompositeViewer
|
||||
#define OSGVIEWER_CompositeViewer 1
|
||||
|
||||
#include <osgViewer/GraphicsWindow>
|
||||
#include <osgViewer/View>
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
|
||||
CompositeViewer();
|
||||
virtual ~CompositeViewer();
|
||||
|
||||
void addView(osgViewer* view);
|
||||
osgViewer* getView(unsigned i) { return _views[i].get(); }
|
||||
const osgViewer* getView(unsigned i) const { return _views[i].get(); }
|
||||
void getNumViews() const { return _views.size(); }
|
||||
|
||||
/** 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.*/
|
||||
virtual void frame();
|
||||
|
||||
virtual void frameAdvance();
|
||||
virtual void frameEventTraversal();
|
||||
virtual void frameUpdateTraversal();
|
||||
virtual void frameCullTraversal();
|
||||
virtual void frameDrawTraversal();
|
||||
|
||||
/** 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. Note, must only be called from the graphics context associated with this viewer.*/
|
||||
virtual void cleanup();
|
||||
|
||||
public:
|
||||
|
||||
void init();
|
||||
|
||||
protected:
|
||||
|
||||
typedef std::vector< osg::ref_ptr<osg:Viewer:View> > Views;
|
||||
Views _views;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
88
include/osgViewer/GraphicsWindowProxy
Normal file
88
include/osgViewer/GraphicsWindowProxy
Normal file
@@ -0,0 +1,88 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSGVIEWER_GRAPHICWINDOW
|
||||
#define OSGVIEWER_GRAPHICWINDOW 1
|
||||
|
||||
#include <osg/GraphicsContext>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <osgGA/EventQueue>
|
||||
|
||||
#include <osgViewer/Export>
|
||||
|
||||
namespace osgViewer {
|
||||
|
||||
/** GraphicsWindowProxy acts as an adpater GraphicsWindow which allows the implementation of the GraphicsWindow to be decoupled */
|
||||
class OSGVIEWER_EXPORT GraphicsWindowProxy : public osgViewer::GraphicsWindow
|
||||
{
|
||||
public:
|
||||
|
||||
GraphicsWindowProxy();
|
||||
|
||||
void setGraphicsWindowImplentation(osgViewer::GraphicsWindow* gw) { _gw = gw; }
|
||||
|
||||
osgViewer::GraphicsWindow* getGraphicsWindowImplentation() { return _gw.get(); }
|
||||
|
||||
const osgViewer::GraphicsWindow* getGraphicsWindowImplentation() const { return _gw.get(); }
|
||||
|
||||
/** Realise the GraphicsContext implementation,
|
||||
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
|
||||
virtual bool realizeImplementation() { if (_gw.valid()) return _gw->realizeImplementation(); else osg::notify(osg::NOTICE)<<"GraphicsWindow::realizeImplementation() not implemented."<<std::endl; return false; }
|
||||
|
||||
/** Return true if the graphics context has been realised, and is ready to use, implementation.
|
||||
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
|
||||
virtual bool isRealizedImplementation() const { if (_gw.valid()) return gw->isRealizedImplementation(); else osg::notify(osg::NOTICE)<<"GraphicsWindow::isRealizedImplementation() not implemented."<<std::endl; return false; }
|
||||
|
||||
/** Close the graphics context implementation.
|
||||
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
|
||||
virtual void closeImplementation() { if (_gw.valid()) _gw->closeImplementation(); else osg::notify(osg::NOTICE)<<"GraphicsWindow::closeImplementation() not implemented."<<std::endl; }
|
||||
|
||||
/** Make this graphics context current implementation.
|
||||
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
|
||||
virtual void makeCurrentImplementation() { if (_gw.valid()) _gw->makeCurrentImplementation(); else osg::notify(osg::NOTICE)<<"GraphicsWindow::makeCurrentImplementation() not implemented."<<std::endl; }
|
||||
|
||||
/** Make this graphics context current with specified read context implementation.
|
||||
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
|
||||
virtual void makeContextCurrentImplementation(GraphicsContext* readContext) { if (_gw.valid()) _gw->makeContextCurrentImplementation(readContext); else osg::notify(osg::NOTICE)<<"GraphicsWindow::makeContextCurrentImplementation(..) not implemented."<<std::endl; }
|
||||
|
||||
/** Pure virtual, Bind the graphics context to associated texture implementation.
|
||||
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
|
||||
virtual void bindPBufferToTextureImplementation(GLenum buffer) { if (_gw.valid()) _gw->bindPBufferToTextureImplementation(buffer) else osg::notify(osg::NOTICE)<<"GraphicsWindow::void bindPBufferToTextureImplementation(..) not implemented."<<std::endl; }
|
||||
|
||||
/** Swap the front and back buffers implementation.
|
||||
* Pure virtual - must be implemented by Concrate implementations of GraphicsContext. */
|
||||
virtual void swapBuffersImplementation() { if (_gw.valid()) _gw->swapBuffersImplementation() else osg::notify(osg::NOTICE)<<"GraphicsWindow:: swapBuffersImplementation() not implemented."<<std::endl; }
|
||||
|
||||
public:
|
||||
|
||||
// Override from GUIActionAdapter
|
||||
virtual void requestRedraw() { if (_gw.valid()) _gw->requestRedraw(); }
|
||||
|
||||
// Override from GUIActionAdapter
|
||||
virtual void requestContinuousUpdate(bool needed=true) { if (_gw.valid()) _gw->tequestContinuousUpdate(needed); }
|
||||
|
||||
// Override from GUIActionAdapter
|
||||
virtual void requestWarpPointer(float x,float y) { if (_gw.valid()) _gw->requestWarpPointer(x,y); }
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
osg::ref_ptr<osgViewer::GraphicsWindow> _gw;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
87
include/osgViewer/Scene
Normal file
87
include/osgViewer/Scene
Normal file
@@ -0,0 +1,87 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSGVIEWER_SCENE
|
||||
#define OSGVIEWER_SCENE 1
|
||||
|
||||
#include <osgUtil/UpdateVisitor>
|
||||
#include <osgGA/GUIEventHandler>
|
||||
#include <osgGA/EventVisitor>
|
||||
#include <osgDB/DatabasePager>
|
||||
|
||||
#include <osgViewer/Export>
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace osgViewer{
|
||||
|
||||
// WARNING ** Under development do not use, yet :-)
|
||||
|
||||
/** Scene holds the highe level reference to a single scene graph.*/
|
||||
class OSGVIEWER_EXPORT Scene : public virtual osg::Referenced
|
||||
{
|
||||
public:
|
||||
|
||||
Scene();
|
||||
virtual ~Scene();
|
||||
|
||||
void setSceneData(osg::Node* node);
|
||||
osg::Node* getSceneData();
|
||||
const osg::Node* getSceneData() const;
|
||||
|
||||
|
||||
void setEventQueue(osgGA::EventQueue* eventQueue) { _eventQueue = eventQueue; }
|
||||
osgGA::EventQueue* getEventQueue() { return _eventQueue.get(); }
|
||||
const osgGA::EventQueue* getEventQueue() const { return _eventQueue.get(); }
|
||||
|
||||
typedef std::list< osg::ref_ptr<osgGA::GUIEventHandler> > EventHandlers;
|
||||
|
||||
void addEventHandler(osgGA::GUIEventHandler* eventHandler);
|
||||
EventHandlers& getEventHandlers() { return _eventHandlers; }
|
||||
const EventHandlers& getEventHandlers() const { return _eventHandlers; }
|
||||
|
||||
void setDatabasePager(osgDB::DatabasePager* dp);
|
||||
osgDB::DatabasePager* getDatabasePager() { return _databasePager.get(); }
|
||||
const osgDB::DatabasePager* getDatabasePager() const { return _databasePager.get(); }
|
||||
|
||||
virtual void frameAdvance();
|
||||
virtual void frameEventTraversal();
|
||||
virtual void frameUpdateTraversal();
|
||||
|
||||
public:
|
||||
|
||||
void init();
|
||||
|
||||
protected:
|
||||
|
||||
bool _firstFrame;
|
||||
osg::Timer_t _startTick;
|
||||
osg::ref_ptr<osg::FrameStamp> _frameStamp;
|
||||
|
||||
osg::ref_ptr<osg::Node> _sceneData;
|
||||
|
||||
osg::ref_ptr<osgUtil::UpdateVisitor> _updateVisitor;
|
||||
|
||||
osg::ref_ptr<osgGA::EventQueue> _eventQueue;
|
||||
osg::ref_ptr<osgGA::EventVisitor> _eventVisitor;
|
||||
|
||||
osg::ref_ptr<osgDB::DatabasePager> _databasePager;
|
||||
|
||||
EventHandlers _eventHandlers;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -42,8 +42,8 @@ class OSGVIEWER_EXPORT SimpleViewer : public virtual osgViewer::GraphicsWindow
|
||||
const osgDB::DatabasePager* getDatabasePager() const { return _databasePager.get(); }
|
||||
|
||||
|
||||
osg::CameraNode* getCamera();
|
||||
const osg::CameraNode* getCamera() const;
|
||||
osg::Camera* getCamera();
|
||||
const osg::Camera* getCamera() const;
|
||||
|
||||
void setCameraManipulator(osgGA::MatrixManipulator* manipulator);
|
||||
osgGA::MatrixManipulator* getCameraManipulator() { return _cameraManipulator.get(); }
|
||||
|
||||
58
include/osgViewer/View
Normal file
58
include/osgViewer/View
Normal file
@@ -0,0 +1,58 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSGVIEWER_VIEW
|
||||
#define OSGVIEWER_VIEW 1
|
||||
|
||||
#include <osg/View>
|
||||
#include <osgGA/MatrixManipulator>
|
||||
#include <osgViewer/Scene>
|
||||
|
||||
/** View holds a single view on a scene, this view may be composed of one or more slave cameras.*/
|
||||
class OSGVIEWER_EXPORT View : public virtual osg::View, public osgViewer::Scene
|
||||
{
|
||||
public:
|
||||
|
||||
View();
|
||||
virtual ~View();
|
||||
|
||||
void setSceneData(osg::Node* node);
|
||||
osg::Node* getSceneData();
|
||||
const osg::Node* getSceneData() const;
|
||||
|
||||
void setCameraManipulator(osgGA::MatrixManipulator* manipulator);
|
||||
osgGA::MatrixManipulator* getCameraManipulator() { return _cameraManipulator.get(); }
|
||||
const osgGA::MatrixManipulator* getCameraManipulator() const { return _cameraManipulator.get(); }
|
||||
|
||||
typedef std::list< osg::ref_ptr<osgGA::GUIEventHandler> > EventHandlers;
|
||||
|
||||
void addEventHandler(osgGA::GUIEventHandler* eventHandler);
|
||||
EventHandlers& getEventHandlers() { return _eventHandlers; }
|
||||
const EventHandlers& getEventHandlers() const { return _eventHandlers; }
|
||||
|
||||
public:
|
||||
|
||||
void init();
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
osg::ref_ptr<osgViewer::Scene> _scene;
|
||||
|
||||
osg::ref_ptr<osgUtil::SceneView> _sceneView;
|
||||
osg::ref_ptr<osgGA::MatrixManipulator> _cameraManipulator;
|
||||
EventHandlers _eventHandlers;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
61
include/osgViewer/Viewer
Normal file
61
include/osgViewer/Viewer
Normal file
@@ -0,0 +1,61 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSGVIEWER_Viewer
|
||||
#define OSGVIEWER_Viewer 1
|
||||
|
||||
#include <osgViewer/GraphicsWindow>
|
||||
#include <osgViewer/View>
|
||||
|
||||
namespace osgViewer{
|
||||
|
||||
// WARNING ** Under development do not use, yet :-)
|
||||
|
||||
/** Viewer holds a single view on to a single scene..*/
|
||||
class OSGVIEWER_EXPORT Viewer : public osgViewer::View
|
||||
{
|
||||
public:
|
||||
|
||||
Viewer();
|
||||
virtual ~Viewer();
|
||||
|
||||
/** 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.*/
|
||||
virtual void frame();
|
||||
|
||||
virtual void frameAdvance();
|
||||
virtual void frameEventTraversal();
|
||||
virtual void frameUpdateTraversal();
|
||||
virtual void frameCullTraversal();
|
||||
virtual void frameDrawTraversal();
|
||||
|
||||
/** 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. Note, must only be called from the graphics context associated with this viewer.*/
|
||||
virtual void cleanup();
|
||||
|
||||
public:
|
||||
|
||||
void init();
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user