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:
Robert Osfield
2006-11-27 14:52:07 +00:00
parent b82e521444
commit fd2ffeb310
110 changed files with 2257 additions and 1466 deletions

404
include/osg/Camera Normal file
View File

@@ -0,0 +1,404 @@
/* -*-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 OSG_CAMERA
#define OSG_CAMERA 1
#include <osg/Transform>
#include <osg/Viewport>
#include <osg/ColorMask>
#include <osg/CullSettings>
#include <osg/Texture>
#include <osg/Image>
#include <osg/GraphicsContext>
#include <OpenThreads/Mutex>
namespace osg {
// forward declare View to allow Camera to point back to the View that its within
class View;
/** Camera - is a subclass of Transform which represents encapsulates the settings of a Camera.
*/
class OSG_EXPORT Camera : public Transform, public CullSettings
{
public :
Camera();
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
Camera(const Camera&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_Node(osg, Camera);
/** Set the View that this Camera is part of. */
void setView(View* view) { _view = view; }
/** Get the View that this Camera is part of. */
View* getView() { return _view; }
/** Get the const View that this Camera is part of. */
const View* getView() const { return _view; }
/** Sets the clear color. */
inline void setClearColor(const Vec4& color) { _clearColor = color; }
/** Returns the clear color. */
inline const Vec4& getClearColor() const { return _clearColor; }
/** Set the clear mask used in glClear(..).
* Defaults to GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT. */
inline void setClearMask(GLbitfield mask) { _clearMask = mask; }
/** Get the clear mask.*/
inline GLbitfield getClearMask() const { return _clearMask; }
/** Set the color mask of the camera to use specified osg::ColorMask. */
void setColorMask(osg::ColorMask* colorMask);
/** Set the color mask of the camera to specified values. */
void setColorMask(bool red, bool green, bool blue, bool alpha);
/** Get the const ColorMask. */
const ColorMask* getColorMask() const { return _colorMask.get(); }
/** Get the ColorMask. */
ColorMask* getColorMask() { return _colorMask.get(); }
/** Set the viewport of the camera to use specified osg::Viewport. */
void setViewport(osg::Viewport* viewport);
/** Set the viewport of the camera to specified dimensions. */
void setViewport(int x,int y,int width,int height);
/** Get the const viewport. */
const Viewport* getViewport() const { return _viewport.get(); }
/** Get the viewport. */
Viewport* getViewport() { return _viewport.get(); }
enum TransformOrder
{
PRE_MULTIPLY,
POST_MULTIPLY
};
/** Set the transformation order for world-to-local and local-to-world transformation.*/
void setTransformOrder(TransformOrder order) { _transformOrder = order; }
/** Get the transformation order.*/
TransformOrder getTransformOrder() const { return _transformOrder; }
/** Set the projection matrix. Can be thought of as setting the lens of a camera. */
inline void setProjectionMatrix(const osg::Matrixf& matrix) { _projectionMatrix.set(matrix); }
/** Set the projection matrix. Can be thought of as setting the lens of a camera. */
inline void setProjectionMatrix(const osg::Matrixd& matrix) { _projectionMatrix.set(matrix); }
/** Set to an orthographic projection. See OpenGL glOrtho for documentation further details.*/
void setProjectionMatrixAsOrtho(double left, double right,
double bottom, double top,
double zNear, double zFar);
/** Set to a 2D orthographic projection. See OpenGL glOrtho2D documentation for further details.*/
void setProjectionMatrixAsOrtho2D(double left, double right,
double bottom, double top);
/** Set to a perspective projection. See OpenGL glFrustum documentation for further details.*/
void setProjectionMatrixAsFrustum(double left, double right,
double bottom, double top,
double zNear, double zFar);
/** Create a symmetrical perspective projection, See OpenGL gluPerspective documentation for further details.
* Aspect ratio is defined as width/height.*/
void setProjectionMatrixAsPerspective(double fovy,double aspectRatio,
double zNear, double zFar);
/** Get the projection matrix.*/
osg::Matrixd& getProjectionMatrix() { return _projectionMatrix; }
/** Get the const projection matrix.*/
const osg::Matrixd& getProjectionMatrix() const { return _projectionMatrix; }
/** Get the othographic settings of the orthographic projection matrix.
* Returns false if matrix is not an orthographic matrix, where parameter values are undefined.*/
bool getProjectionMatrixAsOrtho(double& left, double& right,
double& bottom, double& top,
double& zNear, double& zFar);
/** Get the frustum setting of a perspective projection matrix.
* Returns false if matrix is not a perspective matrix, where parameter values are undefined.*/
bool getProjectionMatrixAsFrustum(double& left, double& right,
double& bottom, double& top,
double& zNear, double& zFar);
/** Get the frustum setting of a symmetric perspective projection matrix.
* Returns false if matrix is not a perspective matrix, where parameter values are undefined.
* Note, if matrix is not a symmetric perspective matrix then the shear will be lost.
* Asymmetric matrices occur when stereo, power walls, caves and reality center display are used.
* In these configurations one should use the 'getProjectionMatrixAsFrustum' method instead.*/
bool getProjectionMatrixAsPerspective(double& fovy,double& aspectRatio,
double& zNear, double& zFar);
/** Set the view matrix. Can be thought of as setting the position of the world relative to the camera in camera coordinates. */
inline void setViewMatrix(const osg::Matrixf& matrix) { _viewMatrix.set(matrix); dirtyBound();}
/** Set the view matrix. Can be thought of as setting the position of the world relative to the camera in camera coordinates. */
inline void setViewMatrix(const osg::Matrixd& matrix) { _viewMatrix.set(matrix); dirtyBound();}
/** Set to the position and orientation of view matrix, using the same convention as gluLookAt. */
void setViewMatrixAsLookAt(const osg::Vec3& eye,const osg::Vec3& center,const osg::Vec3& up);
/** Get the view matrix. */
osg::Matrixd& getViewMatrix() { return _viewMatrix; }
/** Get the const view matrix. */
const osg::Matrixd& getViewMatrix() const { return _viewMatrix; }
/** Get to the position and orientation of a modelview matrix, using the same convention as gluLookAt. */
void getViewMatrixAsLookAt(osg::Vec3& eye,osg::Vec3& center,osg::Vec3& up,float lookDistance=1.0f);
/** Get the inverse view matrix.*/
Matrixd getInverseViewMatrix() const;
enum RenderOrder
{
PRE_RENDER,
NESTED_RENDER,
POST_RENDER
};
/** Set the rendering order of this camera's subgraph relative to any camera that this subgraph is nested within.
* For rendering to a texture, one typically uses PRE_RENDER.
* For Head Up Displays, one would typically use POST_RENDER.*/
void setRenderOrder(RenderOrder order, int orderNum = 0) { _renderOrder = order; _renderOrderNum = orderNum; }
/** Get the rendering order of this camera's subgraph relative to any camera that this subgraph is nested within.*/
RenderOrder getRenderOrder() const { return _renderOrder; }
/** Get the rendering order number of this camera relative to any sibling cameras in this subgraph.*/
int getRenderOrderNum() const { return _renderOrderNum; }
/** Return true if this Camera is set up as a render to texture camera, i.e. it has textures assigned to it.*/
bool isRenderToTextureCamera() const;
enum RenderTargetImplementation
{
FRAME_BUFFER_OBJECT,
PIXEL_BUFFER_RTT,
PIXEL_BUFFER,
FRAME_BUFFER,
SEPERATE_WINDOW
};
/** Set the render target.*/
void setRenderTargetImplementation(RenderTargetImplementation impl);
/** Set the render target and fall-back that's used if the former isn't available.*/
void setRenderTargetImplementation(RenderTargetImplementation impl, RenderTargetImplementation fallback);
/** Get the render target.*/
RenderTargetImplementation getRenderTargetImplementation() const { return _renderTargetImplementation; }
/** Get the render target fallback.*/
RenderTargetImplementation getRenderTargetFallback() const { return _renderTargetFallback; }
/** Set the draw buffer used at the start of each frame draw.
* Note, a buffer value of GL_NONE is used to sepecify that the rendering back-end should choose the most appropriate buffer.*/
void setDrawBuffer(GLenum buffer) { _drawBuffer = buffer; }
/** Get the draw buffer used at the start of each frame draw. */
GLenum getDrawBuffer() const { return _drawBuffer; }
/** Set the read buffer for any required copy operations to use.
* Note, a buffer value of GL_NONE is used to sepecify that the rendering back-end should choose the most appropriate buffer.*/
void setReadBuffer(GLenum buffer) { _readBuffer = buffer; }
/** Get the read buffer for any required copy operations to use. */
GLenum getReadBuffer() const { return _readBuffer; }
enum BufferComponent
{
DEPTH_BUFFER,
STENCIL_BUFFER,
COLOR_BUFFER,
COLOR_BUFFER0 = COLOR_BUFFER,
COLOR_BUFFER1 = COLOR_BUFFER+1,
COLOR_BUFFER2 = COLOR_BUFFER+2,
COLOR_BUFFER3 = COLOR_BUFFER+3,
COLOR_BUFFER4 = COLOR_BUFFER+4,
COLOR_BUFFER5 = COLOR_BUFFER+5,
COLOR_BUFFER6 = COLOR_BUFFER+6,
COLOR_BUFFER7 = COLOR_BUFFER+7
};
void attach(BufferComponent buffer, GLenum internalFormat);
void attach(BufferComponent buffer, osg::Texture* texture, unsigned int level = 0, unsigned int face=0, bool mipMapGeneration=false);
void attach(BufferComponent buffer, osg::Image* image);
void detach(BufferComponent buffer);
struct Attachment
{
Attachment():
_internalFormat(GL_NONE),
_level(0),
_face(0),
_mipMapGeneration(false) {}
int width() const
{
if (_texture.valid()) return _texture->getTextureWidth();
if (_image.valid()) return _image->s();
return 0;
};
int height() const
{
if (_texture.valid()) return _texture->getTextureHeight();
if (_image.valid()) return _image->t();
return 0;
};
int depth() const
{
if (_texture.valid()) return _texture->getTextureDepth();
if (_image.valid()) return _image->r();
return 0;
};
GLenum _internalFormat;
ref_ptr<Image> _image;
ref_ptr<Texture> _texture;
unsigned int _level;
unsigned int _face;
bool _mipMapGeneration;
};
typedef std::map< BufferComponent, Attachment> BufferAttachmentMap;
/** Get the BufferAttachmentMap, used to configure frame buffer objects, pbuffers and texture reads.*/
BufferAttachmentMap& getBufferAttachmentMap() { return _bufferAttachmentMap; }
/** Get the const BufferAttachmentMap, used to configure frame buffer objects, pbuffers and texture reads.*/
const BufferAttachmentMap& getBufferAttachmentMap() const { return _bufferAttachmentMap; }
/** Set the GraphicsContext that provides the mechansim for managing the OpenGL graphics context associated with this camera.*/
void setGraphicsContext(GraphicsContext* context) { _graphicsContext = context; }
/** Get the GraphicsContext.*/
GraphicsContext* getGraphicsContext() { return _graphicsContext.get(); }
/** Get the const GraphicsContext.*/
const GraphicsContext* getGraphicsContext() const { return _graphicsContext.get(); }
/** Set the Rendering object that is used to implement rendering of the subgraph.*/
void setRenderingCache(unsigned int contextID, osg::Object* rc) { _renderingCache[contextID] = rc; }
/** Get the Rendering object that is used to implement rendering of the subgraph.*/
osg::Object* getRenderingCache(unsigned int contextID) { return _renderingCache[contextID].get(); }
/** Get the const Rendering object that is used to implement rendering of the subgraph.*/
const osg::Object* getRenderingCache(unsigned int contextID) const { return _renderingCache[contextID].get(); }
/** Draw callback for custom operations.*/
struct DrawCallback : virtual public Object
{
DrawCallback() {}
DrawCallback(const DrawCallback&,const CopyOp&) {}
META_Object(osg,DrawCallback)
virtual void operator () (const osg::Camera& /*camera*/) const {}
};
/** Set the post draw callback for custom operations to do done after the drawing of the camera's subgraph has been completed.*/
void setPostDrawCallback(DrawCallback* cb) { _postDrawCallback = cb; }
/** Get the post draw callback.*/
DrawCallback* getPostDrawCallback() { return _postDrawCallback.get(); }
/** Get the const post draw callback.*/
const DrawCallback* getPostDrawCallback() const { return _postDrawCallback.get(); }
OpenThreads::Mutex* getDataChangeMutex() const { return &_dataChangeMutex; }
/** If State is non-zero, this function releases any associated OpenGL objects for
* the specified graphics context. Otherwise, releases OpenGL objexts
* for all graphics contexts. */
virtual void releaseGLObjects(osg::State* = 0) const;
public:
/** Transform method that must be defined to provide generic interface for scene graph traversals.*/
virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const;
/** Transform method that must be defined to provide generic interface for scene graph traversals.*/
virtual bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor*) const;
protected :
virtual ~Camera();
mutable OpenThreads::Mutex _dataChangeMutex;
View* _view;
Vec4 _clearColor;
GLbitfield _clearMask;
ref_ptr<ColorMask> _colorMask;
ref_ptr<Viewport> _viewport;
TransformOrder _transformOrder;
Matrixd _projectionMatrix;
Matrixd _viewMatrix;
RenderOrder _renderOrder;
int _renderOrderNum;
GLenum _drawBuffer;
GLenum _readBuffer;
RenderTargetImplementation _renderTargetImplementation;
RenderTargetImplementation _renderTargetFallback;
BufferAttachmentMap _bufferAttachmentMap;
ref_ptr<GraphicsContext> _graphicsContext;
buffered_object< ref_ptr<Object> > _renderingCache;
ref_ptr<DrawCallback> _postDrawCallback;
};
}
#endif

