View Single Post
Old 04-25-2016, 04:16 AM
jelly jelly is offline
Join Date: Feb 2016
Posts: 38
The arrow key problem seems to be a problem in my particular case, but not necessarily acoding mistake. This simple code shows that, for some reason only the left arrow key works.

import viz															
import viztask														



def key():
	yield viztask.waitKeyDown(viz.KEY_LEFT or viz.KEY_RIGHT)
	if viz.key.isDown(viz.KEY_RIGHT):
		print '"RIGHT" key is down'
	elif viz.key.isDown(viz.KEY_LEFT):
		print '"LEFT" key is down'
This is not a problem of my keyboard though, because the key works otherwise. It must somehow be related to Vizard. Any ideas what it could be?

As for the second problem with the animation paths:

I have reset all three animation paths at the beginning of the trial and re-established the link. I have actually tried an impossible number of combinations, where I resert the animations at different locations (inside each of the functions, same goes for the link and resetting the viewpoint at the start location. Each time things turn out different, sometimes the coordinates are so much off, it is impossible to track what is going on. Other times, they are only slightly off and in some cases I have animations that add the paths of the second animation to the first one, hence creating one long one. This is a clue that sometimes the animation paths maybe do not reset?

The closes I got was with this code (please see below). This works almost perfectly. Only the first control point of the main maze animation path is a bit off. Firts time, it runs perfectly, the next times it always takes the same last coordinates of the end control point of the left door animation path. So the biggest clue for me to understand is where do I reset the door animation best? In the chooseDoor function, in the trial function? I have tried them all..

import viz															
import viztask														

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



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

#Load a maze and make it invisible
maze1 = viz.add('Objects/Maze_1.dae')

#Add a sky with an environment map.
env = viz.add(viz.ENVIRONMENT_MAP,'sky.jpg')
dome = viz.add('skydome.dlc')

#Parameters for the viewpoint
view = viz.MainView 

##Animation path
pathMaze1 = viz.addAnimationPath()

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

#Duation of animation path
pathMaze1Duration = pathMaze1.getDuration()

#animation paths for choosing doors

pathDoorLeft = viz.addAnimationPath()
pathDoorLeft.addControlPoint(0, autoRemove = True, pos=(0,0,5),euler=(0,0,0),scale=(2,2,2))
pathDoorLeft.addControlPoint(1, autoRemove = True, pos=(0,0,5),euler=(-10,0,0),scale=(2,2,2))
pathDoorLeft.addControlPoint(2, autoRemove = True, pos=(-1.3,0,10),euler=(-10,0,0),scale=(2,2,2))
pathDoorLeftDuration = pathDoorLeft.getDuration()

pathDoorRight = viz.addAnimationPath()
pathDoorRight.addControlPoint(0, autoRemove = True, pos=(0,0,5),euler=(0,0,0),scale=(2,2,2))
pathDoorRight.addControlPoint(1, autoRemove = True, pos=(0,0,5),euler=(10,0,0),scale=(2,2,2))
pathDoorRight.addControlPoint(2, autoRemove = True, pos=(1.3,0,10),euler=(10,0,0),scale=(2,2,2))
pathDoorRightDuration = pathDoorRight.getDuration()

link =,view)

def chooseDoor():

	yield viztask.waitKeyDown(viz.KEY_LEFT or viz.KEY_RIGHT)
	if viz.key.isDown(viz.KEY_LEFT):
		link =,view) 
		yield viztask.waitTime(pathDoorLeftDuration)
	elif viz.key.isDown(viz.KEY_RIGHT):
		link =,view)
		yield viztask.waitTime(pathDoorRightDuration)

def animation():
	link =,view)
	yield viztask.waitTime(pathMaze1Duration)

def maze1trial():
	print 'new trial'
	link =,view)
	print view.getPosition(mode = viz.ABS_PARENT) #starting point of animation just for control purposes
	yield animation()
	print view.getPosition(mode = viz.ABS_PARENT) #ending point of animation just for control purposes
	yield chooseDoor()

def masterFunction():
	for x in range(4):
		yield maze1trial()
Thank you very much in advance for your help!
Reply With Quote