WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 04-22-2016, 09:23 AM
jelly jelly is offline
Member
 
Join Date: Feb 2016
Posts: 38
I am afraid that the problem continues as soon as I introduce further animation paths. I changed the one I had before to get the following: a trial triggers an animation that moves the viewpoint through a maze until a certain point when it wiats for an arrow key. Once a key is pressed it triggers one of two possible animations (going through left or right door). After this, immmediately, the next trial should start.

Problem 1:

This almost happens, only that the second trial starts at the point where the last door was, etc. I tried resetting the animation paths at various points and nothing seems to help.

Problem 2:

For some reason, it the right arrow key seems to not work. This seems to be a problem of the if statement, because even if I replace the arrow key with the space bar, it does not take the "elif" statement...

I would highly appreciate any pointers in the right direction!

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)

viz.go()

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

#Load a maze and make it invisible
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)

#Parameters for the viewpoint
view = viz.MainView 
view.eyeheight(1.4)
view.setPosition(startPos)
view.collision(viz.ON)
viz.collisionbuffer(.8)

##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()

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

def animation():
	link = viz.link(pathMaze1,view)
	pathMaze1.play()
	yield viztask.waitTime(pathMaze1Duration)
	#pathMaze1.reset()


def maze1trial():
	print 'new trial'
	pathMaze1.reset()
	pathDoorRight.reset()
	pathDoorLeft.reset()
	view.setPosition(startPos)
	link = viz.link(pathMaze1,view)
	print view.getPosition(mode = viz.ABS_PARENT) #starting point of animation just for control purposes
	maze1.visible(viz.ON)
	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()
viztask.schedule(masterFunction())
Reply With Quote
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with path animation jelly Vizard 5 04-20-2016 06:15 AM
Road Animation Path vserchi Vizard 4 11-12-2015 09:29 AM
Problems with interaction of vizact.turn and animation path Enlil Vizard 3 11-24-2008 04:23 PM
speed on animation path whj Vizard 8 11-17-2008 07:41 PM
another bezier animation problem masaki Vizard 1 01-24-2008 02:29 PM


All times are GMT -7. The time now is 08:36 PM.


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