View File

@@ -14,390 +14,13 @@
#ifndef OSG_CAMERANODE
#define OSG_CAMERANODE 1
#include <osg/Transform>
#include <osg/Viewport>
#include <osg/ColorMask>
#include <osg/CullSettings>
#include <osg/Texture>
#include <osg/Image>
#include <osg/GraphicsContext>
#include <OpenThreads/Mutex>
#include <osg/Camera>
namespace osg {
// forward declare View to allow CameraNode to point back to the View that its within
class View;
/** CameraNode - is a subclass of Transform which represents encapsulates the settings of a Camera.
*/
class OSG_EXPORT CameraNode : public Transform, public CullSettings
{
public :
CameraNode();
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
CameraNode(const CameraNode&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_Node(osg, CameraNode);
/** Set the View that this Camera is part of. */
void setView(View* view) { _view = view; }
/** Get the View that this Camera is part of. */
View* getView() { return _view; }
/** Get the const View that this Camera is part of. */
const View* getView() const { return _view; }
/** Sets the clear color. */
inline void setClearColor(const Vec4& color) { _clearColor = color; }
/** Returns the clear color. */
inline const Vec4& getClearColor() const { return _clearColor; }
/** Set the clear mask used in glClear(..).
* Defaults to GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT. */
inline void setClearMask(GLbitfield mask) { _clearMask = mask; }
/** Get the clear mask.*/
inline GLbitfield getClearMask() const { return _clearMask; }
/** Set the color mask of the camera to use specified osg::ColorMask. */
void setColorMask(osg::ColorMask* colorMask);
/** Set the color mask of the camera to specified values. */
void setColorMask(bool red, bool green, bool blue, bool alpha);
/** Get the const ColorMask. */
const ColorMask* getColorMask() const { return _colorMask.get(); }
/** Get the ColorMask. */
ColorMask* getColorMask() { return _colorMask.get(); }
/** Set the viewport of the camera to use specified osg::Viewport. */
void setViewport(osg::Viewport* viewport);
/** Set the viewport of the camera to specified dimensions. */
void setViewport(int x,int y,int width,int height);
/** Get the const viewport. */
const Viewport* getViewport() const { return _viewport.get(); }
/** Get the viewport. */
Viewport* getViewport() { return _viewport.get(); }
enum TransformOrder
{
PRE_MULTIPLY,
POST_MULTIPLY
};
/** Set the transformation order for world-to-local and local-to-world transformation.*/
void setTransformOrder(TransformOrder order) { _transformOrder = order; }
/** Get the transformation order.*/
TransformOrder getTransformOrder() const { return _transformOrder; }
/** Set the projection matrix. Can be thought of as setting the lens of a camera. */
inline void setProjectionMatrix(const osg::Matrixf& matrix) { _projectionMatrix.set(matrix); }
/** Set the projection matrix. Can be thought of as setting the lens of a camera. */
inline void setProjectionMatrix(const osg::Matrixd& matrix) { _projectionMatrix.set(matrix); }
/** Set to an orthographic projection. See OpenGL glOrtho for documentation further details.*/
void setProjectionMatrixAsOrtho(double left, double right,
double bottom, double top,
double zNear, double zFar);
/** Set to a 2D orthographic projection. See OpenGL glOrtho2D documentation for further details.*/
void setProjectionMatrixAsOrtho2D(double left, double right,
double bottom, double top);
/** Set to a perspective projection. See OpenGL glFrustum documentation for further details.*/
void setProjectionMatrixAsFrustum(double left, double right,
double bottom, double top,
double zNear, double zFar);
/** Create a symmetrical perspective projection, See OpenGL gluPerspective documentation for further details.
* Aspect ratio is defined as width/height.*/
void setProjectionMatrixAsPerspective(double fovy,double aspectRatio,
double zNear, double zFar);
/** Get the projection matrix.*/
osg::Matrixd& getProjectionMatrix() { return _projectionMatrix; }
/** Get the const projection matrix.*/
const osg::Matrixd& getProjectionMatrix() const { return _projectionMatrix; }
/** Get the othographic settings of the orthographic projection matrix.
* Returns false if matrix is not an orthographic matrix, where parameter values are undefined.*/
bool getProjectionMatrixAsOrtho(double& left, double& right,
double& bottom, double& top,
double& zNear, double& zFar);
/** Get the frustum setting of a perspective projection matrix.
* Returns false if matrix is not a perspective matrix, where parameter values are undefined.*/
bool getProjectionMatrixAsFrustum(double& left, double& right,
double& bottom, double& top,
double& zNear, double& zFar);
/** Get the frustum setting of a symmetric perspective projection matrix.
* Returns false if matrix is not a perspective matrix, where parameter values are undefined.
* Note, if matrix is not a symmetric perspective matrix then the shear will be lost.
* Asymmetric matrices occur when stereo, power walls, caves and reality center display are used.
* In these configurations one should use the 'getProjectionMatrixAsFrustum' method instead.*/
bool getProjectionMatrixAsPerspective(double& fovy,double& aspectRatio,
double& zNear, double& zFar);
/** Set the view matrix. Can be thought of as setting the position of the world relative to the camera in camera coordinates. */
inline void setViewMatrix(const osg::Matrixf& matrix) { _viewMatrix.set(matrix); dirtyBound();}
/** Set the view matrix. Can be thought of as setting the position of the world relative to the camera in camera coordinates. */
inline void setViewMatrix(const osg::Matrixd& matrix) { _viewMatrix.set(matrix); dirtyBound();}
/** Set to the position and orientation of view matrix, using the same convention as gluLookAt. */
void setViewMatrixAsLookAt(const osg::Vec3& eye,const osg::Vec3& center,const osg::Vec3& up);
/** Get the view matrix. */
osg::Matrixd& getViewMatrix() { return _viewMatrix; }
/** Get the const view matrix. */
const osg::Matrixd& getViewMatrix() const { return _viewMatrix; }
/** Get to the position and orientation of a modelview matrix, using the same convention as gluLookAt. */
void getViewMatrixAsLookAt(osg::Vec3& eye,osg::Vec3& center,osg::Vec3& up,float lookDistance=1.0f);
/** Get the inverse view matrix.*/
Matrixd getInverseViewMatrix() const;
enum RenderOrder
{
PRE_RENDER,
NESTED_RENDER,
POST_RENDER
};
/** Set the rendering order of this camera's subgraph relative to any camera that this subgraph is nested within.
* For rendering to a texture, one typically uses PRE_RENDER.
* For Head Up Displays, one would typically use POST_RENDER.*/
void setRenderOrder(RenderOrder order, int orderNum = 0) { _renderOrder = order; _renderOrderNum = orderNum; }
/** Get the rendering order of this camera's subgraph relative to any camera that this subgraph is nested within.*/
RenderOrder getRenderOrder() const { return _renderOrder; }
/** Get the rendering order number of this camera relative to any sibling cameras in this subgraph.*/
int getRenderOrderNum() const { return _renderOrderNum; }
/** Return true if this Camera is set up as a render to texture camera, i.e. it has textures assigned to it.*/
bool isRenderToTextureCamera() const;
enum RenderTargetImplementation
{
FRAME_BUFFER_OBJECT,
PIXEL_BUFFER_RTT,
PIXEL_BUFFER,
FRAME_BUFFER,
SEPERATE_WINDOW
};
/** Set the render target.*/
void setRenderTargetImplementation(RenderTargetImplementation impl);
/** Set the render target and fall-back that's used if the former isn't available.*/
void setRenderTargetImplementation(RenderTargetImplementation impl, RenderTargetImplementation fallback);
/** Get the render target.*/
RenderTargetImplementation getRenderTargetImplementation() const { return _renderTargetImplementation; }
/** Get the render target fallback.*/
RenderTargetImplementation getRenderTargetFallback() const { return _renderTargetFallback; }
/** Set the draw buffer used at the start of each frame draw.
* Note, a buffer value of GL_NONE is used to sepecify that the rendering back-end should choose the most appropriate buffer.*/
void setDrawBuffer(GLenum buffer) { _drawBuffer = buffer; }
/** Get the draw buffer used at the start of each frame draw. */
GLenum getDrawBuffer() const { return _drawBuffer; }
/** Set the read buffer for any required copy operations to use.
* Note, a buffer value of GL_NONE is used to sepecify that the rendering back-end should choose the most appropriate buffer.*/
void setReadBuffer(GLenum buffer) { _readBuffer = buffer; }
/** Get the read buffer for any required copy operations to use. */
GLenum getReadBuffer() const { return _readBuffer; }
enum BufferComponent
{
DEPTH_BUFFER,
STENCIL_BUFFER,
COLOR_BUFFER,
COLOR_BUFFER0 = COLOR_BUFFER,
COLOR_BUFFER1 = COLOR_BUFFER+1,
COLOR_BUFFER2 = COLOR_BUFFER+2,
COLOR_BUFFER3 = COLOR_BUFFER+3,
COLOR_BUFFER4 = COLOR_BUFFER+4,
COLOR_BUFFER5 = COLOR_BUFFER+5,
COLOR_BUFFER6 = COLOR_BUFFER+6,
COLOR_BUFFER7 = COLOR_BUFFER+7
};
void attach(BufferComponent buffer, GLenum internalFormat);
void attach(BufferComponent buffer, osg::Texture* texture, unsigned int level = 0, unsigned int face=0, bool mipMapGeneration=false);
void attach(BufferComponent buffer, osg::Image* image);
void detach(BufferComponent buffer);
struct Attachment
{
Attachment():
_internalFormat(GL_NONE),
_level(0),
_face(0),
_mipMapGeneration(false) {}
int width() const
{
if (_texture.valid()) return _texture->getTextureWidth();
if (_image.valid()) return _image->s();
return 0;
};
int height() const
{
if (_texture.valid()) return _texture->getTextureHeight();
if (_image.valid()) return _image->t();
return 0;
};
int depth() const
{
if (_texture.valid()) return _texture->getTextureDepth();
if (_image.valid()) return _image->r();
return 0;
};
GLenum _internalFormat;
ref_ptr<Image> _image;
ref_ptr<Texture> _texture;
unsigned int _level;
unsigned int _face;
bool _mipMapGeneration;
};
typedef std::map< BufferComponent, Attachment> BufferAttachmentMap;
/** Get the BufferAttachmentMap, used to configure frame buffer objects, pbuffers and texture reads.*/
BufferAttachmentMap& getBufferAttachmentMap() { return _bufferAttachmentMap; }
/** Get the const BufferAttachmentMap, used to configure frame buffer objects, pbuffers and texture reads.*/
const BufferAttachmentMap& getBufferAttachmentMap() const { return _bufferAttachmentMap; }
/** Set the GraphicsContext that provides the mechansim for managing the OpenGL graphics context associated with this camera.*/
void setGraphicsContext(GraphicsContext* context) { _graphicsContext = context; }
/** Get the GraphicsContext.*/
GraphicsContext* getGraphicsContext() { return _graphicsContext.get(); }
/** Get the const GraphicsContext.*/
const GraphicsContext* getGraphicsContext() const { return _graphicsContext.get(); }
/** Set the Rendering object that is used to implement rendering of the subgraph.*/
void setRenderingCache(unsigned int contextID, osg::Object* rc) { _renderingCache[contextID] = rc; }
/** Get the Rendering object that is used to implement rendering of the subgraph.*/
osg::Object* getRenderingCache(unsigned int contextID) { return _renderingCache[contextID].get(); }
/** Get the const Rendering object that is used to implement rendering of the subgraph.*/
const osg::Object* getRenderingCache(unsigned int contextID) const { return _renderingCache[contextID].get(); }
/** Draw callback for custom operations.*/
struct DrawCallback : virtual public Object
{
DrawCallback() {}
DrawCallback(const DrawCallback&,const CopyOp&) {}
META_Object(osg,DrawCallback)
virtual void operator () (const osg::CameraNode& /*camera*/) const {}
};
/** Set the post draw callback for custom operations to do done after the drawing of the camera's subgraph has been completed.*/
void setPostDrawCallback(DrawCallback* cb) { _postDrawCallback = cb; }
/** Get the post draw callback.*/
DrawCallback* getPostDrawCallback() { return _postDrawCallback.get(); }
/** Get the const post draw callback.*/
const DrawCallback* getPostDrawCallback() const { return _postDrawCallback.get(); }
OpenThreads::Mutex* getDataChangeMutex() const { return &_dataChangeMutex; }
/** If State is non-zero, this function releases any associated OpenGL objects for
* the specified graphics context. Otherwise, releases OpenGL objexts
* for all graphics contexts. */
virtual void releaseGLObjects(osg::State* = 0) const;
public:
/** Transform method that must be defined to provide generic interface for scene graph traversals.*/
virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const;
/** Transform method that must be defined to provide generic interface for scene graph traversals.*/
virtual bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor*) const;
protected :
virtual ~CameraNode();
mutable OpenThreads::Mutex _dataChangeMutex;
View* _view;
Vec4 _clearColor;
GLbitfield _clearMask;
ref_ptr<ColorMask> _colorMask;
ref_ptr<Viewport> _viewport;
TransformOrder _transformOrder;
Matrixd _projectionMatrix;
Matrixd _viewMatrix;
RenderOrder _renderOrder;
int _renderOrderNum;
GLenum _drawBuffer;
GLenum _readBuffer;
RenderTargetImplementation _renderTargetImplementation;
RenderTargetImplementation _renderTargetFallback;
BufferAttachmentMap _bufferAttachmentMap;
ref_ptr<GraphicsContext> _graphicsContext;
buffered_object< ref_ptr<Object> > _renderingCache;
ref_ptr<DrawCallback> _postDrawCallback;
};
#ifdef USE_DEPRECATED_API
typedef osg::Camera CameraNode;
#endif
}

