[osg-users] ease motion with viewer camera

Stephane Dumon dumon.stephane at gmail.com
Fri Apr 15 06:52:01 PDT 2011


ok, just a few words to tell you what i am trying to do.

 have a 3D scene, to this point nothing special. On this 3D scene I draw (like we can do in Paint) a rectangle. I add a camera which has as child node this Geode.
My greatest wishes, for now, is to make an ease motion from my viewer camera(V) to this geode camera(C).
I had already take a look to the osgeasemotion example and try to do the same but the movement is not the one i expect.

For the moment, before the movement, i creat one quaterion to precise the rotation my viewer camera should do to get the geode camera's one. I get the eye, center and up axes of each camera, and make the quat like this:

osg::Vec3 from = eyeV - centerC;
osg::Vec3 to = eyeC - centerC;
rot.makeRotate_original(from, to);

Then i attach a nodeCallBack to my viewer camera which suppose to do the job, like this:


void operator()(osg::Node* node, osg::NodeVisitor* nv)
		if(!_motion.valid()) return;
		if(isDone) return;
			osg::Camera* cam = dynamic_cast<osg::Camera*>(node);
				std::cout << "!cam" << std::endl;
			double t = nv->getFrameStamp()->getSimulationTime();
			if(_previous == 0.0f) 
				_previous = t;
			_motion->update(t - _previous);
			_previous = t;
			float pas = _motion->getValue();
			if(_motion->getTime() == 2.0)
				std::cout << "fini" << std::endl;
				_previous = 0.0;
				isDone = true;

I am about to reach the good position but my camera don't look the good center.

Is there anyone who could help me? 

Thank you!


Read this topic online here:

More information about the osg-users mailing list