PDA

View Full Version : smoothing a cubic bezier path


just alex
03-24-2009, 02:40 PM
I've got an animation path that I've been having issues with. When I use a cubic bezier path, the curve will either swing too wide and leave the area I want the object to move in, or, when I add extra cp's to keep it on path, will jerk to reset it's facing rather than smoothly turn. The path is going to be way too long for just using a bezier and keeping it in the movement area.
Is there a decent way to smooth this out, or will I just have to live with the jerkiness?

Jeff
03-26-2009, 06:05 PM
Have you tried turning on autorotate for the animation path?

just alex
04-01-2009, 04:00 PM
Yeah, I've got autorotate on, I'll post the code as soon as I get to my computer again

Gladsomebeast
04-01-2009, 09:09 PM
If you got the skills and the path is static, I'd stop right now and create the animation in 3ds Max.

I've spent way to much time tuning animation paths and they are never quite right.

Controlling the node's orientation with animation paths is the hardest. You might want to control the orientation with some other method. Perhaps you could have node 'lookat' another node that moves around too?

just alex
04-02-2009, 10:40 AM
Here's the code.

The path is static, but I've never even looked at 3ds Max, so I wouldn't know what to do, though I might be able to pick it up with google fu.
I'll give it a go, but don't know how it'll work.

import viz
import math
import vizmat
import vizinfo
import vizact
viz.go()


#Add the street and drop it a little bit to be below the avatars feet.
street = viz.add('objects/bspcity.bsp')
street.translate(0,-.2,0)

#Add car.
car = viz.add('mini.osgx')

car.setScale(.8,.8,.8)


car.translate(-23,0,-8.8)


path = viz.add(viz.ANIMATION_PATH)
positions = [[-23,0,-8.8],[-23,0,-8],[-34,0,-8],[-34,0,0],[-43,0,0],[-43,0,8],[-43,0,17]]

for x in range(0,len(positions)):
cp = viz.add(viz.CONTROL_POINT)
cp.setPosition(positions[x])
path.add(cp,x+1)


path.constantspeed(viz.ON,1)

path.loop(viz.LOOP)

#computes cubic bezier
path.computetangents()

path.translatemode(viz.CUBIC_BEZIER)

path.setAutoRotate(viz.ON)
car.link(path)

def onkeydown(key):
if key == ' ':
path.play()

viz.callback(viz.KEYDOWN_EVENT,onkeydown)

just alex
04-07-2009, 12:43 AM
Would Google Sketchup be a possible substitute for 3ds Max?

Gladsomebeast
04-07-2009, 11:16 AM
Don't know if Google Sketchup will work. I'll try exporting an animation to VRML and Collada from Sketchup and testing in Vizard.

It would be nice to establish an art workflow that does not center around the expensive and complex 3ds Max.

Gladsomebeast
04-07-2009, 12:57 PM
After checking out SketchUp, I don't think it can export animations to 3D formats like VRML. Plus, it's $500 for the Pro version which you need to export to common 3D file formats.

Anyone know if Blender can export OSG animations? It seems Blender can export to Cal3D well enough for Vizard to use it. That could be an animation workflow for Blender to Vizard. Vizard supports VRML animations, so if Blender can export animated VRMLs that could work as well.

just alex
04-08-2009, 01:23 PM
Would it be possible to swap between a bezier path and a linear path? I could at least get some of the straight areas to go well then.

Jeff
04-09-2009, 02:06 PM
As long as you know how long one path takes to complete you could link your object to the second path when the timer, set to the time of the first path, expires.

Gladsomebeast
04-22-2009, 01:07 PM
I figured out how to use Blender to create animation paths. This seems much easier than tweaking control points forever in Vizard.

Steps:
1. Install Blender. (http://www.blender.org/download/get-blender/)
2. Install osg export plugin. Download plugin. (http://projects.blender.org/projects/osgexport/) Copy the osgexport-2.42.py file into <Program Files>\Blender Foundation\Blender\.blender\scripts directory.
3. Learn how to animate a box in blender. This video provides a simple introduction: http://www.youtube.com/watch?v=FAZFfLmbD2k
4. Checkout the attached Vizard script that moves a car around with an animated box made in blender. The zip includes the .blend file.

import viz
viz.go()

path = viz.add('output.osg')
vizact.onkeydown(' ', path.hint, viz.RESET_ANIMATION_HINT)
path.disable(viz.RENDERING)

car = viz.add('mini.osgx')

linky = viz.link(path.getChild('Cube_geode'), car, srcFlag=viz.LINK_ABSOLUTE)
linky.preEuler([0, -90, 0]) #rotate car upright

viz.MainView.setPosition([0,1,-5])

viz.MainView.getHeadLight().disable()
light = viz.add(viz.LIGHT)
light.position(.5,1,-.5,0)
light.intensity(3)

viz.clearcolor(viz.SKYBLUE)
viz.add('tut_ground.wrl')