motion path time

hi,

i am using the code below to move my camera based on a motion path.

self.motionPath = Mopath.Mopath()
self.motionPath.loadFile("models/curve.egg")
self.camera_dummy_node = render.attachNewNode("camera_dummy_node")
self.myInterval = MopathInterval(self.motionPath,self.camera_dummy_node,name='MyInterval', blendType='easeOut')
self.move = MetaInterval( self.myInterval)

Basically now I want to find out a specific time in the motion path and do something. I don´t want to use camera positions to do this. (e.g when the camera pass from this x y z point of the motion path do something)
I prefer to use something analogous to the seconds of a video.

Is there something that can be useful to me. I looked the documentation but is empty.
panda3d.org/apiref.php?page=Mopath
what the calcTime function is doing and how can be used?

thank you

This is what the Interval system excels at. Say you want to do something at time 2.5 of the Mopath:

ival1 = MopathInterval(self.motionPath,self.camera_dummy_node,name='MyInterval', blendType='easeOut') 
ival2 = Sequence(Wait(2.5), Func(doSomething))
self.myInterval = Parallel(ival1, ival2)

David

thank you drwr for the answer.

Your suggestion works fine but it does not suit to my needs since the motion path speed is not fixed so in time e.g 2.5 the camera will be in different position according to the speed.

Maybe I was not to specific in my previous post.
The position of the camera is defined by the motion path only. I want to do something when the camera passes from a specific point(I don´t want to compare positions). Is there any other way?
Basically I want to find a stage of the motion path

thanks

But you’re using a MopathInterval, right? You might be using a MetaInterval to adjust the speed of that MopathInterval, but the time within the interval is always the same. So even if time 2.5 within the interval happens to happen at time 5.2 in real time, it still happens at time 2.5 within the interval, and the solution above still works.

Anyway, you can get the current time of the Mopath as mopath.playbackTime.

David

…but I am using the

ival2 = Sequence(Wait(2.5), Func(doSomething))
self.myInterval = Parallel(ival1, ival2) 

so the wait(2.5) does not have to do anything with the MopathInterval. It´s just a parallel procedure. I don´t know if I am not thinking correct.

About the mopath.playbackTime, I cannot find the playbackTime nowhere(forum or API). When I tried to use it I got the warning that “Mopath instance has no attribute ‘playbackTime’”.

Is it a function that returns an integer or something?
I am using Panda 1.5.4

thanks for the help

Hmm, I guess playbackTime isn’t set until it is first used. The Mopath wasn’t really designed to be queried in that way. (You can look at the source code in Mopath.py, in the direct source tree–that might be instructive.)

It’s not just a parallel procedure; it’s a new Interval. You’ve constructed a new interval–self.myInterval–that does everything the MopathInterval used to do, but also calls doSomething when your Mopath has reached point 2.5 on its path.

You can then wrap self.myInterval inside your MetaInterval, instead of just the MopathInterval. That way, doSomething will be called at whatever time 2.5 maps to inside your MetaInterval.

David