1
2
3
4
5
6
7
8
9
10
11
12from pyfbsdk import *
13from pyfbsdk_additions import *
14from sys import *
15import os
16import traceback
17
18global lFp
20
21
22
23def BrowseCallback(control, event):
24
25
26
27 lFp.Caption = "Select the shot track definition file:"
28 lFp.Style = FBFilePopupStyle.kFBFilePopupOpen
29 lFp.Filter = "*.txt"
30 if os.path.isdir(os.path.splitext(traceback.extract_stack()[-1][0])[0]):
31 lFp.Path = os.path.normpath(os.path.splitext(traceback.extract_stack()[-1][0])[0])
32 else:
33 lFp.Path = os.path.normpath(os.path.dirname(traceback.extract_stack()[-1][0]))
34
35 lRes = lFp.Execute()
36
37 if lRes:
38 eButt.Text = os.path.join(lFp.Path,lFp.FileName)
39
40def SetupCallback(control, event):
41 try:
42 f=open(os.path.join(lFp.Path,lFp.FileName), 'r')
43 shotInfoFile = f.readlines()
44 f.close()
45
46 shotCnt = len(shotInfoFile)
47 counter = 1
48 for shotInfo in shotInfoFile:
49
50 shots = shotInfo.split()
51 (shotName,shotStart,shotEnd) = shots
52 iShotStart =
int(shotStart)
53 iShotEnd =
int(shotEnd)
54 if shotInfoFile[0] == shotInfo:
55 completeShotStart = iShotStart
56
57 if shotInfoFile[shotCnt - 1] == shotInfo:
58 completeShotEnd = iShotEnd
59
60
61 lCam = FBCamera (shotName)
62 lCam.Visible = True
63 lCam.Show = True
64 lNull = FBModelNull (shotName + "_INT")
65 lCam.Interest = lNull
66
67
68
69 lTrackContainer =
FBStory().RootEditFolder.Tracks
70 lastTrack=0
71 lTrack=None
72 for Track in lTrackContainer:
73 if Track.Label =="Shot Track":
74 lTrack=Track
75 clipStart =
FBTime(0,0,0,iShotStart)
76 if lTrack:
77 lClip = FBStoryClip (lCam, lTrack, clipStart)
78 lClip.Start =
FBTime(0,0,0,iShotStart)
79 lClip.Stop =
FBTime(0,0,0,iShotEnd)
80 if lastTrack<iShotEnd: lastTrack=iShotEnd
81
82
83 if backPlate.State == 1:
84 if counter < 10:
85 vidPath = os.path.join(lFp.Path,
"shot0"+
str(counter)+
".avi")
86 else:
87 vidPath = os.path.normpath(lFp.Path+
"shot" +
str(counter) +
".avi")
89 if lVid.IsValid():
91 lTex.Video = lVid
92 lCam.BackGroundTexture = lTex
93 counter = counter + 1
94
96
97
98
100 lPlayer.LoopStart =
FBTime(0,0,0,completeShotStart)
101 lPlayer.ZoomWindowStart =
FBTime(0,0,0,completeShotStart)
102 lPlayer.LoopStop =
FBTime(0,0,0,completeShotEnd)
103 lPlayer.ZoomWindowStop =
FBTime(0,0,0,completeShotEnd)
104
105
107
109 lModel.Translation = FBVector3d(-10000, 145, 300)
110
112 lModel.Translation = FBVector3d(-10000, 0, 0)
113
115 lModel.Translation = FBVector3d(-5000, 145, 300)
116
118 lModel.Translation = FBVector3d(-5000, 0, 0)
119
121 lModel.Translation = FBVector3d(0, 145, 300)
122
124 lModel.Translation = FBVector3d(0, 0, 0)
125
127 lModel.Translation = FBVector3d(5000, 145, 300)
128
130 lModel.Translation = FBVector3d(5000, 0, 0)
131
133 lModel.Translation = FBVector3d(10000, 145, 300)
134
136 lModel.Translation = FBVector3d(10000, 0, 0)
137
139
140 for lCam in lCameras:
141 if lCam.Name == "Producer Perspective":
142 lCam.FarPlaneDistance = 40000
143 break
145
146 except IOError:
147 FBMessageBox(
"Cannot Continue",
"Unable to read the shot track definition file you selected or you have not selected one.",
"OK",
None,
None )
148 exit
149
150def PopulateLayout(mainLyt):
151
153 l.Caption = "Select the shot track definition file to use:"
154 l.Style = FBTextStyle.kFBTextStyleBold
155 l.WordWrap = True
156
157 x = FBAddRegionParam(5,FBAttachType.kFBAttachLeft,"")
158 y = FBAddRegionParam(5,FBAttachType.kFBAttachTop,"")
159 w = FBAddRegionParam(300,FBAttachType.kFBAttachNone,"")
160 h = FBAddRegionParam(20,FBAttachType.kFBAttachNone,"")
161
162 mainLyt.AddRegion("lab","lab", x, y, w, h)
163 mainLyt.SetControl("lab",l)
164
165
167 e.ReadOnly = True
168 e.Text = ""
169
170 x2 = FBAddRegionParam(5,FBAttachType.kFBAttachLeft,"")
171 y2 = FBAddRegionParam(5,FBAttachType.kFBAttachBottom,"lab")
172 w2 = FBAddRegionParam(220,FBAttachType.kFBAttachNone,"")
173 h2 = FBAddRegionParam(20,FBAttachType.kFBAttachNone,"")
174
175 mainLyt.AddRegion("path","path", x2, y2, w2, h2)
176 mainLyt.SetControl("path",e)
177
178
180 b2.Caption = "Browse..."
181 b2.Justify = FBTextJustify.kFBTextJustifyCenter
182
183 x3 = FBAddRegionParam(225,FBAttachType.kFBAttachLeft,"path")
184 y3 = FBAddRegionParam(5,FBAttachType.kFBAttachBottom,"lab")
185 w3 = FBAddRegionParam(57,FBAttachType.kFBAttachNone,"")
186 h3 = FBAddRegionParam(20,FBAttachType.kFBAttachNone,"")
187
188 mainLyt.AddRegion("but","but", x3, y3, w3, h3)
189 mainLyt.SetControl("but",b2)
190
191 global eButt
192 eButt = e
193 b2.OnClick.Add(BrowseCallback)
194
195
197 cb.Style = FBButtonStyle.kFBCheckbox
198 cb.Caption = "Add backplates to each shot"
199
200 x4 = FBAddRegionParam(60, FBAttachType.kFBAttachLeft, "")
201 y4 = FBAddRegionParam(5, FBAttachType.kFBAttachBottom, "path")
202 w4 = FBAddRegionParam(300,FBAttachType.kFBAttachNone,"")
203 h4 = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
204
205 mainLyt.AddRegion("backp", "backp",x4,y4,w4,h4)
206 mainLyt.SetControl("backp",cb)
207
208 global backPlate
209 backPlate = cb
210
211
213 b3.Caption = "Setup Shots"
214 b3.Justify = FBTextJustify.kFBTextJustifyCenter
215
216 x5 = FBAddRegionParam(40,FBAttachType.kFBAttachLeft,"")
217 y5 = FBAddRegionParam(5,FBAttachType.kFBAttachBottom,"backp")
218 w5 = FBAddRegionParam(100,FBAttachType.kFBAttachNone,"")
219 h5 = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
220
221 mainLyt.AddRegion("shots","shots", x5, y5, w5, h5)
222 mainLyt.SetControl("shots",b3)
223 b3.OnClick.Add(SetupCallback)
224
225 x6 = FBAddRegionParam(20,FBAttachType.kFBAttachRight,"shots")
226 y6 = FBAddRegionParam(5,FBAttachType.kFBAttachBottom,"backp")
227 w6 = FBAddRegionParam(100,FBAttachType.kFBAttachNone,"")
228 h6 = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
229
230def CreateTool():
231
232 global t
233 t = FBCreateUniqueTool("Shot Track Setup Tool")
234 t.StartSizeX = 300
235 t.StartSizeY = 143
236
237 PopulateLayout(t)
238 ShowTool(t)
239
240CreateTool()
Camera switcher.
Definition: pyfbsdk_generated.h:2918
Text edit box.
Definition: pyfbsdk_generated.h:5998
Text label.
Definition: pyfbsdk_generated.h:9829
Player control.
Definition: pyfbsdk_generated.h:13745
Story Management class.
Definition: pyfbsdk_generated.h:17689
Provides access to the underlying system, and the MotionBuilder scene.
Definition: pyfbsdk_generated.h:18771
See samples: HUDElements.py, MaterialAndTexture.py, TextureAnimation.py, VideoInput....
Definition: pyfbsdk_generated.h:19477
Time data structure.
Definition: pyfbsdk_generated.h:19596
Video clip media class.
Definition: pyfbsdk_generated.h:20675
Python built-in int class.
Definition: pyfbsdk.h:59
Python built-in string class.
Definition: pyfbsdk.h:77
FBModel FBFindModelByLabelName(str pModelLabelName)
Find a model in the scene by its label name.
int FBMessageBox(str pBoxTitle, str pMessage, str pButton1Str, str pButton2Str=None, str pButton3Str=None, int pDefaultButton=0, int pScrolledMessage=0)
Dialog popup box.