Translation Matrix Coordinates I have been reading many of the threads here regarding translation matrices and converting.  I am still confused as to how this works to apply to my project.


I currently have a camera object that is a child of my nurbs_path. I have a constraint on the camera for follow path.  Everything is perfect.  My camera is at correct starting location.


What i have figured out so far is that
 
print(camera_object.location)
 
gives me the translated coordinates based on the parent.  I don't completely understand this but not a huge issue at the moment.

My output from print

Vector (-0.0017, -6.6515, 5.0000)
Vector (-0.0017, -6.6515, 5.0000)
Vector (58.6404, -36.0573, 3.0000)
Vector (15.9993, -53.7008, 3.0000)
Vector (58.6404, -71.3442, 7.0000)
Vector (15.9993, -88.9877, 10.0000)
Vector (58.6404, -106.6311, 5.0000)
Vector (15.9993, -124.2746, 6.0000)
Vector (58.6404, -141.9181, 7.0000)
Vector (26.6596, -159.5615, 8.0000)



What i am trying to do is keyframe this camera path to certain timings.  A guy on blender artists showed me how to do the keyframing and i can do it in UI.  I have the keyframes set up but get wierd camera behavior after applying the keyframes.  I am guessing this is because of translation based on my research.

num_points: Length of a list

camera_object and scene are defined before this loop

verts: list of postions (time_offset, X, Y, Z)
     : X, Y, Z are in global space (i think??)


for point in range(num_points):
    current_frame = //calc to get frame number from a time offset
    print(camera_object.location) # print current camera location
    scene.frame_current = current_frame_num
    camera_object.location = verts[point]
    camera_object.keyframe_insert(data_path="location", frame=current_frame)
    previous_frame = self.__user_points[point]


The keyframes are inserted at frame 1, 241, 481, +240 frames each time to frame 2160.

Here is a pic before keyframe:

Here is a pic after keyframe: 

The camera is the selected object to see it easier.

These are the coordinate of the verts list:


[[-0.0017454936660825002, -6.651534000393163, 5.0], 
[58.64040695838593, -36.057303922236066, 3.0], 
[15.99932173602529, -53.70076587534348, 3.0], 
[58.64040695838593, -71.3442278284509, 7.0], 
[15.99932173602529, -88.98768978155623, 10.0], 
[58.64040695838593, -106.63115173466363, 5.0], 
[15.99932173602529, -124.27461368777105, 6.0], 
[58.64040695838593, -141.91807564087637, 7.0], 
[26.659593041615448, -159.5615375939838, 8.0], 
[79.96094956956625, -165.44269157835362, 9.0]]


Any help would be appreciated.
I expect part of the issue comes from you having the camera still following the curve after you have keyframed it. Remove the follow path constraint from the camera after you have the locations for the keyframes.

For your code - don't change frame_current, you should use frame_set(), but in your example you don't need to use either as you are specifying the frame when you create the keyframe.

I would use something like -

import bpy

# each item is time_offset, x, y, z
verts = [
    [0.0, -0.0017,   -6.6515,  5.0],
    [0.1, 58.6404,  -36.0573,  3.0],
    [0.2, 15.9993,  -53.7007,  3.0],
    [0.3, 58.6404,  -71.3442,  7.0],
    [0.4, 15.9993,  -88.9876, 10.0],
    [0.5, 58.6404, -106.6311,  5.0],
    [0.6, 15.9993, -124.2746,  6.0],
    [0.7, 58.6404, -141.9180,  7.0],
    [0.8, 26.6595, -159.5615,  8.0],
    [0.9, 79.9609, -165.4426,  9.0],
]

camera_object = bpy.data.objects['Camera']

for point in range(len(verts)):
    cur_frame = 2160 * verts[point][0]
    camera_object.location = (verts[point][1],verts[point][2],verts[point][3])
    camera_object.keyframe_insert(data_path="location", frame=cur_frame)