Save and Load Camera Animation
This consists of two scripts. The first exports camera position data into a CSV file. The second loads a CSV file into Vue an applies it to the camera. Useful for moving camera animations between scenes..
Save Camera 0.2 (3k Zip Archive)
Python Code - Save Camera Animation
#******************************************************
# Save Camera Data to a CSV file
#
# - savecameradata.py
# - By Mark Caldwell
# - Version 0.1
# - 12th May 2006
# - Copyright Mark Caldwell 2006
# - Tested with Vue 5 Infinite 5.09 and Vue 6 Infinite Pre Release
#
# How to use in 4 easy steps
#
# 1. Download this file onto your computer
#
# 2. Change Path to Saved File if required
#
# 3. Then run script and wait for it to work
# To run it go to Python -> Run Python Script
# Then locate the file on your computer
#
# 4. Camera path and rotation are now stored in the CSV
# File and can be loaded using loadcameradata.csv
#
#******************************************************
#------------------------------------------------------------------
# Filename to Load Data From - Change if different on your computer
#------------------------------------------------------------------
filename="C:\Program Files\e-on software\Vue 5 Infinite\Python\Scripts\impworks\utils\camera.csv"
#----------------------------------------------
# Internal Variables Set Up: Don't alter these
#----------------------------------------------
end=0
frames=[]
currentframe=0
oldframe=currentframe+1
#----------------------------------------------
# Find the camera
#----------------------------------------------
SelectByType(VuePython.VUEBasicObject.VOT_Camera)
cam = GetSelectedObjectByIndex(0)
#----------------------------------------------
# Find the first key frame if it comes before frame 0
#----------------------------------------------
SetCurrentFrame(currentframe)
while end==0:
PreviousKeyFrame ()
currentframe=CurrentFrame ()
if currentframeoldframe:
oldframe=currentframe
pos=cam.Position()
rot=cam.GetRotationAngles()
frames.append([currentframe,pos[0],pos[1],pos[2],rot[0],rot[1],rot[2]])
else:
end=1
#----------------------------------------------
# Write out camera data to file
#----------------------------------------------
output=open (filename,'w')
for f in frames:
line=str(f[0])+','+str(f[1])+','+str(float(f[2]))+','+str(float(f[3]))+','+str(float(f[4]))+','+str(float(f[5]))+','+str(float(f[6]))+'\n'
print line
output.write(line)
output.close()
#----------------------------------------------
# End of Script
#----------------------------------------------
Python Code - Load Camera Animation
#******************************************************
# Loads Camera Data from a CSV file
#
# - loadcameradata.py
# - By Mark Caldwell
# - Version 0.2
# - 18th May 2006
# - Copyright Mark Caldwell 2006
# - Tested with Vue 5 Infinite 5.09 and Vue 6 Infinite Pre Release
#
# How to use in 3 easy steps
#
# 1. Download this file onto your computer
#
# 2. Change Path to Saved File if required and camera to be edited
#
# 3. Then run script and wait for it to work
# To run it go to Python -> Run Python Script
# Then locate the file on your computer
#
#******************************************************
#-------------------------------------------------------------------
# Change if different on your computer
#-------------------------------------------------------------------
#Filename to Load Data From - Change if different on your computer
filename="C:\Program Files\e-on software\Vue 5 Infinite\Python\Scripts\impworks\utils\camera.csv"
# Animate a current camera or make a new camera.Set to 0 to create a new camera or the index of a camera in the scene
cam_selection_method=0
#----------------------------------------------
# End of Changeable Parts
#----------------------------------------------
frames=[]
#----------------------------------------------
# Select or create the Camera
#----------------------------------------------
if cam_selection_method==0:
cam=StoreCamera ()
else:
SelectByType(VuePython.VUEBasicObject.VOT_Camera)
cam = GetSelectedObjectByIndex(0)
SelectByType(VuePython.VUEBasicObject.VOT_Camera)
cam = GetSelectedObjectByIndex(0)
#----------------------------------------------
# Read Camera Data in from CSV file
#----------------------------------------------
file=open(filename,'r')
while 1:
line = file.readline()
if not(line):
break
b=line.split(',')
frames.append([float(b[0]),float(b[1]),float(b[2]),float(b[3]),float(b[4]),float(b[5]),float(b[6])])
file.close()
#----------------------------------------------
# Apply animation
#----------------------------------------------
for data in frames:
SetCurrentFrame (data[0])
cam.SetPosition(data[1],data[2],data[3])
cam.SetRotationAngles(data[4],data[5],data[6],true)
#----------------------------------------------
# End of Script
#----------------------------------------------
Need Help with Python?
If you need an introduction to using Vue Python scripts I've written a short tutorial Vue Python for Beginners.
