WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-28-2008, 10:29 AM
Jerry Jerry is offline
Member
 
Join Date: Jun 2004
Posts: 105
This works for me. Ignore the last control point to keep it
from returning to the origin.

Code:
from viz import *
import viztask

ground = add('tut_ground.wrl')

positions = [[0,0,0],[0,0,0.15],[0,0,0.3],[0,0,0.45],[0,0,0.6],[0,0,0.75],[0,0,0.9],[0,0,1.05],[0,0,1.2],[0,0,1.35],[0,0,1.5],[0,0,1.65],[0,0,1.8],[0,0,1.95],[0,0,2.1],[0,0,2.25],[0,0,2.4],[0,0,2.55],[0,0,2.7],[0,0,2.85],[0,0,3],[0,0,3.15],[-0.00189704643856282,0,3.29998800356965],[-0.00569083587854888,0,3.44994001976712],[-0.0113807614942146,0,3.59983206340683],[-0.0189659131682755,0,3.74964015889596],[-0.0284450776374817,0,3.89934034406941],[-0.0398167386866824,0,4.04890867402259],[-0.0530790773913481,0,4.19832122494145],[-0.0682299724085118,0,4.34755409792921],[-0.085267000316083,0,4.49658342282896],[-0.10418743600048,0,4.64538536204184],[-0.124988253092518,0,4.79393611433984],[-0.147666124451485,0,4.94221191867294],[-0.172217422697326,0,5.09018905796967],[-0.198638220790847,0,5.23784386293077],[-0.226924292661862,0,5.38515271581514],[-0.257071113885158,0,5.53209205421752],[-0.289073862404187,0,5.67863837483741],[-0.322927419302368,0,5.82476823723843],[-0.358626369621871,0,5.9704582675977],[-0.396165003229748,0,6.11568516244454],[-0.435537315731287,0,6.26042569238789],[-0.476737009430427,0,6.40465670583194],[-0.519757494337091,0,6.54835513267926],[-0.564591889221268,0,6.69149798802094],[-0.611233022713687,0,6.83406237581306],[-0.65967343445289,0,6.97602549253898],[-0.709905376278538,0,7.1173646308568],[-0.761920813470746,0,7.25805718323149],[-0.815711426035257,0,7.39808064555097],[-0.871268610034244,0,7.53741262072574],[-0.92858347896253,0,7.67603082227133],[-0.987646865169011,0,7.81391307787307],[-1.04844932132304,0,7.95103733293262],[-1.11098112192553,0,8.08738165409566],[-1.17523226486463,0,8.22292423276015],[-1.24119247301552,0,8.3576433885647],[-1.30885119588429,0,8.4915175728564],[-1.37819761129552,0,8.62452537213754],[-1.44922062712332,0,8.7566455114908],[-1.52190888306552,0,8.88785685798218],[-1.59625075246079,0,9.0181384240413],[-1.67223434414837,0,9.14746937081838],[-1.74984750437003,0,9.2758290115175],[-1.82907781871418,0,9.40319681470545],[-1.90991261410152,0,9.52955240759587],[-1.99233896081214,0,9.6548755793078],[-2.07634367455368,0,9.7791462840986],[-2.16191331857019,0,9.9023446445702],[-2.24903420579132,0,10.0244509548486],[-2.33769240102169,0,10.1454456837358],[-2.42787372316976,0,10.2653094778341],[-2.51956374751621,0,10.3840231646412],[-2.61274780802117,0,10.5015677556176],[-2.70741099967008,0,10.6179244492233],[-2.8035381808578,0,10.7330746339253],[-2.90111397581056,0,10.8469998911746],[-3.00012277704531,0,10.9596819983526],[-3.10054874786623,0,11.0711029316850],[-3.20237582489778,0,11.1812448691258],[-3.30558772065414,0,11.2900901932072],[-3.41016792614439,0,11.3976214938578],[-3.51609971351320,0,11.5038215711876],[-3.62336613871643,0,11.6086734382388],[-3.73195004423145,0,11.7121603237031],[-3.84183406180146,0,11.8142656746044],[-3.95300061521362,0,11.9149731589462],[-4.06543192311039,0,12.0142666683243],[-4.17911000183372,0,12.1121303205031],[-4.29401666830157,0,12.2085484619561],[-4.40892333476941,0,12.3049666034091],[-4.52383000123726,0,12.4013847448621],[-4.63873666770511,0,12.4978028863150],[-4.75364333417295,0,12.5942210277680],[-4.8685500006408,0,12.690639169221],[-4.98345666710865,0,12.7870573106740],[-5.09836333357649,0,12.8834754521270],[-5.21327000004434,0,12.9798935935799],[-5.32817666651219,0,13.0763117350329],[-5.44308333298003,0,13.1727298764859]]
rotations = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.0197823401541,-0.0395646803081,-0.083929374814,-0.151951089501,-0.276953041553,-0.433410406113,-0.632110178471,-0.965097725391,-1.28618347645,-1.77674126625,-2.21355104446,-2.83690094948,-3.36144304276,-4.07549285889,-4.6547999382,-5.42104721069,-6.11628723145,-6.82009744644,-7.52973175049,-8.242811203,-8.95811080933,-9.6739397049,-10.390291214,-11.0798664093,-11.8237514496,-12.5435218811,-13.259013176,-13.9761791229,-14.6936197281,-15.4109125137,-16.1280708313,-16.8457832336,-17.5646896362,-18.2805137634,-18.9967517853,-19.6809310913,-20.4329471588,-21.1172580719,-21.8678417206,-22.5517272949,-23.3028945923,-24.0169754028,-24.7385463715,-25.4126987457,-26.1709594727,-26.8571910858,-27.6046047211,-28.2732105255,-29.0410957336,-29.7245941162,-30.4749107361,-31.2565174103,-31.9090518951,-32.6843223572,-33.3464851379,-34.093547821,-34.7822227478,-35.4534912109,-36.2104263306,-36.8674621582,-37.651763916,-38.3268432617,-39.0805778503,-39.75831604,-40.5209617615,-41.3033027649,-41.9467315674,-42.7125434875,-43.3866958618,-44.1332626343,-44.810836792,-45.5930938721,-46.2115783691,-46.7850189209,-47.5163841248,-48.0392189026,-48.6333274841,-49.0393028259,-49.4651641846,-49.6783599854,-49.8670730591,-49.9598884583,-49.9899749756,-50.0002822876,-50.0074234009,-49.9894752502,-49.998878479,-50.0030937195,-50]



