WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Trouble with adding actions (https://forum.worldviz.com/showthread.php?t=2302)

vijaykiran 10-05-2009 03:18 PM

Trouble with adding actions
 
Hello,

I have been grappling with adding two animate actions and I am unable to get the animation I intended.

I am trying to make a car model move forward and turn right after a certain length. I used one of the samples to do it:

Code:

import viz
viz.go()
viz.add('tut_ground.wrl')
wheel = viz.add('mini.osgx') 

viz.move(0,0,-10)
viz.clearcolor(viz.SKYBLUE)

moveForward = vizact.move(0, 0, 2,1)
turnRight = vizact.spin(0,1,0,90,1)


moveInSquare = vizact.sequence(moveForward, turnRight, 2)

wheel.addAction(moveInSquare)

The animation is fine with this code except the car doesn't look like it's turning
correctly. The turning is about the center of the car model. I figured I need to add a
Code:

wheel.center(x,y,z)
to make the turn look realistic. So, I changed the code to this:

Code:

import viz
viz.go()
viz.add('tut_ground.wrl')
wheel = viz.add('mini.osgx') 
wheel.center(0.5,0,-0.5) # Added this piece of code

viz.move(0,0,-10)
viz.clearcolor(viz.SKYBLUE)

moveForward = vizact.move(0, 0, 2,1)
turnRight = vizact.spin(0,1,0,90,1)


moveInSquare = vizact.sequence(moveForward, turnRight, 4)

wheel.addAction(moveInSquare)

Now, the car turns sort of okay, but as soon as it turns right it zooms too fast compared to its first forward movement. It didn't make sense to me how it works. The
Code:

wheel.center(x,y,z)
should affect rotations but not translations. I am unsure why translations are affected. Besides, I am not sure what (x,y,z) in center() mean. Is it absolute coordinates or relative to the object?

Is there something I am missing? Any suggestions would be extremely helpful.

Thanks,
Vijay.


All times are GMT -7. The time now is 09:11 AM.

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