for i in range(len(self.keyframe_points)-1):
kf1 = self.keyframe_points[i]
kf2 = self.keyframe_points[i+1]
- dx = (kf2.co[0]-kf1.co[0])/3
- slope1 = (kf1.handle_right[1]-kf1.co[1])/(kf1.handle_right[0]-kf1.co[0])
- slope2 = (kf2.co[1]-kf2.handle_left[1])/(kf2.co[0]-kf2.handle_left[0])
+ dx = (kf2.co.x-kf1.co.x)/3
+ slope1 = (kf1.handle_right.y-kf1.co.y)/(kf1.handle_right.x-kf1.co.x)
+ slope2 = (kf2.co.y-kf2.handle_left.y)/(kf2.co.x-kf2.handle_left.x)
if i==0:
self.knots.append(mathutils.Vector(kf1.co))
p2 = c.knots[i+2]
p3 = c.knots[i+3]
for j in range(50):
- t = (p0[0]*(50-j)+p3[0]*j)/50
- x = (t-p0[0])/(p3[0]-p0[0])
+ t = (p0.x*(50-j)+p3.x*j)/50
+ x = (t-p0.x)/(p3.x-p0.x)
v1 = c._curve.evaluate(t)
- v2 = p0[1]*(1-x)**3+3*p1[1]*x*(1-x)**2+3*p2[1]*x**2*(1-x)+p3[1]*x**3
+ v2 = p0.y*(1-x)**3+3*p1.y*x*(1-x)**2+3*p2.y*x**2*(1-x)+p3.y*x**3
keyframes_by_time = {}
controls_by_time = {}
self.keyframes = []
for c in self.curves:
for i, k in enumerate(c.knots):
- x = k[0]
+ x = k.x
control = i%3!=0
kf_map = controls_by_time if control else keyframes_by_time
if x in kf_map:
for c in self.curves:
for k in c.knots:
- k[0] -= self.start_time
+ k.x -= self.start_time
for k in self.keyframes:
k.time -= self.start_time
def check_looping(self, threshold):
self.looping = True
for c in self.curves:
- first_y = c.knots[0][1]
- last_y = c.knots[-1][1]
+ first_y = c.knots.x.y
+ last_y = c.knots[-1].y
d = abs(last_y-first_y)
if c.data_path=="rotation_euler":
for c in self.curves:
for k in c.knots:
- k[0] *= scale
+ k.x *= scale
for k in self.keyframes:
k.time *= scale
resource = Resource(obj.name+".camera", "camera")
position = obj.matrix_world@mathutils.Vector((0, 0, 0))
- resource.statements.append(Statement("position", position[0], position[1], position[2]))
+ resource.statements.append(Statement("position", position.x, position.y, position.z))
look_dir = obj.matrix_world@mathutils.Vector((0, 0, -1, 0))
- resource.statements.append(Statement("look_direction", look_dir[0], look_dir[1], look_dir[2]))
+ resource.statements.append(Statement("look_direction", look_dir.x, look_dir.y, look_dir.z))
right_dir = obj.matrix_world@mathutils.Vector((1, 0, 0, 0))
look_xy = mathutils.Vector((look_dir.x, look_dir.y, 0))
if light.type=='SUN':
light_res.statements.append(Statement("type", Token("directional")))
- light_res.statements.append(Statement("direction", *(-obj.matrix_world.col[2])[0:3]))
+ light_res.statements.append(Statement("direction", *-obj.matrix_world.col[2].xyz))
elif light.type=='POINT':
light_res.statements.append(Statement("type", Token("point")))
pos = obj.matrix_world@mathutils.Vector((0.0, 0.0, 0.0, 1.0))
- light_res.statements.append(Statement("position", *obj.matrix_world.col[3][0:3]))
+ light_res.statements.append(Statement("position", *obj.matrix_world.col[3].xyz))
light_res.statements.append(Statement("attenuation", 1.0, 0.0, 1.0))
else:
raise Exception("Can't export light {} of unknown type {}".format(light.name, light.type))