So this is to be checked …
Animate a camera in 2.49 and use old octam …
Animate the camera in 2.58 the SAME! way.
put the code into a text of blender and execute see file(NEWOctaneCamera.txt) and console
compare if ok!
#PKHG octane_pkhg.py, no warranty, change as you wish 4 aug 2011 version 0.1
#import Blender
#from Blender.BGL import *
#from Blender import Mesh, Scene, Window, sys, Image, Draw, Material, Mathutils, Ipo
import bpy
#import BPyMesh
#import BPyObject
#import BPySys
#import BPyMessages
from sys import *
import os, subprocess
from string import *
from mathutils import Vector, Matrix, Euler
from math import degrees
print("=========================pkhg=======")
scene= bpy.context.scene
#???ostype = platform
GLOBALS = {}
defaultDir=''
blendFileName=''
## an gui exporter needed???? PKHG TODO
#octaneCameraMotion=Draw.Create(0)
#octaneNativeUnitSize=Draw.Create(3)
#octaneActiveCamera=Draw.Create('')
#octaneAnimationStart=Draw.Create(1)
#octaneAnimationEnd=Draw.Create(250)
#octaneAnimationStep=Draw.Create(1)
'''
def matrix_vect(mat,vec):
vecr = [0.,0.,0.,0.,0.]
for i in range(4):
for j in range(4):
vecr[i] += vec[j] * mat[j][i]
return vecr
'''
def matrix_vect(mat,vec):
return mat * Vector(vec)
def rotate90x(vect):
return Vector([vect[0],vect[2],-vect[1]]) #PKHG ???
#######3#rotation and location assumed to exist! check it the animation ! PKHG
def buildWorldMatrix(fcurves,frame):
fRotation = []
for fcu in fcurves:
if fcu.data_path == 'rotation_euler': #'location':
fRotation.append(fcu)
fLocation = []
for fcu in fcurves:
if fcu.data_path == 'location': #'location':
fLocation.append(fcu)
position = Vector([fLocation[0].evaluate(frame), fLocation[1].evaluate(frame), fLocation[2].evaluate(frame),1])
euler = Euler([fRotation[0].evaluate(frame), fRotation[1].evaluate(frame), fRotation[2].evaluate(frame)])
meu = euler.to_matrix()
meu4 = meu.to_4x4()
meu4[3]= position
return(meu4)
octaneNativeUnitSize = 3
def write_command(filename,scene_frames):
file = open(filename,"w")
# print("dbg file = ", file)
#Set the unit factor
unitFactor = {
0:0.001,
1:0.01,
2:0.1,
3:1,
4:10,
5:100,
6:1000,
7:0.0254,
8:0.3048,
9:0.9144,
10:201.168,
11:1609.344
#pkhg }[octaneNativeUnitSize.val]
}[octaneNativeUnitSize]
# scene_frames = xrange(octaneAnimationStart.val, octaneAnimationEnd.val+1,octaneAnimationStep.val)
# scene_frames = 10 #test from 1 to 21 #now parameter! PKHG
camera_param = ''
#not needed??? axes = ['x','y','z']
# octaneActiveCamera.val=Scene.GetCurrent().getCurrentCamera().getName()
#pkhg ???
camera = bpy.data.objects['Camera'] #??? Blender.Object.Get(octaneActiveCamera.val)
# camera = scene.objects.camera#Scene.GetCurrent().getCurrentCamera()
# print(dir(camera))
angle = degrees(camera.data.angle) #WAS radians??!! Check PKHG!
######################################3
cameradata = camera.animation_data.action.fcurves
for frame in range(scene_frames): # in scene_frames ???
# Blender.Set('curframe', frame)
# cameradata = camera.getData()
# matrix = camera.mat
# matrix = camera.matrix_world
matrix = buildWorldMatrix(cameradata, frame)
position = rotate90x(matrix_vect(matrix,[0.0,0.0,0.0,1.0]))
# print("position", position)
target = rotate90x(matrix_vect(matrix,[0.0,0.0,-1.0,1.0]))
up = rotate90x(matrix_vect(matrix,[0.0,1.0,0.0,0.0]))
for i in range(3):
camera_param += "#%f" % (position[i]*unitFactor)
for i in range(3):
camera_param += "#%f" % (target[i]*unitFactor)
camera_param += "#%f" % angle #???????????cameradata.angle CHECK! PKHG
for i in range(3):
camera_param += "#%f" % (up[i]*unitFactor)
new=camera_param.replace('#', '', 1)
file.write(new)
file.write("
")
print("new",new) # see console! pKHG
camera_param = ""
file.close()
octcam = 'NEWOctaneCamera.txt'
write_command(octcam, 3) #Three frames change?! PKHG