Show
Ignore:
Timestamp:
01/31/12 11:56:52 (2 years ago)
Author:
robert
Message:

Improved the handling of osgManipulator::Constraint, DraggerCallbacks? and Command so that they now use a Visitor Pattern

to ensure the correct methods on constraints and callbaks are called for each Command. Also fixed the handling of

Constraints when applied to composite Draggers.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgmanipulator/osgmanipulator.cpp

    r12929 r12930  
    3939#include <osg/Geometry> 
    4040#include <osg/Material> 
     41#include <osg/io_utils> 
    4142 
    4243#include <iostream> 
     44 
     45class PlaneConstraint : public osgManipulator::Constraint 
     46{ 
     47public: 
     48        PlaneConstraint() {} 
     49     
     50        virtual bool constrain(osgManipulator::TranslateInLineCommand& command) const 
     51        { 
     52            OSG_NOTICE<<"TranslateInLineCommand "<<command.getTranslation()<<std::endl; 
     53            return true;             
     54        } 
     55        virtual bool constrain(osgManipulator::TranslateInPlaneCommand& command) const 
     56        { 
     57            //command.setTranslation(osg::Vec3(0.0f,0.0f,0.0f)); 
     58            OSG_NOTICE<<"TranslateInPlaneCommand "<<command.getTranslation()<<std::endl; 
     59            return true; 
     60        } 
     61        virtual bool constrain(osgManipulator::Scale1DCommand& command) const 
     62        { 
     63            //command.setScale(1.0f); 
     64            OSG_NOTICE<<"Scale1DCommand"<<command.getScale()<<std::endl; 
     65            return true;             
     66        } 
     67        virtual bool constrain(osgManipulator::Scale2DCommand& command) const 
     68        { 
     69            //command.setScale(osg::Vec2d(1.0,1.0)); 
     70            OSG_NOTICE<<"Scale2DCommand "<<command.getScale()<<std::endl; 
     71            return true; 
     72        } 
     73        virtual bool constrain(osgManipulator::ScaleUniformCommand& command) const 
     74        { 
     75            OSG_NOTICE<<"ScaleUniformCommand"<<command.getScale()<<std::endl; 
     76            return true;             
     77        } 
     78}; 
    4379 
    4480osgManipulator::Dragger* createDragger(const std::string& name) 
     
    4985        osgManipulator::TabPlaneDragger* d = new osgManipulator::TabPlaneDragger(); 
    5086        d->setupDefaultGeometry(); 
     87        d->addConstraint(new PlaneConstraint()); 
    5188        dragger = d; 
    5289    }