Hi,

I am using oceanExample, and modified the boat transform to use a 
PositionAttitudeTransform instead of the MatrixTransform just because I wanted 
to learn a bit more and eventually go underwater with my model and fly around 
with perspective...

I was successful at orienting my boat and getting it placed at the right level 
and heading, and then desired to make it move. I used the callback to update 
the "y" direction in the transform, and my boat casually drifts away into the 
sunset.

Code:

        if(boat.valid())
        {
            boat->setNodeMask( scene->getOceanScene()->getNormalSceneMask() | 
                scene->getOceanScene()->getReflectedSceneMask() | 
                scene->getOceanScene()->getRefractedSceneMask() );

            osg::ref_ptr<osg::PositionAttitudeTransform> boatTransform = new 
osg::PositionAttitudeTransform;
            //Name that NODE!
            boatTransform->setName("BOAT");
            boatTransform->addChild(boat.get());

            const osg::BoundingSphere& bs = boat->getBound();
            boatTransform->setPivotPoint(bs.center());

            osg::Vec3 boatPosit(0,100,1.5); 
            boatTransform->setPosition( boatPosit );
            boatTransform->setAttitude(osg::Quat( osg::DegreesToRadians(90.0) , 
osg::Vec3(0,0,1) ));

            boatTransform->setUpdateCallback( new 
BoatPositionCallback(scene->getOceanScene()) );

            scene->getOceanScene()->addChild(boatTransform.get());   
        }





Hey... I'm no good at flying after it with my clutzy mouse skills, so I 
wondered if I could get the camera to do the work for me.

Wanting to follow my boat into the sunset on it's perilous journey, I attempted 
to "implement" a "FOLLOW_ME" camera mode in the SceneEventHandler. I did what 
basics I could glean from whatever sources I could, and had limited success... 
At least I could see water. My boat was traveling perhaps with the camera, but 
I couldn't find it no matter what position and distance I placed it. I need 
some clues here... 


Code:

else if (_currentCameraMode == TRACKBALL)
{
        osgGA::NodeTrackerManipulator* nt = new osgGA::NodeTrackerManipulator();
        //Find that NODE!                                       
        osg::Node* trackedNode = 
_scene->findNamedNode("BOAT",_scene->getScene());      
        if(!trackedNode)
                return false;
        nt->setNode(trackedNode);
        nt->setTrackNode(trackedNode);
        nt->setTrackerMode(osgGA::NodeTrackerManipulator::NODE_CENTER_AND_AZIM);
        nt->setAutoComputeHomePosition(true);
        nt->setMinimumDistance(100);
        nt->setDistance(100);
        nt->setElevation(100);
        _currentCameraMode = FOLLOW_ME;
        //_viewer.getCamera()->setViewMatrixAsLookAt( osg::Vec3f(0.f,0.f,20.f), 
        //          osg::Vec3f(0.f,0.f,20.f)+osg::Vec3f(0.f,1.f,0.f), 
osg::Vec3f(0,0,1) );                      
        _viewer.setCameraManipulator(nt);
        _textHUD->setCameraText("FOLLOW_ME");
}




Please note the commented out setViewMatrixAsLookAt... did not know wether it 
should be used or not?

I was wondering if perhaps (again) that the nodeTrackerManipulator is 
incompatible with a node which uses a PositionAttitudeTransform?
The reason I ask is that my mouse controls the position of whatever (the boat 
and camera presumably) in a very radical means. The slightest touch of the 
mouse causes wild swings of height, perspective or distance. Once I can find 
the surface of the water.... zooooooom! What might be going on here?

Thank you!

Cheers,
tim
Code:




------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=37665#37665





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to