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

@@ -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);