I noticed that it's not good to have a function with the same name is an object "maze1" so I cahnged the fucntion name to "maze1trial". This, however still has not solved my problem. I wonder why the viewpoint does not reset to the start position, or why the animation does not play again, respectively? I played around with the viewpoint and thought it may be because of the link, so within the trial, at the very end, I am also unlinking, just to be sure. Still did not solve the issue. I would just like the maze objhect to lead and then the viewpoint animation to be played 4 times (as in repeating the animation 4 times, one after the other).
It now looks like this:
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.OFF)
#Add a sky with an environment map.
env = viz.add(viz.ENVIRONMENT_MAP,'sky.jpg')
dome = viz.add('skydome.dlc')
dome.texture(env)
view = viz.MainView
view.eyeheight(1.4)
view.setPosition(startPos)
view.collision(viz.ON)
viz.collisionbuffer(.8)
viewNode = viz.addGroup()
viewLink = viz.link( viewNode, viz.MainView)
viewNode.setPosition([-6.4,0,-8])
##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 maze1trial():
print 'now'
maze1.visible(viz.ON)
viewNode.setPosition(-6.4,0,-8)
link = viz.link(pathMaze1,viewNode)
yield pathMaze1.play()
yield viztask.waitTime(pathMaze1Duration)
link.remove
maze1.visible(viz.OFF)
def masterFunction():
for x in range(4):
yield maze1trial()
viztask.schedule(masterFunction())