View File

@@ -19,7 +19,7 @@
#include <osg/GL>
#include <osg/Texture>
#include <osg/buffered_value>
#include <osg/CameraNode>
#include <osg/Camera>
#ifndef GL_EXT_framebuffer_object
#define GL_EXT_framebuffer_object 1
@@ -261,7 +261,7 @@ namespace osg
explicit FrameBufferAttachment(Texture3D* target, int zoffset, int level = 0);
explicit FrameBufferAttachment(TextureCubeMap* target, int face, int level = 0);
explicit FrameBufferAttachment(TextureRectangle* target);
explicit FrameBufferAttachment(CameraNode::Attachment& attachment);
explicit FrameBufferAttachment(Camera::Attachment& attachment);
~FrameBufferAttachment();

View File

@@ -38,9 +38,8 @@ class Sequence;
class Switch;
class TexGenNode;
class Transform;
class CameraNode;
class Camera;
class CameraView;
class View;
/** Visitor for type safe operations on osg::Nodes.
Based on GOF's Visitor pattern. The NodeVisitor
@@ -236,8 +235,7 @@ class OSG_EXPORT NodeVisitor : public virtual Referenced
virtual void apply(LightSource& node) { apply((Group&)node); }
virtual void apply(Transform& node) { apply((Group&)node); }
virtual void apply(View& node) { apply((Transform&)node); }
virtual void apply(CameraNode& node) { apply((Transform&)node); }
virtual void apply(Camera& node) { apply((Transform&)node); }
virtual void apply(CameraView& node) { apply((Transform&)node); }
virtual void apply(MatrixTransform& node) { apply((Transform&)node); }
virtual void apply(PositionAttitudeTransform& node) { apply((Transform&)node); }

View File

@@ -28,24 +28,24 @@ namespace osg {
/** Compute the matrix which transforms objects in local coords to world coords,
* by accumulating the Transform local to world matrices along the specified node path.
*/
extern OSG_EXPORT Matrix computeLocalToWorld(const NodePath& nodePath, bool ignoreCameraNodes = true);
extern OSG_EXPORT Matrix computeLocalToWorld(const NodePath& nodePath, bool ignoreCameras = true);
/** Compute the matrix which transforms objects in world coords to local coords,
* by accumulating the Transform world to local matrices along the specified node path.
*/
extern OSG_EXPORT Matrix computeWorldToLocal(const NodePath& nodePath, bool ignoreCameraNodes = true);
extern OSG_EXPORT Matrix computeWorldToLocal(const NodePath& nodePath, bool ignoreCameras = true);
/** Compute the matrix which transforms objects in local coords to eye coords,
* by accumulating the Transform local to world matrices along the specified node path
* and multipling by the supplied initial camera modelview.
*/
extern OSG_EXPORT Matrix computeLocalToEye(const Matrix& modelview, const NodePath& nodePath, bool ignoreCameraNodes = true);
extern OSG_EXPORT Matrix computeLocalToEye(const Matrix& modelview, const NodePath& nodePath, bool ignoreCameras = true);
/** Compute the matrix which transforms objects in eye coords to local coords,
* by accumulating the Transform world to local matrices along the specified node path
* and multipling by the inverse of the supplied initialial camera modelview.
*/
extern OSG_EXPORT Matrix computeEyeToLocal(const Matrix& modelview, const NodePath& nodePath, bool ignoreCameraNodes = true);
extern OSG_EXPORT Matrix computeEyeToLocal(const Matrix& modelview, const NodePath& nodePath, bool ignoreCameras = true);
/** A Transform is a group node for which all children are transformed by

View File

@@ -14,112 +14,43 @@
#ifndef OSG_VIEW
#define OSG_VIEW 1
#include <osg/CameraNode>
#include <osg/Camera>
#include <OpenThreads/Mutex>
namespace osg {
/** View - is a subclass of Transform which encompasses all the cameras that combine to make up a single view of the scene.
/** View - maintains a master camera view and a list of slave cameras that are relative to this master camera.
* Note, if no slave cameras are attached to the view then the master camera does both the control and implementation of the rendering of the scene,
* but if slave cameras are present then the master controls the view onto the scene, while the slaves implement the rendering of the scene.
*/
class OSG_EXPORT View : public osg::Transform, public CullSettings
class OSG_EXPORT View : public osg::Referenced
{
public :
View();
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
View(const View&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
/** Set the master camera of the view. */
void setCamera(osg::Camera* camera) { _camera = camera; }
META_Node(osg, View);
/** Get the master camera of the view. */
osg::Camera* getCamera() { return _camera.get(); }
/** Get the const master camera of the view. */
const osg::Camera* getCamera() const { return _camera.get(); }
/** Set the projection matrix. Can be thought of as setting the lens of a camera. */
inline void setProjectionMatrix(const osg::Matrixf& matrix) { _projectionMatrix.set(matrix); updateCameras(); }
/** Set the projection matrix. Can be thought of as setting the lens of a camera. */
inline void setProjectionMatrix(const osg::Matrixd& matrix) { _projectionMatrix.set(matrix); updateCameras(); }
/** Set to an orthographic projection. See OpenGL glOrtho for documentation further details.*/
void setProjectionMatrixAsOrtho(double left, double right,
double bottom, double top,
double zNear, double zFar);
/** Set to a 2D orthographic projection. See OpenGL glOrtho2D documentation for further details.*/
void setProjectionMatrixAsOrtho2D(double left, double right,
double bottom, double top);
/** Set to a perspective projection. See OpenGL glFrustum documentation for further details.*/
void setProjectionMatrixAsFrustum(double left, double right,
double bottom, double top,
double zNear, double zFar);
/** Create a symmetrical perspective projection, See OpenGL gluPerspective documentation for further details.
* Aspect ratio is defined as width/height.*/
void setProjectionMatrixAsPerspective(double fovy,double aspectRatio,
double zNear, double zFar);
/** Get the projection matrix.*/
osg::Matrixd& getProjectionMatrix() { return _projectionMatrix; }
/** Get the const projection matrix.*/
const osg::Matrixd& getProjectionMatrix() const { return _projectionMatrix; }
/** Get the othographic settings of the orthographic projection matrix.
* Returns false if matrix is not an orthographic matrix, where parameter values are undefined.*/
bool getProjectionMatrixAsOrtho(double& left, double& right,
double& bottom, double& top,
double& zNear, double& zFar);
/** Get the frustum setting of a perspective projection matrix.
* Returns false if matrix is not a perspective matrix, where parameter values are undefined.*/
bool getProjectionMatrixAsFrustum(double& left, double& right,
double& bottom, double& top,
double& zNear, double& zFar);
/** Get the frustum setting of a symmetric perspective projection matrix.
* Returns false if matrix is not a perspective matrix, where parameter values are undefined.
* Note, if matrix is not a symmetric perspective matrix then the shear will be lost.
* Asymmetric matrices occur when stereo, power walls, caves and reality center display are used.
* In these configurations one should use the 'getProjectionMatrixAsFrustum' method instead.*/
bool getProjectionMatrixAsPerspective(double& fovy,double& aspectRatio,
double& zNear, double& zFar);
/** Set the view matrix. Can be thought of as setting the position of the world relative to the camera in camera coordinates. */
inline void setViewMatrix(const osg::Matrixf& matrix) { _viewMatrix.set(matrix); dirtyBound(); updateCameras(); }
/** Set the view matrix. Can be thought of as setting the position of the world relative to the camera in camera coordinates. */
inline void setViewMatrix(const osg::Matrixd& matrix) { _viewMatrix.set(matrix); dirtyBound(); updateCameras(); }
/** Set to the position and orientation of view matrix, using the same convention as gluLookAt. */
void setViewMatrixAsLookAt(const osg::Vec3& eye,const osg::Vec3& center,const osg::Vec3& up);
/** Get the view matrix. */
osg::Matrixd& getViewMatrix() { return _viewMatrix; }
/** Get the const view matrix. */
const osg::Matrixd& getViewMatrix() const { return _viewMatrix; }
/** Get to the position and orientation of a modelview matrix, using the same convention as gluLookAt. */
void getViewMatrixAsLookAt(osg::Vec3& eye,osg::Vec3& center,osg::Vec3& up,float lookDistance=1.0f);
/** Get the inverse view matrix.*/
Matrixd getInverseViewMatrix() const;
struct CameraData
/** Slave allows one to up a camera that follows the master with a local offset to the project and view matrices.*/
struct Slave
{
CameraData() {}
CameraData(osg::CameraNode* camera, const osg::Matrixd& projectionOffset, const osg::Matrixd& viewOffset):
Slave() {}
Slave(osg::Camera* camera, const osg::Matrixd& projectionOffset, const osg::Matrixd& viewOffset):
_camera(camera), _projectionOffset(projectionOffset), _viewOffset(viewOffset) {}
CameraData(const CameraData& rhs) :
Slave(const Slave& rhs) :
_camera(rhs._camera), _projectionOffset(rhs._projectionOffset), _viewOffset(rhs._viewOffset) {}
CameraData& operator = (const CameraData& rhs)
Slave& operator = (const Slave& rhs)
{
_camera = rhs._camera;
_projectionOffset = rhs._projectionOffset;
@@ -127,46 +58,32 @@ class OSG_EXPORT View : public osg::Transform, public CullSettings
return *this;
}
osg::ref_ptr<osg::CameraNode> _camera;
osg::ref_ptr<osg::Camera> _camera;
osg::Matrixd _projectionOffset;
osg::Matrixd _viewOffset;
};
bool addCamera(osg::CameraNode* camera) { return addCamera(camera, osg::Matrix::identity(), osg::Matrix::identity()); }
bool addSlave(osg::Camera* camera) { return addSlave(camera, osg::Matrix::identity(), osg::Matrix::identity()); }
bool addCamera(osg::CameraNode* camera, const osg::Matrix& projectionOffset, const osg::Matrix& viewOffse);
bool addSlave(osg::Camera* camera, const osg::Matrix& projectionOffset, const osg::Matrix& viewOffse);
bool removeCamera(unsigned int pos);
bool removeSlave(unsigned int pos);
unsigned int getNumCameras() const { return _cameras.size(); }
CameraNode* getCamera(unsigned int pos) { return _cameras[pos]._camera.get(); }
const CameraNode* getCamera(unsigned int pos) const { return _cameras[pos]._camera.get(); }
CameraData& getCameraData(unsigned int pos) { return _cameras[pos]; }
const CameraData& getCameraData(unsigned int pos) const { return _cameras[pos]; }
public:
/** Transform method that must be defined to provide generic interface for scene graph traversals.*/
virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const;
/** Transform method that must be defined to provide generic interface for scene graph traversals.*/
virtual bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor*) const;
unsigned int getNumSlaves() const { return _slaves.size(); }
Slave& getSlave(unsigned int pos) { return _slaves[pos]; }
const Slave& getSlave(unsigned int pos) const { return _slaves[pos]; }
protected :
virtual ~View();
void updateCameras();
void updateSlaves();
Matrixd _projectionMatrix;
Matrixd _viewMatrix;
osg::ref_ptr<osg::Camera> _camera;
typedef std::vector<CameraData> CameraList;
CameraList _cameras;
typedef std::vector<Slave> Slaves;
Slaves _slaves;
};
}

