View Single Post
  #1  
Old 04-16-2016, 11:42 AM
jelly jelly is offline
Member
 
Join Date: Feb 2016
Posts: 38
problem with path animation

Hello!

I want to run a function 4 times. The function entails that the viewpoint is being animated as to look as it is moving through a maze. The problem is that, while it always loads the function 4 times, the animation only works the first time, after which is stops at the position of the end of the animation. It's as if the viewpoint does not get updated back to its initial setting.

I would be extremely grateful for any help or pointers, because I tried everything I could think of and it is just trial-and-error!


Code:
import viz															#Needed to generate a world.
import viztask														#Needed to control the experiment structure.


viz.mouse.setVisible(viz.OFF) 										#Stops the mouse appearing on the screen.
viz.mouse.setOverride(viz.ON)										#Stops Vizard navigation using the mouse.

viz.clearcolor(viz.BLACK)



#Set the start position:
startPos = [-6.4,0,-8]


viz.go()

### Add all the resources. ############### 
maze1 = viz.add('Objects/Maze_1.dae')
#maze1.visible(viz.ON)

subwindow = viz.addWindow()

view = viz.addView()

view.eyeheight(1.4)
view.setPosition(startPos)
view.collision(viz.ON)
viz.collisionbuffer(.8)

subwindow.setView( view )
subwindow.setSize( 0.4,0.4 )
subwindow.setPosition(0.3,0.7) #(0,1)
subwindow.visible( viz.ON )



##Animation path


pathMaze1 = viz.addAnimationPath()

#Add control points to the path, along with their time stamp.
pathMaze1.addControlPoint(0,pos=(-6.4,0,-8),euler=(0,0,0),scale=(2,2,2))
pathMaze1.addControlPoint(2,pos=(-6.4,0,-8),euler=(90,0,0),scale=(2,2,2))
pathMaze1.addControlPoint(4,pos=(0,0,-8),euler=(0,0,0),scale=(2,2,2))
pathMaze1.addControlPoint(8,pos=(0,0,5),euler=(0,0,0),scale=(2,2,2))

#Duation of animation
pathMaze1Duration = pathMaze1.getDuration()

#Loop the path in a swinging fashion (point A to point B to point A, etc.).
pathMaze1.setLoopMode(viz.OFF)


def maze1():
	print 'now'
	
	view.setPosition(-6.4,0,-8)
	link = viz.link(pathMaze1,view)
	yield viztask.waitTime(2)
	pathMaze1.play()
	yield viztask.waitTime(pathMaze1Duration)
	

def masterFunction():								
	for x in range(4):
		yield maze1()
		
viztask.schedule(masterFunction())
Reply With Quote