Hi John,

Could you post separate questions in separate emails, this helps
others track topics later when looking at archives.

W.r.t 1) try attaching the callback to the PositionAttitudeTransform.

W.r.t 2) The old 1.2 osgProducer::Viewer you can switch off the
default event handlers vis setOptions.  None of the event handles in
1.2 are customizable w.r.t keys though, so you are stuck with 'w' if
you want to use the osgGA::StateSetManipulator.

In the new 2.0 osgViewer::Viewer there isn't any default event
handlers - you add these all yourself one by one, if you don't one
then just don't add it.  In 2.0 a number of the event handlers have
the ability to cutomize which key to use.  Unfortunately the osgGA
manipulators have yet been updated in this way, which includes
StateSetManipulator so your're still stuck with 'w'.  Later rev's will
make this customizable.

You have the source code so you're welcome to add this ability to
override the key bindings in the osgGA manipualtors and submit the
changes.

Robert.



On 7/2/07, John Ring <[EMAIL PROTECTED]> wrote:
Hey all,
  I've got two questions that I'd appreciate help with.

1)  Why doesn't this work?  basically the problem is that pat in
updateCallback is never not null.  I got this code basically from
http://www.nps.navy.mil/cs/sullivan/osgtutorials/osgKeyboard.htm,
though I add PositionAttitudeTransform in the main code (it doesn't work
either way)

// Main body code
    planeStateType *planeData = new planeStateType();
    airplaneNode->setUserData(planeData );
    airplaneTransform->setUpdateCallback(new
updatePlanePosCallback(planeData));
    airplaneTransform->addChild(airplaneNode);
    osg::PositionAttitudeTransform* pat = new
osg::PositionAttitudeTransform();
    pat->addChild(airplaneTransform);
    root->addChild(pat);
// ...

// updateCallback code
class updatePlanePosCallback : public osg::NodeCallback {
public:

updatePlanePosCallback::updatePlanePosCallback(planeStateType*
planeIState) : planePos(0.,0.,0.)
    {
        planeState = planeIState;
        planePos = osg::Vec3(0,0,0);
    }
    virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
    {
        osg::PositionAttitudeTransform* pat =
dynamic_cast<osg::PositionAttitudeTransform*> (node);
        if(pat)
        {
            if(planePos == osg::Vec3(0,0,0))
            {
                planePos = pat->getPosition();
            }
            planePos += planeState->getSpeed();
            pat->setPosition(planePos);
        }
        traverse(node, nv);
   }


2) How do you override the default actions of the viewer upon certain key
presses?  I'm trying to override with a WASD configuration, but 'w' still
changes the wireframe.  How do I stop this?

Thanks,
John

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to