View File

@@ -14,7 +14,7 @@
#ifndef OSGSHADOW_PARALLELSPLITSHADOWMAP
#define OSGSHADOW_PARALLELSPLITSHADOWMAP 1
#include <osg/CameraNode>
#include <osg/Camera>
#include <osgShadow/ShadowTechnique>

View File

@@ -14,7 +14,7 @@
#ifndef OSGSHADOW_SHADOWEDTEXTURE
#define OSGSHADOW_SHADOWEDTEXTURE 1
#include <osg/CameraNode>
#include <osg/Camera>
#include <osgShadow/ShadowTechnique>

View File

@@ -15,7 +15,7 @@
#define OSGSHADOW_SHADOWEDTECHNIQUE 1
#include <osg/buffered_value>
#include <osg/CameraNode>
#include <osg/Camera>
#include <osg/Texture2D>
#include <osg/TexGenNode>

View File

@@ -14,7 +14,7 @@
#ifndef OSGSHADOW_SHADOWEDTEXTURE
#define OSGSHADOW_SHADOWEDTEXTURE 1
#include <osg/CameraNode>
#include <osg/Camera>
#include <osgShadow/ShadowTechnique>

View File

@@ -14,7 +14,7 @@
#ifndef OSGSHADOW_SHADOWVOLUME
#define OSGSHADOW_SHADOWVOLUME 1
#include <osg/CameraNode>
#include <osg/Camera>
#include <osgShadow/ShadowTechnique>

