WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #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
  #2  
Old 04-18-2016, 02:52 AM
jelly jelly is offline
Member
 
Join Date: Feb 2016
Posts: 38
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())
Reply With Quote
  #3  
Old 04-18-2016, 02:53 AM
jelly jelly is offline
Member
 
Join Date: Feb 2016
Posts: 38
I would really appreciate your help!
Reply With Quote
  #4  
Old 04-18-2016, 06:01 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Make sure you reset the path at the beginning of each trial:

Code:
pathMaze1.reset()
Reply With Quote
  #5  
Old 04-18-2016, 07:18 AM
jelly jelly is offline
Member
 
Join Date: Feb 2016
Posts: 38
Smile

Thank you so much, this did the trick and it now works perfectly!!
Reply With Quote
  #6  
Old 04-20-2016, 06:15 AM
jelly jelly is offline
Member
 
Join Date: Feb 2016
Posts: 38
Exclamation Help again, coordinates not reset

Dear Jeff,

I am sorry, but I am still having problems. To simplify the issue I will explain the first problem I am having, as (once solved) it may solve the others as well.

The problem is that once the trial and the animation run once, the other times they run, the coordinates are reset. To find out what happens I added two lines to find out the cooridnates (red below), at those points where I believe I should get the starting and end positions. But the output gives me this:

Code:
now
[-6.400000095367432, 0.0, -8.0]
[0.0, 1.399999976158142, 5.0]
now
[0.0, 0.0, 5.0]
[0.0, 0.0, 5.0]
now
[0.0, 0.0, 5.0]
[0.0, 0.0, 5.0]
now
[0.0, 0.0, 5.0]
[0.0, 0.0, 5.0]
Only the very fist line is correct, since that is the starting position. What happens with the coordinates for the animation and the viewpoint during the other 3 trials?. I would be so grateful for your help!

I have updated the code below.

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'
	print view.getPosition(mode = viz.ABS_PARENT)
	pathMaze1.reset()
	maze1.visible(viz.ON)
	viewNode.setPosition(-6.4,0,-8)
	link = viz.link(pathMaze1,viewNode)
	yield pathMaze1.play()
	yield viztask.waitTime(pathMaze1Duration)
	print view.getPosition(mode = viz.ABS_PARENT)
	link.remove
	maze1.visible(viz.OFF)


def masterFunction():								
	for x in range(4):
		yield maze1trial()
		
viztask.schedule(masterFunction())
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create Animation Path Abood Karkar Vizard 2 01-27-2016 05:03 PM
Road Animation Path vserchi Vizard 4 11-12-2015 09:29 AM
Clarification on CAL3D Avatar Animation in Vizard shivanangel Vizard 2 11-22-2010 07:16 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


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


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