Hello David,

Ok. Looks like I was wrong. The CompositeDragger does exist in the older code, 
there is just not a separate cpp file for it. However, this still does not 
address my problem. I tried building my own composite dragger that combines the 
TranslateAxisDragger and the TrackballDragger, but the trackballdragger always 
has precedence and will never let the translation work. I can find no good 
documentation on how to do something like this. Is there some documentation or 
examples that I have missed that someone could point me to?

We do exactly the same thing in our own projects and it works fine, so you must be missing something.

Here is the code we use for our dragger. Note that it uses the subclassez OurTrackballDragger and OurTranslateAxisDragger which customize the behavior of the draggers themselves, but you can use the draggers directly from osgManipulator if they fit your purposes. For example, the customizations we did were that the normal TrackballDragger has a sphere in the middle, but then you can't pick the axes of the TranslateAxisDragger in the middle of the trackball. So we removed that. Also the TrackballDragger's cylinders are one polygon thick so we gave them thickness so you could pick them from the side. The normal TranslateAxisDragger's axes were too small for us, so we made them bigger so they're easier to pick.

Also note that we use an osg::AutoTransform so the dragger is always the same size on the screen. If you don't need that just remove it.

class TrackballAxisDragger : public osgManipulator::CompositeDragger
{
public:
    TrackballAxisDragger()
    {
        _autoTransform = new osg::AutoTransform;
        _autoTransform->setAutoScaleToScreen(true);
        addChild(_autoTransform.get());

        _sizeTransform = new osg::MatrixTransform;
        // Screen coordinates because of AutoTransform parent
        _sizeTransform->setMatrix(
            osg::Matrix::scale(100, 100, 100));
        _autoTransform->addChild(_sizeTransform.get());

        _tbDragger = new OurTrackballDragger;
        _tbDragger->setName("TrackballDragger");
        _sizeTransform->addChild(_tbDragger.get());

        _transDragger = new OurTranslateAxisDragger;
        _transDragger->setName("TranslateAxisDragger");
        _sizeTransform->addChild(_transDragger.get());

        this->addDragger(_tbDragger.get());
        this->addDragger(_transDragger.get());
        this->getOrCreateStateSet()->setMode(
            GL_RESCALE_NORMAL, osg::StateAttribute::ON);
        this->setParentDragger(getParentDragger());
    }

    void setupDefaultGeometry()
    {
        _tbDragger->setupDefaultGeometry();

        // Scale the translate dragger up a bit, otherwise the axes
        // will be in the trackball dragger's sphere and we won't be
        // able to pick them.
        float axesScale = 1.5;
        _transDragger->setMatrix(
            osg::Matrix::scale(axesScale,axesScale,axesScale));
        _transDragger->setupDefaultGeometry();
    }

    // ... Other methods omitted for brevity

I don't think we do anything else to make the CompositeDragger work... So if you're missing anything in the setup that we do above, that must be it.

If it still doesn't work for you, please post the code (preferably a short self-contained but complete example, perhaps using the osgmanipulator example from OSG as a starting point) and I can have a look.

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay    [email protected]
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to