WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   update sequence animation speed (https://forum.worldviz.com/showthread.php?t=5309)

vserchi 03-16-2015 10:13 AM

update sequence animation speed
 
Hi, I am trying to interactively update the speed of certain objects animations (sequences of animation) in my virtual reality. At the change of the variable "speed" I need that the speed of translation of my objects accordingly changes too. In the following code there is a a very simplified example of what I am trying to do.

Code:

import viz
import vizact

viz.fov(60)
viz.go()

#Add the ground plane
ground = viz.addChild('ground.osgb')

#Move the viewpoint back
viz.MainView.move([0,0,-7])

ball = viz.add('beachball.osgb')
ball.setPosition(0,1,0)

ball1 = viz.add('beachball.osgb')
ball1.setPosition(0,0,0)

myAction1 = vizact.moveTo([ball.getPosition()[0], -1,  ball.getPosition()[1]],speed=1) # Definition of the animation of the road (custom function that manages its resume defined from line 364 to line 439
myAction2 = vizact.moveTo([ball.getPosition()[0], ball.getPosition()[1], ball.getPosition()[2]],[ball.getPosition()[0], 4, ball.getPosition()[1]],speed=1)
myAnimation = vizact.sequence(myAction1, myAction2, viz.FOREVER)

myAction3 = vizact.moveTo([ball1.getPosition()[0], -1,  ball1.getPosition()[1]],speed=1) # Definition of the animation of the road (custom function that manages its resume defined from line 364 to line 439
myAction4 = vizact.moveTo([ball1.getPosition()[0], ball1.getPosition()[1], ball1.getPosition()[2]],[ball1.getPosition()[0], 4, ball1.getPosition()[1]],speed=1)
myAnimation1 = vizact.sequence(myAction3, myAction4, viz.FOREVER)

ball.addAction(myAnimation)
ball1.addAction(myAnimation1)

def changeSpeed(pos):
        print str(pos), viz.Vector(ball.getVelocity())
        ball.setVelocity([0, pos, 0])
        ball1.setVelocity([0, pos, 0])

####        ball.setSpeed(pos)
####        ball1.setSpeed(pos)

slider = viz.addSlider()
slider.setPosition([.5,.5,0])

#Setup callbacks for slider events
vizact.onslider(slider, changeSpeed)

I really appreciate any help you may give me.
Valeria

Jeff 03-17-2015 02:33 AM

Animation paths may work for you. You can link the ball to an animation path and then change the path's speed.


All times are GMT -7. The time now is 08:58 AM.

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