[Bf-python] Timeline.marks
Toni Alatalo
antont at kyperjokki.fi
Tue Oct 25 15:05:30 CEST 2005
On Monday 24 October 2005 18:19, Ken Hughes wrote:
> If it's not urgent now, then suggest we discuss your proposed changes
> here. I'd be willing to code whatever we decide on.
i figured it would be useful to see a concrete example of usage. this is the
code that Basse put together for camera changing (he is not really a
programmer but finds his ways around and likes his while loops :) .. so in
fact we are using the markers to get 'ranges', that is time 'areas' where
certain conditions are to take place, like active camera being a certain one
or a certain subtitle showed. as there are no typed markers, the guys simply
prefix the markers to separate camera-changing and subtitling ones.
note that there are still issues with DAG (any news about when those will be
fixed?), so ppl are doing tricks like 'tab-tab' (enter/exit editmode) to get
things working.. and we just found out that doing that trick with the Window
module 'caused a frame in render to be from the UI .. luckily
Object.makeDisplayList() (which forces a DAG update?) seems to fix those for
us now
anyhow back to the timeline api, this is how we use it:
import Blender
from Blender import *
import math
cam_prefix = "cam"
empty_ratio = 35.0
y_offset = 0.0
z_offset = 0.0
scn = Scene.GetCurrent()
tline = scn.getTimeLine()
cur = Blender.Get('curframe')
rnd = scn.getRenderingContext()
marks = []
i = rnd.startFrame()
tl = tline.getMarked()
# change the marker list type
i = 0
for i in range(0, len(tl), 2):
if tl[i+1][:len(cam_prefix)] == cam_prefix:
marks.append([tl[i], tl[i+1]])
marks.sort()
# add one extra dummy entry
marks.append(['end', 30000])
curCam = scn.getCurrentCamera()
# travel through markers and do a switch if needed
i = 0
while i < len(marks):
if (cur >= marks[i][0]) and (cur < marks[i+1][0]):
if curCam.name != marks[i][1]:
print "switched to " + marks[i][1]
camobj = Object.Get(marks[i][1])
scn.setCurrentCamera(camobj)
sizeadj = empty_ratio / camobj.getData().getLens()
subObj = Object.Get('Fempty')
subObj.loc = camobj.loc
subObj.rot = camobj.rot
subObj.setSize(sizeadj,sizeadj,1)
# to = Object.Get('Font')
subObj.makeDisplayList()
# Window.EditMode(1)
# Window.EditMode(0)
Redraw(-1)
i = i+1
so ideas and implementations for an API that would make that nice are
welcome :)
> Ken
~Toni
More information about the Bf-python
mailing list