def playpath():
	path = addAnimationPath()

	yield viztask.waitKeyDown(' ')
	
	for x in range (0,len(positions)-1):
			
		cp = add(CONTROL_POINT)
		cp.setPosition(positions[x])
		cp.rotate(rotations[x],0,0)

		path.add(cp,x)
			
	path.speed(8)
	path.translatemode(BEZIER)
	MainView.link(path)
	path.loop(OFF)
	path.play()


def delaystart():
	yield viztask.waitTime(2)
	playpath()
viztask.schedule(playpath())

go()
Reply With Quote
  #2  
Old 02-28-2008, 12:11 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Here is a workaround for the glitch at the beginning of the animation. This will be fixed in the next release:
Code:
from viz import *
import viztask

ground = add('tut_ground.wrl')
mainView = viz.get( viz.MAIN_VIEWPOINT )

positions = [[0,0,0],[0,0,0.15],[0,0,0.3],[0,0,0.45],[0,0,0.6],[0,0,0.75],[0,0,0.9],[0,0,1.05],[0,0,1.2],[0,0,1.35],[0,0,1.5],[0,0,1.65],[0,0,1.8],[0,0,1.95],[0,0,2.1],[0,0,2.25],[0,0,2.4],[0,0,2.55],[0,0,2.7],[0,0,2.85],[0,0,3],[0,0,3.15],[-0.00189704643856282,0,3.29998800356965],[-0.00569083587854888,0,3.44994001976712],[-0.0113807614942146,0,3.59983206340683],[-0.0189659131682755,0,3.74964015889596],[-0.0284450776374817,0,3.89934034406941],[-0.0398167386866824,0,4.04890867402259],[-0.0530790773913481,0,4.19832122494145],[-0.0682299724085118,0,4.34755409792921],[-0.085267000316083,0,4.49658342282896],[-0.10418743600048,0,4.64538536204184],[-0.124988253092518,0,4.79393611433984],[-0.147666124451485,0,4.94221191867294],[-0.172217422697326,0,5.09018905796967],[-0.198638220790847,0,5.23784386293077],[-0.226924292661862,0,5.38515271581514],[-0.257071113885158,0,5.53209205421752],[-0.289073862404187,0,5.67863837483741],[-0.322927419302368,0,5.82476823723843],[-0.358626369621871,0,5.9704582675977],[-0.396165003229748,0,6.11568516244454],[-0.435537315731287,0,6.26042569238789],[-0.476737009430427,0,6.40465670583194],[-0.519757494337091,0,6.54835513267926],[-0.564591889221268,0,6.69149798802094],[-0.611233022713687,0,6.83406237581306],[-0.65967343445289,0,6.97602549253898],[-0.709905376278538,0,7.1173646308568],[-0.761920813470746,0,7.25805718323149],[-0.815711426035257,0,7.39808064555097],[-0.871268610034244,0,7.53741262072574],[-0.92858347896253,0,7.67603082227133],[-0.987646865169011,0,7.81391307787307],[-1.04844932132304,0,7.95103733293262],[-1.11098112192553,0,8.08738165409566],[-1.17523226486463,0,8.22292423276015],[-1.24119247301552,0,8.3576433885647],[-1.30885119588429,0,8.4915175728564],[-1.37819761129552,0,8.62452537213754],[-1.44922062712332,0,8.7566455114908],[-1.52190888306552,0,8.88785685798218],[-1.59625075246079,0,9.0181384240413],[-1.67223434414837,0,9.14746937081838],[-1.74984750437003,0,9.2758290115175],[-1.82907781871418,0,9.40319681470545],[-1.90991261410152,0,9.52955240759587],[-1.99233896081214,0,9.6548755793078],[-2.07634367455368,0,9.7791462840986],[-2.16191331857019,0,9.9023446445702],[-2.24903420579132,0,10.0244509548486],[-2.33769240102169,0,10.1454456837358],[-2.42787372316976,0,10.2653094778341],[-2.51956374751621,0,10.3840231646412],[-2.61274780802117,0,10.5015677556176],[-2.70741099967008,0,10.6179244492233],[-2.8035381808578,0,10.7330746339253],[-2.90111397581056,0,10.8469998911746],[-3.00012277704531,0,10.9596819983526],[-3.10054874786623,0,11.0711029316850],[-3.20237582489778,0,11.1812448691258],[-3.30558772065414,0,11.2900901932072],[-3.41016792614439,0,11.3976214938578],[-3.51609971351320,0,11.5038215711876],[-3.62336613871643,0,11.6086734382388],[-3.73195004423145,0,11.7121603237031],[-3.84183406180146,0,11.8142656746044],[-3.95300061521362,0,11.9149731589462],[-4.06543192311039,0,12.0142666683243],[-4.17911000183372,0,12.1121303205031],[-4.29401666830157,0,12.2085484619561],[-4.40892333476941,0,12.3049666034091],[-4.52383000123726,0,12.4013847448621],[-4.63873666770511,0,12.4978028863150],[-4.75364333417295,0,12.5942210277680],[-4.8685500006408,0,12.690639169221],[-4.98345666710865,0,12.7870573106740],[-5.09836333357649,0,12.8834754521270],[-5.21327000004434,0,12.9798935935799],[-5.32817666651219,0,13.0763117350329],[-5.44308333298003,0,13.1727298764859]]
rotations = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.0197823401541,-0.0395646803081,-0.083929374814,-0.151951089501,-0.276953041553,-0.433410406113,-0.632110178471,-0.965097725391,-1.28618347645,-1.77674126625,-2.21355104446,-2.83690094948,-3.36144304276,-4.07549285889,-4.6547999382,-5.42104721069,-6.11628723145,-6.82009744644,-7.52973175049,-8.242811203,-8.95811080933,-9.6739397049,-10.390291214,-11.0798664093,-11.8237514496,-12.5435218811,-13.259013176,-13.9761791229,-14.6936197281,-15.4109125137,-16.1280708313,-16.8457832336,-17.5646896362,-18.2805137634,-18.9967517853,-19.6809310913,-20.4329471588,-21.1172580719,-21.8678417206,-22.5517272949,-23.3028945923,-24.0169754028,-24.7385463715,-25.4126987457,-26.1709594727,-26.8571910858,-27.6046047211,-28.2732105255,-29.0410957336,-29.7245941162,-30.4749107361,-31.2565174103,-31.9090518951,-32.6843223572,-33.3464851379,-34.093547821,-34.7822227478,-35.4534912109,-36.2104263306,-36.8674621582,-37.651763916,-38.3268432617,-39.0805778503,-39.75831604,-40.5209617615,-41.3033027649,-41.9467315674,-42.7125434875,-43.3866958618,-44.1332626343,-44.810836792,-45.5930938721,-46.2115783691,-46.7850189209,-47.5163841248,-48.0392189026,-48.6333274841,-49.0393028259,-49.4651641846,-49.6783599854,-49.8670730591,-49.9598884583,-49.9899749756,-50.0002822876,-50.0074234009,-49.9894752502,-49.998878479,-50.0030937195,-50]



def playpath():
	path = addAnimationPath()

	for x in range (0,len(positions)):
			
		cp = add(CONTROL_POINT)
		cp.setPosition(positions[x])
		cp.translatemode(BEZIER)
		cp.rotatemode(BEZIER)
		#cp.rotate(rotations[x],0,0)

		path.add(cp,x)
			
	path.speed(8)
	path.translatemode(BEZIER)
	path.rotatemode(BEZIER)

	path.play()
	
	#Wait one frame before turning autorotate on and linking view to path
	yield None
	path.autorotate(ON)
	mainView.link(path)


def delaystart():
	yield viztask.waitTime(2)
	yield playpath()
viztask.schedule(delaystart())

go()
The trick is to way a frame before turning autorotate on and linking the view to the path.

I haven't looked into the issue with the view resetting to the origin. I'll get back to you on that.
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


All times are GMT -7. The time now is 07:18 PM.


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