View File

@@ -15,7 +15,7 @@
#define OSGSHADOW_SHADOWEDSCENE 1
#include <osg/buffered_value>
#include <osg/CameraNode>
#include <osg/Camera>
#include <osg/Texture2D>
#include <osg/TexGenNode>

View File

@@ -20,7 +20,7 @@
#include <osg/AlphaFunc>
#include <osg/TexEnv>
#include <osg/Texture2D>
#include <osg/CameraNode>
#include <osg/Camera>
#include <osgSim/Export>
@@ -152,13 +152,13 @@ class OSGSIM_EXPORT ImpostorSprite : public osg::Drawable
virtual osg::BoundingBox computeBound() const;
/** Set the camera node to use for pre rendering the impostor sprite's texture.*/
void setCameraNode(osg::CameraNode* camera) { _camera = camera; }
void setCamera(osg::Camera* camera) { _camera = camera; }
/** Get the camera node to use for pre rendering the impostor sprite's texture.*/
osg::CameraNode* getCameraNode() { return _camera.get(); }
osg::Camera* getCamera() { return _camera.get(); }
/** Get the const camera node to use for pre rendering the impostor sprite's texture.*/
const osg::CameraNode* getCameraNode() const { return _camera.get(); }
const osg::Camera* getCamera() const { return _camera.get(); }
protected:
@@ -172,7 +172,7 @@ class OSGSIM_EXPORT ImpostorSprite : public osg::Drawable
friend class osgSim::ImpostorSpriteManager;
// camera node for doing the pre rendering.
osg::ref_ptr<osg::CameraNode> _camera;
osg::ref_ptr<osg::Camera> _camera;
// support for a double linked list managed by the
// ImposotorSpriteManager.

