WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   animation question (https://forum.worldviz.com/showthread.php?t=1624)

whj 08-28-2008 02:34 PM

animation question
 
hi,

I'm trying to create an animation of a moving car. Animation path seems to be a handy way. But I also want to change the speed of the car or even stop the car when some event occurs. I don't see any control of speed is available to the animation path. Does anyone have an idea how to do it?

Thanks a lot.
whj

Jeff 08-28-2008 04:31 PM

With animation paths you can change the speed of the animation or you can pause an animation. To reduce the speed by half

path = viz.add(viz.ANIMATION_PATH)
path.speed(.5)

to pause the animation

path.pause()

whj 08-29-2008 03:01 PM

Thank you.

whj 09-05-2008 10:16 AM

Hi, I have another question on animation path.

When I use path.autorotate(), all my cars move along their current trajectory, which is great. But some of them move forward, and some of them move backward. I don't know how to control the rotation of the objects when I use animation path. The following is my code:

mybus = viz.add('schoolbus.3ds')
path = viz.add(viz.ANIMATION_PATH)

positions = [ [-40,1.25,-4], [-30,1.25,-3], [-20,1.25,-2], [-10,1.25,-6], [0,1.25,-30], [10,1.25,-10], [20,1.25,7], [30,1.25,-10], [50,1.25,2] ]
for x in range(0,len(positions)):
cp = viz.add(viz.CONTROL_POINT)
cp.setPosition(positions[x])
path.add(cp,x+1)
path.constantspeed(viz.ON,CAR_SPEED)

path.loop(viz.LOOP)
path.translatemode(viz.BEZIER)
path.setAutoRotate(viz.ON)
mybus.link(path)
path.play()


Thanks,

Jeff 09-08-2008 09:21 AM

Since there is a link between the animation path and the car you can offset the car's position or orientation from the path's. If I understand correctly you want to offset the orientation so that the car is facing the opposite direction. Here is some code that takes 2 wheelbarrows and animates them along a path. The second wheelbarrow will get rotated so it faces the opposite direction. Then its position is offset slighty from the path so it appears below the first one. Let me know if that helps.

Code:

import viz
viz.go()

wheel1 = viz.add('wheelbarrow.ive')
wheel2 = viz.add('wheelbarrow.ive')

path = viz.add(viz.ANIMATION_PATH)

positions = [[0,0,10],[5,0,10],[5,0,15],[0,0,15]]

for x in range(0,len(positions)):
        cp = viz.add(viz.CONTROL_POINT)
        cp.setPosition(positions[x])
        path.add(cp,x+1)
       
path.constantspeed(viz.ON,1)

path.loop(viz.LOOP)

path.translatemode(viz.BEZIER)

path.setAutoRotate(viz.ON)

#link the first wheelbarrow to the path
wheel1.link(path)

#link the second wheelbarrow to the path then
#offset the wheelbarrow's orientation so it is opposite the path
#and offset its position from the path so it will be
#below the first wheelbarrow

wheel2link = viz.link(path, wheel2)
wheel2link.preEuler([180,0,0])
wheel2link.preTrans([0,-1,0])

path.play()


whj 09-08-2008 12:13 PM

Thank you, Jeff. That works very well.


All times are GMT -7. The time now is 03:25 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC