#include <osg/Matrix>
#include <osg/ref_ptr>
#include <osg/Referenced>
+#include <osg/Node>
// For osgUtil::LineSegmentIntersector::Intersections, which is a typedef.
#include <osgUtil/LineSegmentIntersector>
*/
struct CameraInfo : public osg::Referenced
{
- CameraInfo(unsigned flags_, osg::Camera* camera_)
- : flags(flags_), camera(camera_), slaveIndex(-1)
+ CameraInfo(unsigned flags_, osg::Camera* camera_ = 0)
+ : flags(flags_), camera(camera_), slaveIndex(-1), farSlaveIndex(-1),
+ x(0.0), y(0.0), width(0.0), height(0.0)
{
}
/** Properties of the camera. @see CameraGroup::Flags.
/** the camera object
*/
osg::ref_ptr<osg::Camera> camera;
+ /** camera for rendering far field, if needed
+ */
+ osg::ref_ptr<osg::Camera> farCamera;
/** Index of this camera in the osgViewer::Viewer slave list.
*/
int slaveIndex;
+ /** index of far camera in slave list
+ */
+ int farSlaveIndex;
+ /** Viewport parameters.
+ */
+ double x;
+ double y;
+ double width;
+ double height;
};
+/** Update the OSG cameras from the camera info.
+ */
+void updateCameras(const CameraInfo* info);
+
class CameraGroup : public osg::Referenced
{
public:
* @param cameraNode the property node.
* @return a CameraInfo object for the camera.
*/
- CameraInfo* buildCamera(const SGPropertyNode* cameraNode);
+ CameraInfo* buildCamera(SGPropertyNode* cameraNode);
/** Create a camera from properties that will draw the GUI and add
* it to the camera group.
* @param cameraNode the property node. This can be 0, in which
* this is 0, the window is determined from the property node.
* @return a CameraInfo object for the GUI camera.
*/
- CameraInfo* buildGUICamera(const SGPropertyNode* cameraNode,
+ CameraInfo* buildGUICamera(SGPropertyNode* cameraNode,
GraphicsWindow* window = 0);
/** Update the view for the camera group.
* @param position the world position of the view
* @param the camera group property node.
*/
static CameraGroup* buildCameraGroup(osgViewer::Viewer* viewer,
- const SGPropertyNode* node);
+ SGPropertyNode* node);
+ /** Set the cull mask on all non-GUI cameras
+ */
+ void setCameraCullMasks(osg::Node::NodeMask nm);
+ /** Update camera properties after a resize event.
+ */
+ void resized();
protected:
CameraList _cameras;
osg::ref_ptr<osgViewer::Viewer> _viewer;
static osg::ref_ptr<CameraGroup> _defaultGroup;
+ // Near, far for the master camera if used.
+ float _zNear;
+ float _zFar;
+ float _nearField;
};
}