This repository has been archived by the owner on Oct 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
trailer.py
77 lines (61 loc) · 2.62 KB
/
trailer.py
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
# for feedback, please post here: https://github.com/santosh/.nuke/issues
# using naming convention, like i b n k for int, bool, node, knob
strRepeat = nuke.getInput("Enter number of copies: ", "10")
iRepeat = int(strRepeat) # probably gonna be replaced by knob input
bFirstLoop = True
# packing into group {{{
nGroup = nuke.nodes.Group(name="Trails")
nGroup.begin()
## GUI COMPONENETS BEGIN
kX_Trans = nuke.Double_Knob("x_trans", "Translate X:")
kX_Trans.setRange(-50.,50.)
kX_Trans.setValue(20.)
nGroup.addKnob(kX_Trans)
kY_Trans = nuke.Double_Knob("y_trans", "Translate Y:")
kY_Trans.setRange(-50.,50.)
kY_Trans.setValue(20.)
nGroup.addKnob(kY_Trans)
kX_Rot = nuke.Double_Knob("rot", "Rotate:")
kX_Rot.setRange(-20.,20.)
kX_Rot.setValue(0.)
nGroup.addKnob(kX_Rot)
kX_Scale = nuke.Double_Knob("scale", "Scale:")
kX_Scale.setRange(-1.,2.)
kX_Scale.setValue(1.)
nGroup.addKnob(kX_Scale)
## GUI COMPONENTS END
# calculate center of the project dimension
# need to select a node, there's no direct way
# Viewer1 is only generic thing in every project
# nuke.toNode("Viewer1").setSelected(True)
# projwidth = nuke.selectedNode().format().width()
# projheight = nuke.selectedNode().format().height()
nInput = nuke.nodes.Input() #input node is gateway into the gizmo
nDot = nuke.nodes.Dot()
nDot.setInput(0, nInput) # input comes to a Dot node
for i in range(iRepeat):
# translating by 20 in x and y
nTrans = nuke.nodes.Transform(name="transform" + str(i),
translate="parent.x_trans parent.y_trans",
rotate = "parent.rot",
scale = "parent.scale",
center = "960 540" # this one is for HD, calculate from project setting instead
# TODO: center = "{x} {y}".format(x=projwidth/2, y=projheight/2)
)
# create a merge node
nMerge = nuke.nodes.Merge2(name="merge" + str(i))
# set first input of merge to translated image
nMerge.setInput(1, nTrans)
if bFirstLoop: # if this is the first loop
bFirstLoop = False # disable the logic, so below commands execute only once
nTrans.setInput(0, nDot) # connect tranlate node to dot
nMerge.setInput(0, nDot) # then merge to dot
else: # do the same thing, but with previous merges
nTrans.setInput(0, nPrevMerge)
nMerge.setInput(0, nPrevMerge)
# nMerge becomes nPrevMerge for next Merge2
nPrevMerge = nMerge
nOutput = nuke.nodes.Output()
nOutput.setInput(0, nMerge) # output node is attached to last Merge's output
nGroup.end()
# }}} group ends