whj
11-02-2008, 01:48 PM
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)
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)