WorldViz User Forum speed on animation path
 User Name Remember Me? Password
 Register FAQ Search Today's Posts Mark Forums Read

 Thread Tools Rating: Display Modes
#1
11-02-2008, 01:48 PM
 whj Member Join Date: Apr 2008 Posts: 60
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
11-03-2008, 07:38 PM
 Jeff WorldViz Team Member Join Date: Aug 2008 Posts: 2,471
thanks for the post, we'll get back to you as soon as we can on this
#3
11-04-2008, 12:12 PM
 Jeff WorldViz Team Member Join Date: Aug 2008 Posts: 2,471
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
11-05-2008, 09:19 PM
 whj Member Join Date: Apr 2008 Posts: 60
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
11-07-2008, 07:02 PM
 Jeff WorldViz Team Member Join Date: Aug 2008 Posts: 2,471
Are you using

Code:
```path.translatemode(viz.CUBIC_BEZIER)
path.computetangents()```
I think this should work with constantspeed. Can you post an example with how you are using it.
#6
11-09-2008, 07:52 PM
 whj Member Join Date: Apr 2008 Posts: 60
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
11-10-2008, 09:36 AM
 whj Member Join Date: Apr 2008 Posts: 60
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
11-12-2008, 10:44 AM
 Jeff WorldViz Team Member Join Date: Aug 2008 Posts: 2,471
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
11-17-2008, 07:41 PM
 whj Member Join Date: Apr 2008 Posts: 60
OK. Thanks for your help.

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Getting Vizard Help with AI Announcements Vizard Precision Position Tracker (PPT) Plug-in development

 Similar Threads Thread Thread Starter Forum Replies Last Post whj Vizard 10 10-06-2008 04:38 PM djdesmangles Vizard 2 06-11-2007 03:37 PM djdesmangles Vizard 0 06-06-2007 11:03 AM k_iwan Vizard 2 03-26-2007 05:52 PM Elizabeth S Vizard 1 11-08-2006 02:11 PM

All times are GMT -7. The time now is 02:16 PM.

 Contact Us - WorldViz Home - Archive - Top

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