#include #include #include #include #include #include using namespace osg; using namespace osgGA; CameraManipulator::CameraManipulator() { _intersectTraversalMask = 0xffffffff; _autoComputeHomePosition = true; _homeEye.set(0.0,-1.0,0.0); _homeCenter.set(0.0,0.0,0.0); _homeUp.set(0.0,0.0,1.0); } CameraManipulator::CameraManipulator(const CameraManipulator& mm, const CopyOp& copyOp) : inherited(mm, copyOp), _intersectTraversalMask(mm._intersectTraversalMask), _autoComputeHomePosition(mm._autoComputeHomePosition), _homeEye(mm._homeEye), _homeCenter(mm._homeCenter), _homeUp(mm._homeUp), _coordinateFrameCallback(dynamic_cast(copyOp(mm._coordinateFrameCallback.get()))) { } CameraManipulator::~CameraManipulator() { } std::string CameraManipulator::getManipulatorName() const { const char* className = this->className(); const char* manipString = strstr(className, "Manipulator"); if (!manipString) return std::string(className); else return std::string(className, manipString-className); } bool CameraManipulator::handle(const GUIEventAdapter&,GUIActionAdapter&) { return false; } /** Compute the home position. * * The computation considers camera's fov (field of view) and model size and * positions camera far enough to fit the model to the screen. * * camera parameter enables computations of camera's fov. If camera is NULL, * scene to camera distance can not be computed and default value is used, * based on model size only. * * useBoundingBox parameter enables to use bounding box instead of bounding sphere * for scene bounds. Bounding box provide more precise scene center that may be * important for many applications.*/ void CameraManipulator::computeHomePosition(const osg::Camera *camera, bool useBoundingBox) { if (getNode()) { osg::BoundingSphere boundingSphere; OSG_INFO<<" CameraManipulator::computeHomePosition("<accept(cbVisitor); osg::BoundingBox &bb = cbVisitor.getBoundingBox(); if (bb.valid()) boundingSphere.expandBy(bb); else boundingSphere = getNode()->getBound(); } else { // compute bounding sphere boundingSphere = getNode()->getBound(); } OSG_INFO<<" boundingSphere.center() = ("<