#1
|
|||
|
|||
speed on animation path
Hello Jeff,
Previously you helped me out with the problem that how to get the position of an object two seconds ahead. Thanks a lot. Here is the code with slight change on your code, in which a semi-transparent ball two seconds ahead of another ball on animation path. I have a question about their speed. Why the speed of balls changes a lot along the animation path although I used path.constantspeed(viz.ON,4). How can I get a smooth constant speed? Thanks. import viz viz.go() viz.add('tut_ground.wrl') ball = viz.add('ball.wrl') ball.alpha(.5) ball2 = viz.add('ball.wrl') viz.MainView.move(0,3,-30) path = viz.add(viz.ANIMATION_PATH) path2 = viz.add(viz.ANIMATION_PATH) positions = [ [2,0.15,50], [1,0.15,35], [0,0.15,25], [-4,0.15,15], [-10,0.15,8], [-25,0.15,0], [-15,0.15,-8], [-10,0.15,-10], [-6,0.15,-12], [-3,0.15,-15], [0,0.15,-18], [3,0.15,-16], [6,0.15,-8], [10,0.15,2], [15,0.15,0], [25,0.15,-12], [35,0.15,-12], [50,0.15,-12], [70,0.15,10], [90,0.15,30], [140,0.15,120] ] for x in range(0,len(positions)): cp = viz.add(viz.CONTROL_POINT) cp.setPosition(positions[x]) path.add(cp,x+1) path2.add(cp,x+1) path.constantspeed(viz.ON,4) path2.constantspeed(viz.ON,4) path.loop(viz.OFF) path2.loop(viz.OFF) path.translatemode(viz.BEZIER) path2.translatemode(viz.BEZIER) path.setAutoRotate(viz.ON) path2.setAutoRotate(viz.ON) #Link ball and ball2 to their paths ball.link(path) ball2.link(path2) #start playing the first animation path immediately path.play() #start playing the second animation path after two seconds vizact.ontimer2(2, 1, path2.play) |
#2
|
|||
|
|||
thanks for the post, we'll get back to you as soon as we can on this
|
#3
|
|||
|
|||
the constantspeed method does not work with the bezier translation mode. If you use it with one of the other modes it should be fine.
|
#4
|
|||
|
|||
Seems that computeTangents() mode doesn't work too. Then how can I smoothly move a object in a specified curve with constent speed?
Thanks, |
#5
|
|||
|
|||
Are you using
Code:
path.translatemode(viz.CUBIC_BEZIER) path.computetangents() |
#6
|
|||
|
|||
Thanks Jeff. I didn't put path.translatemode(viz.CUBIC_BEZIER) in my code. Yes, cubic_bezier mode has constant speed.
BTW, it's not bad for me to specify all positions of a animation path using bezier translation mode, but it is really hard to find positions in cubic_bezier translation mode. Having a cubic-bezier curve, do you have any easy way to get its intermediate points? Thanks, whj |
#7
|
|||
|
|||
Hi Jeff,
Please see the following code. The car speed up when it turns. Seems still not constant speed for some curves. How can I improve it? About cubic_bezier curve, do I specify only 4 points for a curve? If the curve is complex, could I include more points? import viz viz.go() viz.add('tut_ground.wrl') ball = viz.add('ball.wrl') ball.alpha(.5) car = viz.add('mini.osgx') viz.MainView.move(0,3,-60) path = viz.add(viz.ANIMATION_PATH) path2 = viz.add(viz.ANIMATION_PATH) positions = [ [7,0.15,-50], [5,0.15,10], [20,0.15,-10], [140,0.15,120] ] for x in range(0,len(positions)): cp = viz.add(viz.CONTROL_POINT) cp.setPosition(positions[x]) path.add(cp,x+1) path2.add(cp,x+1) path.constantspeed(viz.ON,4) path2.constantspeed(viz.ON,4) path.loop(viz.OFF) path2.loop(viz.OFF) path.translatemode(viz.CUBIC_BEZIER) path.computetangents() path2.translatemode(viz.CUBIC_BEZIER) path2.computetangents() path.setAutoRotate(viz.ON) path2.setAutoRotate(viz.ON) #Link ball and ball2 to their paths ball.link(path) car.link(path2) #start playing the first animation path immediately path.play() #start playing the second animation path after two seconds vizact.ontimer2(2, 1, path2.play) |
#8
|
|||
|
|||
Yes, your right. I guess the constantspeed does not work with Cubic Bezier either. Would defining more points on the curve and using the linear mode work for your situation
|
#9
|
|||
|
|||
OK. Thanks for your help.
|
Thread Tools | |
Display Modes | Rate This Thread |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
real time collision on animation path | whj | Vizard | 10 | 10-06-2008 04:38 PM |
Animation Path | djdesmangles | Vizard | 2 | 06-11-2007 03:37 PM |
Animation Path | djdesmangles | Vizard | 0 | 06-06-2007 11:03 AM |
Animation Tracks.... | k_iwan | Vizard | 2 | 03-26-2007 05:52 PM |
Jumpy animation | Elizabeth S | Vizard | 1 | 11-08-2006 02:11 PM |