0
$\begingroup$

I'm new to Blender, and I'd like to animate my camera rotating around 360 degrees to show off part of a 3d model. I have a setup, and the camera will move, but instead of pivoting all the way around the camera will rotate most of the way, and then spin all the way (more than 180 degrees) back around. Here's an example

An example

And here's the code:

camera.keyframe_insert(data_path="rotation_euler", frame=0.0, index=-1)
camera.rotation_euler.rotate_axis( 'Y', 2 * math.pi / 3 )
camera.keyframe_insert(data_path="rotation_euler", frame=frames/3., index=-1)
camera.rotation_euler.rotate_axis( 'Y', 2 * math.pi / 3 )
camera.keyframe_insert(data_path="rotation_euler", frame=2.*frames/3., index=-1)
camera.rotation_euler.rotate_axis( 'Y', 2 * math.pi / 3 )
camera.keyframe_insert(data_path="rotation_euler", frame=frames, index=-1)

Is there a good solution to this?

$\endgroup$
2
  • $\begingroup$ Does the animation need to be scripted? $\endgroup$
    – ChiCubed
    Dec 9, 2016 at 7:46
  • $\begingroup$ Yeah, I'll be doing a lot of these :) $\endgroup$
    – user32344
    Dec 9, 2016 at 7:48

1 Answer 1

1
$\begingroup$

Instead of rotating around a global axis with rotate_axis set absolute values to the rotation channels and handle all the relative transformations in code.

camera.rotation_euler = (math.pi/2, 0, 0)
camera.keyframe_insert(data_path="rotation_euler", frame=0.0)

prevRot = camera.rotation_euler
nextRot = (prevRot[0], prevRot[1], prevRot[2] + 2 * math.pi)
# or absolute values
# nextRot = (math.pi/2, 0, 2*math.pi)

camera.rotation_euler = nextRot
camera.keyframe_insert(data_path="rotation_euler", frame=frames)

The script presumes Y is Up.

$\endgroup$
1
  • $\begingroup$ That works perfectly! Thanks for the tip and the explanation. $\endgroup$
    – user32344
    Dec 9, 2016 at 7:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .