WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-21-2009, 09:16 AM
whj whj is offline
Member
 
Join Date: Apr 2008
Posts: 60
constant speed on animation path

Hello, By pressing 'a', my script simply starts a car in a road. My question is how to make the car move in a constant speed. I use path.constantspeed(), but seems to me that the car will accelerate when it move along the circle. Does the way I add control point have problem?

Code:
import viz
import math
import time

viz.go()


myroad = viz.add('road4.wrl')
myroad.setPosition(0,0.1,0)
myroad.setScale(3.2,3.2,3.2)

mymini = viz.add('mini.osgx')
mymini.setPosition(-10,-10,0)

y_pos_car = 0.14
path = viz.addAnimationPath()
positions = [ [2,y_pos_car,50], [1,y_pos_car,35], [0,y_pos_car,25], [-1,y_pos_car,15], 
				[-1,y_pos_car,8], [-25,y_pos_car,0], [-15,y_pos_car,-8], [-10,y_pos_car,-10], 
				[-6,y_pos_car,-10], [-3,y_pos_car,-12], [0,y_pos_car,-18], [3,y_pos_car,-17], 
				[6,y_pos_car,0], [10,y_pos_car,4], [15,y_pos_car,2], [25,y_pos_car,-8], 
				[35,y_pos_car,-16], [50,y_pos_car,-10], [60,y_pos_car,20], [80,y_pos_car,40],
				[200,y_pos_car,200] ]
for x in range(0,len(positions)):
	cp = viz.add(viz.CONTROL_POINT)
	cp.setPosition(positions[x])
	path.add(cp,x+1)

path.loop(viz.OFF)
path.translatemode(viz.BEZIER)
path.setAutoRotate(viz.ON)
mymini.link(path)

	
def mytimer(num):
	pass

def onkeydown(key):
	if key == 'a': 
		path.play()
		path.constantspeed(viz.ON,6.7)
		


viz.callback(viz.KEYBOARD_EVENT, onkeydown) #keyboard event callback
viz.callback(viz.TIMER_EVENT, mytimer) #timer event callback
viz.starttimer(0,1/60,viz.FOREVER) #timer

BTW, I cannot attach my models zip file here because it always said "Upload of file failed". What should I try?

Thanks a lot!

Last edited by whj; 04-21-2009 at 09:23 AM.
Reply With Quote
  #2  
Old 04-21-2009, 11:17 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,457
Constant speed will not work with the translate mode you are using. You could try using the linear mode or creating your animation in modeling software like 3ds Max.
Reply With Quote
  #3  
Old 04-21-2009, 01:29 PM
whj whj is offline
Member
 
Join Date: Apr 2008
Posts: 60
Thanks anyway.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with interaction of vizact.turn and animation path Enlil Vizard 3 11-24-2008 04:23 PM
speed on animation path whj Vizard 8 11-17-2008 07:41 PM
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


All times are GMT -7. The time now is 07:12 AM.


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