Hey everyone
I am working in a script for creating and rendering an animation in 2.49 but I can’t get it to work. What happens is that it creates a *.avi which is only 1 second (or frame) long.
Could anyone please have a look through the code amd see if they find anything wrong?
Thanks a lot guys
if blend_filename != "No File" and results_filename != "No File":
if len(link_obj) == 0:
Draw.PupMenu("There Are No Linked Objects%t")
else:
Window.WaitCursor(1)
curr_scn = Scene.GetCurrent()
render_info = curr_scn.getRenderingContext() #: Access Render Data
Scene.Render.EnableDispWin() #: Render in Render Window
render_info.extensions = 1
render_info.renderPath = "//ANIMATION/"
render_info.sizePreset(Scene.Render.PC)
render_info.sizeX = 640
render_info.sizeY = 480
render_info.imageType = Scene.Render.AVIJPEG
ntime_ini = ANIMATION_MENU['START_INSTANT'].val
ntime_fin = ANIMATION_MENU['END_INSTANT'].val
object_ID = list()
for i in range(0,len(link_obj)):
aux = link_obj[i]
object_ID.append(aux[1])
ipo = Ipo.New('Object',str(aux[1]))
obj = Object.Get(aux[0])
ipo.addCurve('LocX')
ipo.addCurve('LocY')
ipo.addCurve('LocZ')
ipo.addCurve('RotX')
ipo.addCurve('RotY')
ipo.addCurve('RotZ')
obj.setIpo(ipo)
if len(camera2obj) != 0:
ipo = Ipo.New('Object',camera2obj[1])
obj = Object.Get(camera2obj[0])
ipo.addCurve('LocX')
ipo.addCurve('LocY')
ipo.addCurve('LocZ')
obj.setIpo(ipo)
render_info.fps = ANIMATION_MENU['STEP'].val
render_info.sFrame = ntime_ini
render_info.eFrame = ntime_ini + (ntime_fin - ntime_ini) * render_info.fps
print render_info.fps
print ntime_ini
print render_info.eFrame
print object_ID
print link_obj
for time in range(ntime_ini,ntime_fin + 1):
for i in range(0,len(object_ID)):
transf_info = info_results_lines[object_ID[i] + (time - 1) * nbodies].split()
#: Information About the Elements of the Transformation Matrix
A11 = float(transf_info[0])
A12 = float(transf_info[4])
A13 = float(transf_info[8])
A21 = float(transf_info[1])
A22 = float(transf_info[5])
A23 = float(transf_info[9])
A31 = float(transf_info[2])
A32 = float(transf_info[6])
A33 = float(transf_info[10])
#: Euler Angles
#psi = acos(A33) z
#theta = atan(-A13/A23) x
#psi = atan(A31/A32) z
#: Bryant Angles
dRotY = asin(A13) #: y
dRotX = atan(-A23/A33) #: x
dRotZ = atan(-A12/A11) #:z
#theta = (180 * theta / pi) / 10
#phi = (180 * phi / pi) / 10
#psi = (180 * psi / pi) / 10
ry = -1*float(transf_info[12])
rx = float(transf_info[13])
rz = float(transf_info[14])
ipo = Ipo.Get(str(object_ID[i]))
#print str(object_ID[i])
#print ipo
for i in range(0,len(link_obj)):
aux = link_obj[i]
ipo = Ipo.Get()
obi = Blender.Object.Get(str(aux[0]))
obi.setLocation(rx, ry, rz)
obi.RotX=dRotX
obi.RotY=dRotY
obi.RotZ=dRotZ
ipo = obi.getIpo()
ipo.getCurve('LocX').append((ntime_ini + time * render_info.fps,rx))
ipo.getCurve('LocY').append((ntime_ini + time * render_info.fps,ry))
ipo.getCurve('LocZ').append((ntime_ini + time * render_info.fps,rz))
ipo.getCurve('RotX').append((ntime_ini + time * render_info.fps,dRotX))
ipo.getCurve('RotY').append((ntime_ini + time * render_info.fps,dRotY))
ipo.getCurve('RotZ').append((ntime_ini + time * render_info.fps,dRotZ))
print ipo
print(str(aux[1]))
Redraw()
render_info.renderAnim()
Scene.Render.CloseRenderWindow() #: Close Rendering Window
results_animation = "Created"
results_path = render_info.getRenderPath()
Window.WaitCursor(0)