__author__ = 'thoth'
# http://blender.stackexchange.com/questions/53983/get-points-of-bezier-curve-in-coordinate-space-of-the-scene
import bpy
from math import *
def interpBez3(bp0, t, bp3):
# bp1, HR, HL, bp2
return interpBez3_(bp0.co, bp0.handle_right, bp3.handle_left, bp3.co, t)
# return interpBez3_(bp0.co, bp0.handle_left, bp3.handle_right, bp3.co, t)
def interpBez3_(p0, p1, p2, p3, t):
r = 1-t
return (r*r*r*p0 +
3*r*r*t*p1 +
3*r*t*t*p2 +
t*t*t*p3)
def mission1(obj, t):
i1 = floor(t)
curve = obj.data
bp1 = curve.splines[0].bezier_points[i1]
bp2 = curve.splines[0].bezier_points[i1+1]
bpy.context.scene.cursor_location = obj.matrix_world * interpBez3(bp1, t-i1, bp2)
mission1(bpy.context.active_object, 0.7)
|
Blender python API quick-start
Syntax highlighting by Pygments.