-
Notifications
You must be signed in to change notification settings - Fork 0
/
PG.Render.ms
110 lines (86 loc) · 2.53 KB
/
PG.Render.ms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
struct PGRenderDef (
uiInstance, startF, endF, outputFile, nextFrame,
fn existFile fname = ((getfiles fname).count != 0),
fn findNextFrame = (
this.nextFrame = undefined
for i = this.startF to this.endF do (
folder = getFilenamePath rendOutputFilename
file = getFilenameFile rendOutputFilename
ext = getFilenameType rendOutputFilename
root = folder + file + i as string
this.outputFile = root + ext
available = (existFile (root + "*")) == false-- check if image or *.lock file exists
if available == true then (
this.nextFrame = i
exit
)
)
),
fn createLock = (
folder = getFilenamePath outputFile
file = getFilenameFile outputFile
createFile (folder+file+".lock")
),
fn removeLock = (
),
fn actualRender = (
this.createLock()
render \
frame:PGRender.nextFrame \
outputfile:PGRender.outputFile \
vfb:false
),
fn preRender = (
print ">> #preRender"
),
fn postRender = (
print ">> #postRender"
this.removeLock()
this.findNextFrame()
if this.nextFrame != undefined then (
fn perform sender evt = (
sender.stop() -- one tick only
dotnet.removeAllEventHandlers sender
PGRender.actualRender()
)
delay= dotnetobject "Windows.Forms.Timer"
delay.Interval=500
dotnet.AddEventHandler delay "Tick" perform
delay.start()
)
else messageBox "No frames to render :)"
),
fn registerCallbacks = (
callbacks.addScript #preRender "PGRender.preRender()" id:#PGCallbackId
callbacks.addScript #postRender "PGRender.postRender()" id:#PGCallbackId
),
fn unRegisterCallbacks = ( callbacks.removeScripts id:#PGCallbackId ),
fn ui = (
rollout PGRenderUi "PG Render" width:240 (
spinner start "Range:" type:#integer width:100 across:2 range:[-99999, 99999, animationRange.start]
spinner end "To:" type:#integer width:80 range:[-99999, 99999, animationRange.end]
button renderBtn "Render!" width:200 height:60
on renderBtn pressed do (
PGRender.startF = start.value
PGRender.endF = end.value
PGRender.registerCallbacks()
PGRender.postRender() -- initailize render loop
)
on PGRenderUi open do ()
on PGRenderUi close do (
PGRender.unRegisterCallbacks()
)
)
uiInstance = createDialog PGRenderUi --pos:[1200, (random 300 1200)]
uiInstance = PGRenderUi
),
fn open = ( ui() ),
fn close = ( if uiInstance != undefined do (
destroyDialog uiInstance
uiInstance = undefined
))
)
clearListener()
try( PGRender.close() )catch()
global PGRender = PGRenderDef()
PGRender.open()