View File

@@ -15,7 +15,7 @@
#define OSGSIM_OVERLAYNODE 1
#include <osg/buffered_value>
#include <osg/CameraNode>
#include <osg/Camera>
#include <osg/Texture2D>
#include <osg/TexGenNode>
@@ -82,10 +82,10 @@ class OSGSIM_EXPORT OverlayNode : public osg::Group
/** Get the camera used to implement the render to texture of the overlay subgraph.*/
osg::CameraNode* getCamera() { return _camera.get(); }
osg::Camera* getCamera() { return _camera.get(); }
/** Get the const camera used to implement the render to texture of the overlay subgraph.*/
const osg::CameraNode* getCamera() const { return _camera.get(); }
const osg::Camera* getCamera() const { return _camera.get(); }
protected :
@@ -99,7 +99,7 @@ class OSGSIM_EXPORT OverlayNode : public osg::Group
mutable TextureObjectValidList _textureObjectValidList;
osg::ref_ptr<osg::CameraNode> _camera;
osg::ref_ptr<osg::Camera> _camera;
// overlay subgraph is render to a texture
osg::ref_ptr<osg::Node> _overlaySubgraph;

View File

@@ -25,7 +25,7 @@
#include <osg/StateSet>
#include <osg/State>
#include <osg/ClearNode>
#include <osg/CameraNode>
#include <osg/Camera>
#include <osg/Notify>
#include <osg/CullStack>
@@ -76,7 +76,7 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac
virtual void apply(osg::Switch& node);
virtual void apply(osg::LOD& node);
virtual void apply(osg::ClearNode& node);
virtual void apply(osg::CameraNode& node);
virtual void apply(osg::Camera& node);
virtual void apply(osg::OccluderNode& node);
void setClearNode(const osg::ClearNode* earthSky) { _clearNode = earthSky; }

