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
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:enter image description here
Here is a pic after keyframe: enter image description here
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.

  • $\begingroup$ I've found it prudent not to parent cameras direct to a path, rather have an empty parented to it instead and parent the cam to that. Constraint conflicts have disappeared after that. Timing, stops and starts, and speed variations are possible within paths. I have done this some time ago. $\endgroup$
    – Edgel3D
    Mar 7 '17 at 21:13
  • $\begingroup$ is that what this is. A constraint conflict? $\endgroup$
    – Chris
    Mar 7 '17 at 21:20
  • $\begingroup$ Not sure by your question but my suggestion has cleared a lot of 'jittery' cameras. It frees the cam to pursue it's own constraints. $\endgroup$
    – Edgel3D
    Mar 7 '17 at 21:21
  • $\begingroup$ I am new at blender and animation so bear with me. I just learned about constraints yesterday. I have never used an empty so i will have to look into that. As for my question if you look at the picture. At frame 241 before keyframes the camera is on the path but not at the point where i want it. I want it ahead on the path where it turns. After i insert keyframes in the second picture you can see that at the same frame count the camera has flown way off the path. So if creating an empty will resolve this i will look into it. $\endgroup$
    – Chris
    Mar 7 '17 at 21:33
  • $\begingroup$ ha ha I know how you feel ! When first exploring Blender over some months I invented an entirely new language - most of it unprintable ! I'll keep an eye on this space. There are heaps of very clever Blenderites in here so you're bound to find a solution to most problems. $\endgroup$
    – Edgel3D
    Mar 7 '17 at 21:36

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)
  • $\begingroup$ You rock!!!!! it was the follow path constraint. Removed that and the frame_set and works almost perfectly. The camera swings wide to create a smooth curve instead of following the path explicitly. If i change to linear interpolation that should resolve that, correct?? $\endgroup$
    – Chris
    Mar 8 '17 at 4:14
  • $\begingroup$ Everything is perfect. Changing interpolation to linear fix that last issue. $\endgroup$
    – Chris
    Mar 8 '17 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.