PDA

View Full Version : Trouble with adding actions


vijaykiran
10-05-2009, 03:18 PM
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:


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 wheel.center(x,y,z) to make the turn look realistic. So, I changed the code to this:


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 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.