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

View File

@@ -181,7 +181,7 @@ int main( int argc, char **argv )
osgUtil::UpdateVisitor updateVisitor;
updateVisitor.setFrameStamp(frameStamp.get());
typedef std::list< osg::ref_ptr<osg::CameraNode> > CameraList;
typedef std::list< osg::ref_ptr<osg::Camera> > CameraList;
typedef std::set< osg::GraphicsContext* > GraphicsContextSet;
CameraList cameraList;
@@ -192,7 +192,7 @@ int main( int argc, char **argv )
osg::GraphicsContext* previousContext = 0;
for(unsigned int i=0; i< numberCameras; ++i)
{
osg::ref_ptr<osg::CameraNode> camera = new osg::CameraNode;
osg::ref_ptr<osg::Camera> camera = new osg::Camera;
camera->addChild(loadedModel.get());
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
@@ -284,7 +284,7 @@ int main( int argc, char **argv )
citr != cameraList.end();
++citr)
{
osg::CameraNode* camera = citr->get();
osg::Camera* camera = citr->get();
osg::GraphicsThread* graphicsThread = camera->getGraphicsContext()->getGraphicsThread();
// create a scene view to do the cull and draw

View File

@@ -28,7 +28,7 @@ void CURRENT_CLASS::init()
_active = true;
_numCameras = 0;
setCullingActive(false);
_renderOrder = osg::CameraNode::POST_RENDER;
_renderOrder = osg::Camera::POST_RENDER;
_clearColorBuffer = true;
}
@@ -42,7 +42,7 @@ void CURRENT_CLASS::setClearColorBuffer(bool clear)
{
_clearColorBuffer = clear;
// Update the render order for the first CameraNode if it exists
// Update the render order for the first Camera if it exists
if(!_cameraList.empty())
{
if(clear)
@@ -52,11 +52,11 @@ void CURRENT_CLASS::setClearColorBuffer(bool clear)
}
}
void CURRENT_CLASS::setRenderOrder(osg::CameraNode::RenderOrder order)
void CURRENT_CLASS::setRenderOrder(osg::Camera::RenderOrder order)
{
_renderOrder = order;
// Update the render order for existing CameraNodes
// Update the render order for existing Cameras
unsigned int numCameras = _cameraList.size();
for(unsigned int i = 0; i < numCameras; i++)
{
@@ -104,18 +104,18 @@ void CURRENT_CLASS::traverse(osg::NodeVisitor &nv)
_children[i]->accept(*(_distAccumulator.get()));
}
// Step 2: Compute the near and far distances for every CameraNode that
// Step 2: Compute the near and far distances for every Camera that
// should be used to render the scene.
_distAccumulator->computeCameraPairs();
// Step 3: Create the CameraNodes, and add them as children.
// Step 3: Create the Cameras, and add them as children.
DistanceAccumulator::PairList& camPairs = _distAccumulator->getCameraPairs();
_numCameras = camPairs.size(); // Get the number of cameras
// Create the CameraNodes, and add them as children.
// Create the Cameras, and add them as children.
if(_numCameras > 0)
{
osg::CameraNode *currCam;
osg::Camera *currCam;
DistanceAccumulator::DistancePair currPair;
for(i = 0; i < _numCameras; i++)
@@ -147,7 +147,7 @@ bool CURRENT_CLASS::insertChild(unsigned int index, osg::Node *child)
{
if(!Group::insertChild(index, child)) return false; // Insert child
// Insert child into each CameraNode
// Insert child into each Camera
unsigned int totalCameras = _cameraList.size();
for(unsigned int i = 0; i < totalCameras; i++)
{
@@ -161,7 +161,7 @@ bool CURRENT_CLASS::removeChildren(unsigned int pos, unsigned int numRemove)
{
if(!Group::removeChildren(pos, numRemove)) return false; // Remove child
// Remove child from each CameraNode
// Remove child from each Camera
unsigned int totalCameras = _cameraList.size();
for(unsigned int i = 0; i < totalCameras; i++)
{
@@ -174,7 +174,7 @@ bool CURRENT_CLASS::setChild(unsigned int i, osg::Node *node)
{
if(!Group::setChild(i, node)) return false; // Set child
// Set child for each CameraNode
// Set child for each Camera
unsigned int totalCameras = _cameraList.size();
for(unsigned int j = 0; j < totalCameras; j++)
{
@@ -183,16 +183,16 @@ bool CURRENT_CLASS::setChild(unsigned int i, osg::Node *node)
return true;
}
osg::CameraNode* CURRENT_CLASS::createOrReuseCamera(const osg::Matrix& proj,
osg::Camera* CURRENT_CLASS::createOrReuseCamera(const osg::Matrix& proj,
double znear, double zfar,
const unsigned int &camNum)
{
if(_cameraList.size() <= camNum) _cameraList.resize(camNum+1);
osg::CameraNode *camera = _cameraList[camNum].get();
osg::Camera *camera = _cameraList[camNum].get();
if(!camera) // Create a new CameraNode
if(!camera) // Create a new Camera
{
camera = new osg::CameraNode;
camera = new osg::Camera;
camera->setCullingActive(false);
camera->setRenderOrder(_renderOrder);
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
@@ -206,7 +206,7 @@ osg::CameraNode* CURRENT_CLASS::createOrReuseCamera(const osg::Matrix& proj,
else
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
// Add our children to the new CameraNode's children
// Add our children to the new Camera's children
unsigned int numChildren = _children.size();
for(unsigned int i = 0; i < numChildren; i++)
{

View File

@@ -2,7 +2,7 @@
#define _OF_DEPTHPARTITIONNODE_
#include "DistanceAccumulator.h"
#include <osg/CameraNode>
#include <osg/Camera>
#define CURRENT_CLASS DepthPartitionNode
/**********************************************************
@@ -28,13 +28,13 @@ class CURRENT_CLASS : public osg::Group
inline bool getActive() const { return _active; }
/** Specify whether the color buffer should be cleared before the first
CameraNode draws it's scene. */
Camera draws it's scene. */
void setClearColorBuffer(bool clear);
inline bool getClearColorBuffer() const { return _clearColorBuffer; }
/** Specify the render order for each CameraNode */
void setRenderOrder(osg::CameraNode::RenderOrder order);
inline osg::CameraNode::RenderOrder getRenderOrder() const
/** Specify the render order for each Camera */
void setRenderOrder(osg::Camera::RenderOrder order);
inline osg::Camera::RenderOrder getRenderOrder() const
{ return _renderOrder; }
/** Set/get the maximum depth that the scene will be traversed to.
@@ -48,7 +48,7 @@ class CURRENT_CLASS : public osg::Group
/** Override update and cull traversals */
virtual void traverse(osg::NodeVisitor &nv);
/** Catch child management functions so the CameraNodes can be informed
/** Catch child management functions so the Cameras can be informed
of added or removed children. */
virtual bool addChild(osg::Node *child);
virtual bool insertChild(unsigned int index, osg::Node *child);
@@ -56,14 +56,14 @@ class CURRENT_CLASS : public osg::Group
virtual bool setChild(unsigned int i, osg::Node *node);
protected:
typedef std::vector< osg::ref_ptr<osg::CameraNode> > CameraList;
typedef std::vector< osg::ref_ptr<osg::Camera> > CameraList;
~CURRENT_CLASS();
void init();
// Creates a new CameraNode object with default settings
osg::CameraNode* createOrReuseCamera(const osg::Matrix& proj,
// Creates a new Camera object with default settings
osg::Camera* createOrReuseCamera(const osg::Matrix& proj,
double znear, double zfar,
const unsigned int &camNum);
@@ -72,13 +72,13 @@ class CURRENT_CLASS : public osg::Group
// The NodeVisitor that computes cameras for the scene
osg::ref_ptr<DistanceAccumulator> _distAccumulator;
osg::CameraNode::RenderOrder _renderOrder;
osg::Camera::RenderOrder _renderOrder;
bool _clearColorBuffer;
// Cameras that should be used to draw the scene. These cameras
// will be reused on every frame in order to save time and memory.
CameraList _cameraList;
unsigned int _numCameras; // Number of CameraNodes actually being used
unsigned int _numCameras; // Number of Cameras actually being used
};
#undef CURRENT_CLASS

View File

@@ -73,7 +73,7 @@ void CURRENT_CLASS::pushDistancePair(double zNear, double zFar)
}
/** Return true if the node should be traversed, and false if the bounding sphere
of the node is small enough to be rendered by one CameraNode. If the latter
of the node is small enough to be rendered by one Camera. If the latter
is true, then store the node's near & far plane distances. */
bool CURRENT_CLASS::shouldContinueTraversal(osg::Node &node)
{

View File

@@ -17,7 +17,7 @@
#include <osg/TexEnvCombine>
#include <osg/TexEnv>
#include <osg/CameraNode>
#include <osg/Camera>
#include <osg/TexGenNode>
#include <osgDB/ReadFile>
@@ -193,9 +193,9 @@ class UpdateCameraAndTexGenCallback : public osg::NodeCallback
{
public:
UpdateCameraAndTexGenCallback(osg::MatrixTransform* light_transform, osg::CameraNode* cameraNode, osg::TexGenNode* texgenNode):
UpdateCameraAndTexGenCallback(osg::MatrixTransform* light_transform, osg::Camera* Camera, osg::TexGenNode* texgenNode):
_light_transform(light_transform),
_cameraNode(cameraNode),
_Camera(Camera),
_texgenNode(texgenNode)
{
}
@@ -207,14 +207,14 @@ class UpdateCameraAndTexGenCallback : public osg::NodeCallback
// now compute the camera's view and projection matrix to point at the shadower (the camera's children)
osg::BoundingSphere bs;
for(unsigned int i=0; i<_cameraNode->getNumChildren(); ++i)
for(unsigned int i=0; i<_Camera->getNumChildren(); ++i)
{
bs.expandBy(_cameraNode->getChild(i)->getBound());
bs.expandBy(_Camera->getChild(i)->getBound());
}
if (!bs.valid())
{
osg::notify(osg::WARN) << "bb invalid"<<_cameraNode.get()<<std::endl;
osg::notify(osg::WARN) << "bb invalid"<<_Camera.get()<<std::endl;
return;
}
@@ -234,14 +234,14 @@ class UpdateCameraAndTexGenCallback : public osg::NodeCallback
float top = (bs.radius()/centerDistance)*znear;
float right = top;
_cameraNode->setReferenceFrame(osg::CameraNode::ABSOLUTE_RF);
_cameraNode->setProjectionMatrixAsFrustum(-right,right,-top,top,znear,zfar);
_cameraNode->setViewMatrixAsLookAt(position,bs.center(),osg::Vec3(0.0f,1.0f,0.0f));
_Camera->setReferenceFrame(osg::Camera::ABSOLUTE_RF);
_Camera->setProjectionMatrixAsFrustum(-right,right,-top,top,znear,zfar);
_Camera->setViewMatrixAsLookAt(position,bs.center(),osg::Vec3(0.0f,1.0f,0.0f));
// compute the matrix which takes a vertex from local coords into tex coords
// will use this later to specify osg::TexGen..
osg::Matrix MVPT = _cameraNode->getViewMatrix() *
_cameraNode->getProjectionMatrix() *
osg::Matrix MVPT = _Camera->getViewMatrix() *
_Camera->getProjectionMatrix() *
osg::Matrix::translate(1.0,1.0,1.0) *
osg::Matrix::scale(0.5f,0.5f,0.5f);
@@ -255,7 +255,7 @@ class UpdateCameraAndTexGenCallback : public osg::NodeCallback
virtual ~UpdateCameraAndTexGenCallback() {}
osg::ref_ptr<osg::MatrixTransform> _light_transform;
osg::ref_ptr<osg::CameraNode> _cameraNode;
osg::ref_ptr<osg::Camera> _Camera;
osg::ref_ptr<osg::TexGenNode> _texgenNode;
};
@@ -307,11 +307,11 @@ osg::Group* createShadowedScene(osg::Node* shadowed,osg::MatrixTransform* light_
{
// create the camera
osg::CameraNode* camera = new osg::CameraNode;
osg::Camera* camera = new osg::Camera;
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
camera->setClearColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
camera->setComputeNearFarMode(osg::CameraNode::DO_NOT_COMPUTE_NEAR_FAR);
camera->setComputeNearFarMode(osg::Camera::DO_NOT_COMPUTE_NEAR_FAR);
// set viewport
camera->setViewport(0,0,tex_width,tex_height);
@@ -337,13 +337,13 @@ osg::Group* createShadowedScene(osg::Node* shadowed,osg::MatrixTransform* light_
// set the camera to render before the main camera.
camera->setRenderOrder(osg::CameraNode::PRE_RENDER);
camera->setRenderOrder(osg::Camera::PRE_RENDER);
// tell the camera to use OpenGL frame buffer object where supported.
camera->setRenderTargetImplementation(osg::CameraNode::FRAME_BUFFER_OBJECT);
camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
// attach the texture and use it as the color buffer.
camera->attach(osg::CameraNode::DEPTH_BUFFER, texture);
camera->attach(osg::Camera::DEPTH_BUFFER, texture);
// add subgraph to render
camera->addChild(shadowed);

View File

@@ -39,7 +39,7 @@ osg::Node* createDistortionSubgraph(osg::Node* subgraph, const osg::Vec4& clearC
// set up the render to texture camera.
{
osg::CameraNode* camera = new osg::CameraNode;
osg::Camera* camera = new osg::Camera;
// set clear the color and depth buffer
camera->setClearColor(clearColour);
@@ -54,13 +54,13 @@ osg::Node* createDistortionSubgraph(osg::Node* subgraph, const osg::Vec4& clearC
camera->setViewport(0,0,tex_width,tex_height);
// set the camera to render before the main camera.
camera->setRenderOrder(osg::CameraNode::PRE_RENDER);
camera->setRenderOrder(osg::Camera::PRE_RENDER);
// tell the camera to use OpenGL frame buffer object where supported.
camera->setRenderTargetImplementation(osg::CameraNode::FRAME_BUFFER_OBJECT);
camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
// attach the texture and use it as the color buffer.
camera->attach(osg::CameraNode::COLOR_BUFFER, texture);
camera->attach(osg::Camera::COLOR_BUFFER, texture);
// add subgraph to render
camera->addChild(subgraph);
@@ -145,7 +145,7 @@ osg::Node* createDistortionSubgraph(osg::Node* subgraph, const osg::Vec4& clearC
geode->addDrawable(polyGeom);
// set up the camera to render the textured quad
osg::CameraNode* camera = new osg::CameraNode;
osg::Camera* camera = new osg::Camera;
// just inherit the main cameras view
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
@@ -153,13 +153,13 @@ osg::Node* createDistortionSubgraph(osg::Node* subgraph, const osg::Vec4& clearC
camera->setProjectionMatrixAsOrtho2D(0,1280,0,1024);
// set the camera to render before the main camera.
camera->setRenderOrder(osg::CameraNode::NESTED_RENDER);
camera->setRenderOrder(osg::Camera::NESTED_RENDER);
// tell the camera to use OpenGL frame buffer object where supported.
camera->setRenderTargetImplementation(osg::CameraNode::FRAME_BUFFER_OBJECT);
camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
// attach the texture and use it as the color buffer.
camera->attach(osg::CameraNode::COLOR_BUFFER, texture);
camera->attach(osg::Camera::COLOR_BUFFER, texture);
// add subgraph to render
camera->addChild(geode);

View File

@@ -21,7 +21,7 @@
#include <osg/Depth>
#include <osg/PolygonOffset>
#include <osg/MatrixTransform>
#include <osg/CameraNode>
#include <osg/Camera>
#include <osgText/Text>
@@ -69,7 +69,7 @@ osg::Node* createHUD()
text->setFont(timesFont);
text->setPosition(position);
text->setText("Then place an osg::CameraNode above the subgraph\n"
text->setText("Then place an osg::Camera above the subgraph\n"
"to create an orthographic projection.\n");
position += delta;
@@ -81,7 +81,7 @@ osg::Node* createHUD()
text->setFont(timesFont);
text->setPosition(position);
text->setText("Set the CameraNode's ReferenceFrame to ABSOLUTE_RF to ensure\n"
text->setText("Set the Camera's ReferenceFrame to ABSOLUTE_RF to ensure\n"
"it remains independent from any external model view matrices.");
position += delta;
@@ -93,7 +93,7 @@ osg::Node* createHUD()
text->setFont(timesFont);
text->setPosition(position);
text->setText("And set the CameraNode's clear mask to just clear the depth buffer.");
text->setText("And set the Camera's clear mask to just clear the depth buffer.");
position += delta;
}
@@ -104,7 +104,7 @@ osg::Node* createHUD()
text->setFont(timesFont);
text->setPosition(position);
text->setText("And finally set the CameraNode's RenderOrder to POST_RENDER\n"
text->setText("And finally set the Camera's RenderOrder to POST_RENDER\n"
"to make sure its drawn last.");
position += delta;
@@ -148,7 +148,7 @@ osg::Node* createHUD()
geode->addDrawable(geom);
}
osg::CameraNode* camera = new osg::CameraNode;
osg::Camera* camera = new osg::Camera;
// set the projection matrix
camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
@@ -161,7 +161,7 @@ osg::Node* createHUD()
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
// draw subgraph after main camera view.
camera->setRenderOrder(osg::CameraNode::POST_RENDER);
camera->setRenderOrder(osg::Camera::POST_RENDER);
camera->addChild(geode);

View File

@@ -22,7 +22,7 @@
#include <osg/Projection>
#include <osg/PolygonOffset>
#include <osg/MatrixTransform>
#include <osg/CameraNode>
#include <osg/Camera>
#include <osg/FrontFace>
#include <osgText/Text>
@@ -30,7 +30,7 @@
osg::Node* createRearView(osg::Node* subgraph, const osg::Vec4& clearColour)
{
osg::CameraNode* camera = new osg::CameraNode;
osg::Camera* camera = new osg::Camera;
// set the viewport
camera->setViewport(10,10,400,200);
@@ -38,7 +38,7 @@ osg::Node* createRearView(osg::Node* subgraph, const osg::Vec4& clearColour)
// set the view matrix
camera->setCullingActive(false);
camera->setReferenceFrame(osg::Transform::RELATIVE_RF);
camera->setTransformOrder(osg::CameraNode::POST_MULTIPLY);
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));
@@ -48,7 +48,7 @@ osg::Node* createRearView(osg::Node* subgraph, const osg::Vec4& clearColour)
camera->setClearMask(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
// draw subgraph after main camera view.
camera->setRenderOrder(osg::CameraNode::POST_RENDER);
camera->setRenderOrder(osg::Camera::POST_RENDER);
// add the subgraph to draw.
camera->addChild(subgraph);

View File

@@ -25,7 +25,7 @@
#include <osg/Depth>
#include <osg/Projection>
#include <osg/MatrixTransform>
#include <osg/CameraNode>
#include <osg/Camera>
#include <osg/io_utils>
#include <osgText/Text>
@@ -116,11 +116,11 @@ osg::Node* createHUD(osgText::Text* updateText)
// eg to be used as a menuing/help system!
// Can pick texts too!
osg::CameraNode* hudCamera = new osg::CameraNode;
osg::Camera* hudCamera = new osg::Camera;
hudCamera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
hudCamera->setProjectionMatrixAsOrtho2D(0,1280,0,1024);
hudCamera->setViewMatrix(osg::Matrix::identity());
hudCamera->setRenderOrder(osg::CameraNode::POST_RENDER);
hudCamera->setRenderOrder(osg::Camera::POST_RENDER);
hudCamera->setClearMask(GL_DEPTH_BUFFER_BIT);
std::string timesFont("fonts/times.ttf");

View File

@@ -107,14 +107,14 @@ class MyGeometryCallback :
};
struct MyCameraPostDrawCallback : public osg::CameraNode::DrawCallback
struct MyCameraPostDrawCallback : public osg::Camera::DrawCallback
{
MyCameraPostDrawCallback(osg::Image* image):
_image(image)
{
}
virtual void operator () (const osg::CameraNode& /*camera*/) const
virtual void operator () (const osg::Camera& /*camera*/) const
{
if (_image && _image->getPixelFormat()==GL_RGBA && _image->getDataType()==GL_UNSIGNED_BYTE)
{
@@ -177,7 +177,7 @@ struct MyCameraPostDrawCallback : public osg::CameraNode::DrawCallback
};
osg::Node* createPreRenderSubGraph(osg::Node* subgraph, unsigned tex_width, unsigned tex_height, osg::CameraNode::RenderTargetImplementation renderImplementation, bool useImage, bool useTextureRectangle, bool useHDR)
osg::Node* createPreRenderSubGraph(osg::Node* subgraph, unsigned tex_width, unsigned tex_height, osg::Camera::RenderTargetImplementation renderImplementation, bool useImage, bool useTextureRectangle, bool useHDR)
{
if (!subgraph) return 0;
@@ -288,7 +288,7 @@ osg::Node* createPreRenderSubGraph(osg::Node* subgraph, unsigned tex_width, unsi
// then create the camera node to do the render to texture
{
osg::CameraNode* camera = new osg::CameraNode;
osg::Camera* camera = new osg::Camera;
// set up the background color and clear mask.
camera->setClearColor(osg::Vec4(0.1f,0.1f,0.3f,1.0f));
@@ -321,7 +321,7 @@ osg::Node* createPreRenderSubGraph(osg::Node* subgraph, unsigned tex_width, unsi
camera->setViewport(0,0,tex_width,tex_height);
// set the camera to render before the main camera.
camera->setRenderOrder(osg::CameraNode::PRE_RENDER);
camera->setRenderOrder(osg::Camera::PRE_RENDER);
// tell the camera to use OpenGL frame buffer object where supported.
camera->setRenderTargetImplementation(renderImplementation);
@@ -334,7 +334,7 @@ osg::Node* createPreRenderSubGraph(osg::Node* subgraph, unsigned tex_width, unsi
image->allocateImage(tex_width, tex_height, 1, GL_RGBA, GL_FLOAT);
// attach the image so its copied on each frame.
camera->attach(osg::CameraNode::COLOR_BUFFER, image);
camera->attach(osg::Camera::COLOR_BUFFER, image);
camera->setPostDrawCallback(new MyCameraPostDrawCallback(image));
@@ -351,7 +351,7 @@ osg::Node* createPreRenderSubGraph(osg::Node* subgraph, unsigned tex_width, unsi
else
{
// attach the texture and use it as the color buffer.
camera->attach(osg::CameraNode::COLOR_BUFFER, texture);
camera->attach(osg::Camera::COLOR_BUFFER, texture);
}
@@ -404,13 +404,13 @@ int main( int argc, char **argv )
while (arguments.read("--width", tex_width)) {}
while (arguments.read("--height", tex_height)) {}
osg::CameraNode::RenderTargetImplementation renderImplementation = osg::CameraNode::FRAME_BUFFER_OBJECT;
osg::Camera::RenderTargetImplementation renderImplementation = osg::Camera::FRAME_BUFFER_OBJECT;
while (arguments.read("--fbo")) { renderImplementation = osg::CameraNode::FRAME_BUFFER_OBJECT; }
while (arguments.read("--pbuffer")) { renderImplementation = osg::CameraNode::PIXEL_BUFFER; }
while (arguments.read("--pbuffer-rtt")) { renderImplementation = osg::CameraNode::PIXEL_BUFFER_RTT; }
while (arguments.read("--fb")) { renderImplementation = osg::CameraNode::FRAME_BUFFER; }
while (arguments.read("--window")) { renderImplementation = osg::CameraNode::SEPERATE_WINDOW; }
while (arguments.read("--fbo")) { renderImplementation = osg::Camera::FRAME_BUFFER_OBJECT; }
while (arguments.read("--pbuffer")) { renderImplementation = osg::Camera::PIXEL_BUFFER; }
while (arguments.read("--pbuffer-rtt")) { renderImplementation = osg::Camera::PIXEL_BUFFER_RTT; }
while (arguments.read("--fb")) { renderImplementation = osg::Camera::FRAME_BUFFER; }
while (arguments.read("--window")) { renderImplementation = osg::Camera::SEPERATE_WINDOW; }
bool useImage = false;
while (arguments.read("--image")) { useImage = true; }

View File

@@ -18,7 +18,7 @@
#include <osg/Material>
#include <osg/PositionAttitudeTransform>
#include <osg/CameraNode>
#include <osg/Camera>
#include <osg/TexGenNode>
using namespace osg;
@@ -111,11 +111,11 @@ class UpdateCameraAndTexGenCallback : public osg::NodeCallback
{
public:
typedef std::vector< osg::ref_ptr<osg::CameraNode> > CameraList;
typedef std::vector< osg::ref_ptr<osg::Camera> > CameraList;
UpdateCameraAndTexGenCallback(osg::NodePath& reflectorNodePath, CameraList& cameraNodes):
UpdateCameraAndTexGenCallback(osg::NodePath& reflectorNodePath, CameraList& Cameras):
_reflectorNodePath(reflectorNodePath),
_cameraNodes(cameraNodes)
_Cameras(Cameras)
{
}
@@ -141,7 +141,7 @@ class UpdateCameraAndTexGenCallback : public osg::NodeCallback
};
for(unsigned int i=0;
i<6 && i<_cameraNodes.size();
i<6 && i<_Cameras.size();
++i)
{
osg::Matrix localOffset;
@@ -149,9 +149,9 @@ class UpdateCameraAndTexGenCallback : public osg::NodeCallback
osg::Matrix viewMatrix = worldToLocal*localOffset;
_cameraNodes[i]->setReferenceFrame(osg::CameraNode::ABSOLUTE_RF);
_cameraNodes[i]->setProjectionMatrixAsFrustum(-1.0,1.0,-1.0,1.0,1.0,10000.0);
_cameraNodes[i]->setViewMatrix(viewMatrix);
_Cameras[i]->setReferenceFrame(osg::Camera::ABSOLUTE_RF);
_Cameras[i]->setProjectionMatrixAsFrustum(-1.0,1.0,-1.0,1.0,1.0,10000.0);
_Cameras[i]->setViewMatrix(viewMatrix);
}
}
@@ -160,7 +160,7 @@ class UpdateCameraAndTexGenCallback : public osg::NodeCallback
virtual ~UpdateCameraAndTexGenCallback() {}
osg::NodePath _reflectorNodePath;
CameraList _cameraNodes;
CameraList _Cameras;
};
class TexMatCullCallback : public osg::NodeCallback
@@ -191,7 +191,7 @@ class TexMatCullCallback : public osg::NodeCallback
};
osg::Group* createShadowedScene(osg::Node* reflectedSubgraph, osg::NodePath reflectorNodePath, unsigned int unit, const osg::Vec4& clearColor, unsigned tex_width, unsigned tex_height, osg::CameraNode::RenderTargetImplementation renderImplementation)
osg::Group* createShadowedScene(osg::Node* reflectedSubgraph, osg::NodePath reflectorNodePath, unsigned int unit, const osg::Vec4& clearColor, unsigned tex_width, unsigned tex_height, osg::Camera::RenderTargetImplementation renderImplementation)
{
osg::Group* group = new osg::Group;
@@ -207,11 +207,11 @@ osg::Group* createShadowedScene(osg::Node* reflectedSubgraph, osg::NodePath refl
texture->setFilter(osg::TextureCubeMap::MAG_FILTER,osg::TextureCubeMap::LINEAR);
// set up the render to texture cameras.
UpdateCameraAndTexGenCallback::CameraList cameraNodes;
UpdateCameraAndTexGenCallback::CameraList Cameras;
for(unsigned int i=0; i<6; ++i)
{
// create the camera
osg::CameraNode* camera = new osg::CameraNode;
osg::Camera* camera = new osg::Camera;
camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
camera->setClearColor(clearColor);
@@ -220,20 +220,20 @@ osg::Group* createShadowedScene(osg::Node* reflectedSubgraph, osg::NodePath refl
camera->setViewport(0,0,tex_width,tex_height);
// set the camera to render before the main camera.
camera->setRenderOrder(osg::CameraNode::PRE_RENDER);
camera->setRenderOrder(osg::Camera::PRE_RENDER);
// tell the camera to use OpenGL frame buffer object where supported.
camera->setRenderTargetImplementation(renderImplementation);
// attach the texture and use it as the color buffer.
camera->attach(osg::CameraNode::COLOR_BUFFER, texture, 0, i);
camera->attach(osg::Camera::COLOR_BUFFER, texture, 0, i);
// add subgraph to render
camera->addChild(reflectedSubgraph);
group->addChild(camera);
cameraNodes.push_back(camera);
Cameras.push_back(camera);
}
// create the texgen node to project the tex coords onto the subgraph
@@ -264,7 +264,7 @@ osg::Group* createShadowedScene(osg::Node* reflectedSubgraph, osg::NodePath refl
group->addChild(reflectedSubgraph);
// set an update callback to keep moving the camera and tex gen in the right direction.
group->setUpdateCallback(new UpdateCameraAndTexGenCallback(reflectorNodePath, cameraNodes));
group->setUpdateCallback(new UpdateCameraAndTexGenCallback(reflectorNodePath, Cameras));
return group;
}
@@ -307,12 +307,12 @@ int main(int argc, char** argv)
while (arguments.read("--width", tex_width)) {}
while (arguments.read("--height", tex_height)) {}
osg::CameraNode::RenderTargetImplementation renderImplementation = osg::CameraNode::FRAME_BUFFER_OBJECT;
osg::Camera::RenderTargetImplementation renderImplementation = osg::Camera::FRAME_BUFFER_OBJECT;
while (arguments.read("--fbo")) { renderImplementation = osg::CameraNode::FRAME_BUFFER_OBJECT; }
while (arguments.read("--pbuffer")) { renderImplementation = osg::CameraNode::PIXEL_BUFFER; }
while (arguments.read("--fb")) { renderImplementation = osg::CameraNode::FRAME_BUFFER; }
while (arguments.read("--window")) { renderImplementation = osg::CameraNode::SEPERATE_WINDOW; }
while (arguments.read("--fbo")) { renderImplementation = osg::Camera::FRAME_BUFFER_OBJECT; }
while (arguments.read("--pbuffer")) { renderImplementation = osg::Camera::PIXEL_BUFFER; }
while (arguments.read("--fb")) { renderImplementation = osg::Camera::FRAME_BUFFER; }
while (arguments.read("--window")) { renderImplementation = osg::Camera::SEPERATE_WINDOW; }
// any option left unread are converted into errors to write out later.

View File

@@ -4,7 +4,7 @@
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/ShapeDrawable>
#include <osg/CameraNode>
#include <osg/Camera>
#include <osg/TexGenNode>
#include <osg/Notify>
#include <osg/io_utils>
@@ -17,9 +17,9 @@ class UpdateCameraAndTexGenCallback : public osg::NodeCallback
{
public:
UpdateCameraAndTexGenCallback(const osg::Vec3& position, osg::CameraNode* cameraNode, osg::TexGenNode* texgenNode):
UpdateCameraAndTexGenCallback(const osg::Vec3& position, osg::Camera* Camera, osg::TexGenNode* texgenNode):
_position(position),
_cameraNode(cameraNode),
_Camera(Camera),
_texgenNode(texgenNode)
{
}
@@ -31,14 +31,14 @@ class UpdateCameraAndTexGenCallback : public osg::NodeCallback
// now compute the camera's view and projection matrix to point at the shadower (the camera's children)
osg::BoundingSphere bs;
for(unsigned int i=0; i<_cameraNode->getNumChildren(); ++i)
for(unsigned int i=0; i<_Camera->getNumChildren(); ++i)
{
bs.expandBy(_cameraNode->getChild(i)->getBound());
bs.expandBy(_Camera->getChild(i)->getBound());
}
if (!bs.valid())
{
osg::notify(osg::WARN) << "bb invalid"<<_cameraNode.get()<<std::endl;
osg::notify(osg::WARN) << "bb invalid"<<_Camera.get()<<std::endl;
return;
}
@@ -52,14 +52,14 @@ class UpdateCameraAndTexGenCallback : public osg::NodeCallback
float top = (bs.radius()/centerDistance)*znear;
float right = top;
_cameraNode->setReferenceFrame(osg::CameraNode::ABSOLUTE_RF);
_cameraNode->setProjectionMatrixAsFrustum(-right,right,-top,top,znear,zfar);
_cameraNode->setViewMatrixAsLookAt(_position,bs.center(),osg::Vec3(0.0f,1.0f,0.0f));
_Camera->setReferenceFrame(osg::Camera::ABSOLUTE_RF);
_Camera->setProjectionMatrixAsFrustum(-right,right,-top,top,znear,zfar);
_Camera->setViewMatrixAsLookAt(_position,bs.center(),osg::Vec3(0.0f,1.0f,0.0f));
// compute the matrix which takes a vertex from local coords into tex coords
// will use this later to specify osg::TexGen..
osg::Matrix MVPT = _cameraNode->getViewMatrix() *
_cameraNode->getProjectionMatrix() *
osg::Matrix MVPT = _Camera->getViewMatrix() *
_Camera->getProjectionMatrix() *
osg::Matrix::translate(1.0,1.0,1.0) *
osg::Matrix::scale(0.5f,0.5f,0.5f);
@@ -73,7 +73,7 @@ class UpdateCameraAndTexGenCallback : public osg::NodeCallback
virtual ~UpdateCameraAndTexGenCallback() {}
osg::Vec3 _position;
osg::ref_ptr<osg::CameraNode> _cameraNode;
osg::ref_ptr<osg::Camera> _Camera;
osg::ref_ptr<osg::TexGenNode> _texgenNode;
};
@@ -120,7 +120,7 @@ osg::Group* createShadowedScene(osg::Node* shadower,osg::Node* shadowed,const os
{
// create the camera
osg::CameraNode* camera = new osg::CameraNode;
osg::Camera* camera = new osg::Camera;
camera->setClearColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
@@ -128,13 +128,13 @@ osg::Group* createShadowedScene(osg::Node* shadower,osg::Node* shadowed,const os
camera->setViewport(0,0,tex_width,tex_height);
// set the camera to render before the main camera.
camera->setRenderOrder(osg::CameraNode::PRE_RENDER);
camera->setRenderOrder(osg::Camera::PRE_RENDER);
// tell the camera to use OpenGL frame buffer object where supported.
camera->setRenderTargetImplementation(osg::CameraNode::FRAME_BUFFER_OBJECT);
camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
// attach the texture and use it as the color buffer.
camera->attach(osg::CameraNode::COLOR_BUFFER, texture);
camera->attach(osg::Camera::COLOR_BUFFER, texture);
// add subgraph to render
camera->addChild(shadower);
@@ -179,7 +179,7 @@ osg::Group* createShadowedScene(osg::Node* shadower,osg::Node* shadowed,const os
geom->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
geode->addDrawable(geom);
osg::CameraNode* camera = new osg::CameraNode;
osg::Camera* camera = new osg::Camera;
// set the projection matrix
camera->setProjectionMatrix(osg::Matrix::ortho2D(0,100,0,100));
@@ -194,7 +194,7 @@ osg::Group* createShadowedScene(osg::Node* shadower,osg::Node* shadowed,const os
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
// draw subgraph after main camera view.
camera->setRenderOrder(osg::CameraNode::POST_RENDER);
camera->setRenderOrder(osg::Camera::POST_RENDER);
camera->addChild(geode);

View File

@@ -20,7 +20,7 @@
#include <osgProducer/Viewer>
#include <osg/Geode>
#include <osg/CameraNode>
#include <osg/Camera>
#include <osg/ShapeDrawable>
#include <osg/Sequence>
@@ -540,7 +540,7 @@ int main( int argc, char **argv )
{
// create the hud.
osg::CameraNode* camera = new osg::CameraNode;
osg::Camera* camera = new osg::Camera;
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setProjectionMatrixAsOrtho2D(0,1280,0,1024);
camera->setViewMatrix(osg::Matrix::identity());