Re: [osg-users] how restart AnimationPathHandler at start position

2009-10-26 Thread Felix Ilbring
Hi Again,

somehow it is still not working. The setStartTick method has no effect at all. 
i tried to set the startTick in _view, _timer and both, nothing worked.

As i want to start the animation from the beginning, each time i press the play 
button, i do the folowing:


Code:

bool RecordCameraPathHandler::handle(const osgGA::GUIEventAdapter &ea, 
osgGA::GUIActionAdapter &aa)
{
_view = dynamic_cast(&aa);


// The user has requested to BEGIN playback.
if (!_currentlyPlaying)
{
_view->setStartTick(_timer->tick());
_timer->setStartTick(_timer->tick());
std::ifstream in(_filename.c_str());
_animPath.~ref_ptr();
_animPathManipulator.~ref_ptr();
_animPath = new osg::AnimationPath();
_animPath->read(in);
_animPathManipulator = new 
osgGA::AnimationPathManipulator(_animPath.get());
_animPathManipulator->home(ea,aa);

// If we successfully found our _filename file, set it and keep 
a copy
// around of the original MatrixManipulator to restore later.
if (_animPathManipulator.valid() && 
_animPathManipulator->valid())
{
_oldManipulator = _view->getCameraManipulator();
_view->setCameraManipulator(_animPathManipulator.get());
_currentlyPlaying = true;
}
}

// The user has requested to STOP playback.
else
{
// Restore the old manipulator if necessary and stop playback.
_view->setCameraManipulator(_oldManipulator);
_currentlyPlaying = false;
_oldManipulator = 0;
}
}




I guess, i am doing something wrong. Please give me some support.

thanks
Felix[/code]

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





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


Re: [osg-users] how restart AnimationPathHandler at start position

2009-10-26 Thread Felix Ilbring
Thanks Rafa,

that sounds like it would solve the problem. 
real big thanks for the fast reply

Felix

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





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


Re: [osg-users] how restart AnimationPathHandler at start position

2009-10-25 Thread Rafa Gaitan
Hi Felix,

I did something similar, maybe this "pause" method could help you.

 _pause = !_pause;
 if(_pause)
_startTick = _timer.tick();
 else {
_timer.setStartTick(_timer.getStartTick()+(_timer.tick()-_startTick));
 }

I save the tick when is paused and when I unpause I set the new
startTick of the timer (or the view in your case) to the prevous
startTick plus the time I have been paused, so all continues at the
same time.

Hope this helps,

Rafa.



On Sun, Oct 25, 2009 at 8:07 PM, Felix Ilbring  wrote:
> Hi,
>
> I have a simple question: How do i confince the handler to start the 
> animation always from first second? Each time i fire the start event, i want 
> to start the animation from time 0.
> If i stop the animation by 'Z', and press 'Z' again 5 sec later. it seems the 
> path has moved on although if i fired the stop event.
>
> Is it possible to restart the Timer or something?
> i tried:
> _view->setStartTick(osg::Timer::instance()->tick());
>
> but has no effect.
>
> thanks for your help
> Cheers,
> Felix
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=18675#18675
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
Rafael Gaitán Linares
Instituto de Automática e Informática Industrial  http://www.ai2.upv.es
Ciudad Politécnica de la Innovación
Universidad Politécnica de Valencia
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org