View File

@@ -213,7 +213,7 @@ class OSGUTIL_EXPORT PickVisitor : public osgUtil::IntersectVisitor
void apply(osg::Projection& projection);
void apply(osg::CameraNode& camera);
void apply(osg::Camera& camera);
protected:

View File

@@ -323,7 +323,7 @@ class OSGUTIL_EXPORT IntersectionVisitor : public osg::NodeVisitor
virtual void apply(osg::PagedLOD& lod);
virtual void apply(osg::Transform& transform);
virtual void apply(osg::Projection& projection);
virtual void apply(osg::CameraNode& camera);
virtual void apply(osg::Camera& camera);
protected:

View File

@@ -18,7 +18,7 @@
#include <osg/Viewport>
#include <osg/Texture>
#include <osg/FrameBufferObject>
#include <osg/CameraNode>
#include <osg/Camera>
#include <osgUtil/RenderBin>
#include <osgUtil/PositionalStateContainer>
@@ -119,9 +119,9 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
/** Get the clear color.*/
int getClearStencil() const { return _clearStencil; }
void setCameraNode(osg::CameraNode* camera) { if (_camera!=camera) { _camera = camera; _cameraRequiresSetUp = true; } }
osg::CameraNode* getCameraNode() { return _camera; }
const osg::CameraNode* getCameraNode() const { return _camera; }
void setCamera(osg::Camera* camera) { if (_camera!=camera) { _camera = camera; _cameraRequiresSetUp = true; } }
osg::Camera* getCamera() { return _camera; }
const osg::Camera* getCamera() const { return _camera; }
void setCameraRequiresSetUp(bool flag) { _cameraRequiresSetUp = flag; }
bool getCameraRequiresSetUp() const { return _cameraRequiresSetUp; }
@@ -210,7 +210,7 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
GLenum _imageReadPixelDataType;
};
void attach(osg::CameraNode::BufferComponent buffer, osg::Image* image);
void attach(osg::Camera::BufferComponent buffer, osg::Image* image);
protected:
@@ -236,7 +236,7 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
int _clearStencil;
bool _cameraRequiresSetUp;
osg::CameraNode* _camera;
osg::Camera* _camera;
osg::ref_ptr<osg::Texture> _texture;
unsigned int _level;
@@ -246,7 +246,7 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
GLenum _imageReadPixelFormat;
GLenum _imageReadPixelDataType;
std::map< osg::CameraNode::BufferComponent, Attachment> _bufferAttachmentMap;
std::map< osg::Camera::BufferComponent, Attachment> _bufferAttachmentMap;
osg::ref_ptr<osg::FrameBufferObject> _fbo;
osg::ref_ptr<osg::GraphicsContext> _graphicsContext;

