rendered paste body#!BPY """Name: 'Game Engine Path Baker'Blender: 242Group: 'Misc'Tooltip: 'Bake a path animation to and object's Ipo'"""__author__= "Timothy Wakeham"__url__= ["blender.org", "blenderartists.org"]__version__= "1.0"__bpydoc__= """\This script bakes a path animation to an object's Ipo, for use in the game engineUsage:Modify the User variables as fits your application, and run from text window."""# User edit stuff here ###################################number of steps between each controlpointres = 25#object to make follow pathbake_ob = 'Camera'#number of frames each step takesstep_time = 1#start framestart = 0# End user edit stuff ###################################import Blenderdef coeff(p0, p1, p2, p3): co = [] for x in range(3): cx = 3 * (p1[x] - p0[x]) bx = 3 * (p2[x] - p1[x]) - cx ax = p3[x] - p0[x] - cx - bx co.append([ax, bx, cx]) return codef eval_curve(o, co, t): p = [] t2 = t*t for x in range(3): val = co[x][0] * t2 * t + co[x][1] * t2 + co[x][2] * t + o[x] p.append(val) return pobj = Blender.Object.GetSelected()[0]if obj.getType() <> 'Curve': Blender.Draw.PupMenu('Please select path to bake%t|Ok') raisecurve = obj.getData()points = curve[0]num_points = len(points)frame = startstep = 1.0 / resobj = Blender.Object.Get(bake_ob)ipo = Blender.Ipo.New('Object', 'Path')lx = ipo.addCurve('LocX')ly = ipo.addCurve('LocY')lz = ipo.addCurve('LocZ')for idx in range(num_points - 1): b0 = points[idx].getTriple() b1 = points[idx + 1].getTriple() p0 = b0[1] p1 = b0[2] p2 = b1[0] p3 = b1[1] co = coeff(p0, p1, p2, p3) for t in range(res): p = eval_curve(p0, co, step * t) lx[frame] = p[0] ly[frame] = p[1] lz[frame] = p[2] frame += step_time obj.setIpo(ipo)