View Single Post
  #4  
Old 10-27-2009, 01:21 PM
whj whj is offline
Member
 
Join Date: Apr 2008
Posts: 60
Hi,

If I happen to create another non-circle path using bezier paths, would the distance we can see/feel in VR is close to the actual distance that calculated by vizmat.Distance().

Thanks!



Quote:
Originally Posted by farshizzo View Post
You won't be able to create a perfect circle using bezier paths. You are better off manually animating the object. Either way, the following modified version of your script will generate a path that is closer to a circle. It uses cubic bezier and you removes the duplicate control point at the end of the path:
Code:
import viz
import vizmat
import vizact
viz.go()

viz.add('tut_ground.wrl')
ball = viz.add('ball.wrl')

viz.MainView.move([0,3,-20])

path = viz.addAnimationPath()
positions = [ [0,1,10], [10,1,0], [0,1,-10], [-10,1,0] ]
for x,pos in enumerate(positions):
	cp = viz.addControlPoint()
	cp.setPosition(pos)
	path.add(cp,x+1)

path.loop(viz.CIRCULAR)
path.translatemode(viz.CUBIC_BEZIER)
path.computetangents()
path.setAutoRotate(viz.ON)

mylink = viz.link(path,ball)
path.play()

def PrintInfo():
	pc = ball.getPosition()
	print 'position: ', pc

	dist = vizmat.Distance(pc,[0,1,0])
	print 'distance: ', dist

vizact.ontimer(0,PrintInfo)
Reply With Quote