View File

@@ -21,7 +21,7 @@
#include <osg/DisplaySettings>
#include <osg/CollectOccludersVisitor>
#include <osg/CullSettings>
#include <osg/CameraNode>
#include <osg/Camera>
#include <osgUtil/CullVisitor>
@@ -56,13 +56,13 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced, public osg::CullSetting
void setDefaults(unsigned int options = STANDARD_SETTINGS);
/** Set the camera used to represent the camera view of this SceneView.*/
void setCamera(osg::CameraNode* camera);
void setCamera(osg::Camera* camera);
/** Get the camera used to represent the camera view of this SceneView.*/
osg::CameraNode* getCamera() { return _camera.get(); }
osg::Camera* getCamera() { return _camera.get(); }
/** Get the const camera used to represent the camera view of this SceneView.*/
const osg::CameraNode* getCamera() const { return _camera.get(); }
const osg::Camera* getCamera() const { return _camera.get(); }
/** Set the data to view. The data will typically be
* an osg::Scene but can be any osg::Node type.
@@ -500,7 +500,7 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced, public osg::CullSetting
osg::ref_ptr<osg::FrameStamp> _frameStamp;
osg::ref_ptr<osg::CameraNode> _camera;
osg::ref_ptr<osg::Camera> _camera;
osg::ref_ptr<osg::StateSet> _globalStateSet;
osg::ref_ptr<osg::Light> _light;

View 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

View 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
View 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

View File

@@ -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
View 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
View 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