Adding 6 Rotation Keyframes for a Camera to an IPO w. Python

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
joshuaseaver
Posts: 0
Joined: Sun Jan 26, 2003 3:39 am
Location: Twin Cities, Minnesota, USA
Contact:

Adding 6 Rotation Keyframes for a Camera to an IPO w. Python

Post by joshuaseaver »

Hi folks!
I'm working hard on a Python script to export to a cubic QuickTime VR (that I intend to give to the community of course) and I think the best way to do it is to create a six frame animation with the camera pointing up, down, left...etc. I am at the point in my script where I want to automatically add the animation to any file when the script is executed.

I am at a wall right now as I've added a new IPO and linked it to the camera object, but I can't seem to figure out how to ADD a curve, or how to tell it to add the RotX, RotY and RotZ information I want it to have. When I try the setBeztriple method, I always get an attribute error (although I have to admit that without an example in the documentation, I am guessing as to what integers and floats I should be adding).

Any help would be GREATLY appreciated. Here's what I have so far...

Code: Select all

#!BPY

"""
Name: 'QTVR'
Blender: 233
Group: 'Render'
Tip: 'Export 6 JPG files for use in creation of a Cubic QTVR panorama file.'
"""
  
######################################################
# I N F O R M A T I O N
######################################################  
# Cubic QTVR Exporter
# By: Joshua Seaver, Kent Mein
# Date: 13 July 04
# Ver: 0.1
#-----------------------------------------------------
# (C) 2004 Joshua Seaver, Kent Mein - released under Blender Artistic License - www.blender.org
# This script exports 6 jpg renderings for use in a cubic QuickTime file.
# Before choosing to render, please have the camera you'd like to use
# in it's proper y location (in the center of your scene with no rotation on the y axis!
# Otherwise, the script will generate a new camera called qtvrcamera and place it at 
# x = 0, y = 0, z = 10
# 01.jpg = front face
# 02.jpg = left face
# 03.jpg = back face
# 04.jpg = right face
# 05.jpg = top face
# 06.jpg = bottom face
# Thanks to Andrew Kator for the article on blenderman.org
# To create a final QuickTime cubic .mov file, you will need 
# a tool like MakeCubic for Mac or GoCubic for Windows.
######################################################

#----------------------------------
# I M P O R T I N G  M O D U L E S
#----------------------------------  

import Blender
from Blender import Camera, Object, Scene
from Blender.Draw import *          # get the Blender OpenGL library
from Blender.BGL import *           # get the Bledner user interface library

#----------------------------------
# SET UP CAMERA FOR IMAGE 01
# rotation is in radians
# 1 degree = 0.016
#----------------------------------
def camPos1	():
	ob.RotX = 1.5708 # 90 degrees
	ob.RotY = 0
	ob.RotZ = -3.1416 # -180 degrees

#----------------------------------
# SET UP CAMERA FOR IMAGE 02
#----------------------------------
def camPos2 ():
	ob.RotX = 1.5708 # 90 degrees
	ob.RotY = 0
	ob.RotZ = -4.71239 # -270 degrees

#----------------------------------
# SET UP CAMERA FOR IMAGE 03
#----------------------------------
def camPos3 ():
	ob.RotX = 1.5708 # 90 degrees
	ob.RotY = 0
	ob.RotZ = -6.28319 # -360 degrees

#----------------------------------
# SET UP CAMERA FOR IMAGE 04
#----------------------------------
def camPos4 ():
	ob.RotX = 1.5708 # 90 degrees
	ob.RotY = 0
	ob.RotZ = -7.85399 # -450 degrees

#----------------------------------
# SET UP CAMERA FOR IMAGE 05
#----------------------------------
def camPos5 ():
	ob.RotX = 3.1416 # 180 degrees
	ob.RotY = 0
	ob.RotZ = -9.42477 # -540 degrees

#----------------------------------
# SET UP CAMERA FOR IMAGE 06
#----------------------------------
def camPos6 ():
	ob.RotX = 0
	ob.RotY = 0
	ob.RotZ = 9.42477 # 540 degrees

def checkAttributes(x):
  print "the IPO name is ", x.getName()
  print "the blocktype is ", x.getBlocktype()
  print "the number of curves is ", x.getNcurves()
  print "getCurves = ", x.getCurves()

#----------------------------------
# C A M E R A  S E T U P
#----------------------------------
"""
need to create an if statement to 
check it there's a camera selected.
If not, create a new camera. 
"""
print "/////////////////////////////"
print "//    CUBIC QTVR EXPORT    //"
print "/////////////////////////////"
print
print "making the qtvr camera..."
# create new ortho camera data
c = Camera.New('persp', 'qtvrcamera')
# set lens value    
c.lens = 16.0
# get current Scene               
cur = Scene.getCurrent()
# make camera object     
ob = Object.New('Camera')
# link camera data with this object    
ob.link(c)
# link object into scene                  
cur.link(ob)
# make this camera the active                 
cur.setCurrentCamera(ob)
i = Blender.Ipo.New('Object', 'qtvripo')
ob.setIpo(i)
checkAttributes(i)
# move to position 1
print "setting the camera position to 1..."
camPos1 ()

################################################################################
#	E N D  S C R I P T
################################################################################
Take care and THANKS! :shock:

an-toni
Posts: 0
Joined: Wed Mar 17, 2004 5:20 pm

Post by an-toni »

any luck yet?

i suppose you did check http://www.blender.org/modules/document ... #getTriple for hints about what kind of data there is? (by e.g. making a IPO by hand first and seeing what that gives..?)

also, as you already set the camera orientation there, could you not just render the images from the script without doing the IPO at all? at least the new Render module seems to make everything like that possible, http://www.blender.org/modules/document ... tml#render

~Toni

Post Reply