View Single Post
  #1  
Old 04-20-2016, 09:06 AM
jelly jelly is offline
Member
 
Join Date: Feb 2016
Posts: 38
animation path problem - coordinates not resetting

Dear Jeff,

I am sorry, but I am still having problems with my animation path from here http://forum.worldviz.com/showthread.php?t=5695 Since it is a different problem, I decided to open a new thread.

The problem is that after the trial (and the animation) run once, the other three times they run, the coordinates are not 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. The output gives me this, which is indeed very strange:

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. In another version I tried removing all control points at the end of the trial and adding them at the beginning. But that does not seem to help What happens with the coordinates for the animation and the viewpoint during the other 3 trials? It seems that the viewpoint is not reset, but that it takes and keeps the very last coordinate which is also relative to the path not absolute in the coordinate space.

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