-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAdjustRenderFrame.ms
More file actions
171 lines (145 loc) · 5.46 KB
/
AdjustRenderFrame.ms
File metadata and controls
171 lines (145 loc) · 5.46 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
-------------------------------------------------------------------------------
-- AdjustRenderFrame.ms
-- By Ilya Floussov (ilya@conceptfarm.ca)
-- Dec 16 2019
-- Adjusts 3dsmax render frame by changing camera's lens and perspective offset
-- a few issues vertical shift
-------------------------------------------------------------------------------
macroScript AdjustRenderFrame
category:"ilya_s Scripts"
tooltip:"Adjust Render Frame"
buttontext:"AdjRenFrame"
(
global keep_btn
fn camera_filter o =
(
ClassOf o == Physical
)
fn calcShift opt Wo Wn So =
(
/*
Wn = 740.0
Wo = 640.0
So = -10.0
*/
local Sn = 0
if (opt == 2) then (Sn = 100.0 * ((((Wn-Wo)/2.0) + (So/100.0 * Wo)) / Wn))
else if (opt == 0) then (Sn = 100.0 * ((((Wo-Wn)/2.0) + (So/100.0 * Wo)) / Wn))
else (Sn = So * Wo / Wn)
return Sn
)
renderSceneDialog.close()
rollout AdjustWidth "AdjustRenderFrame v 2.0" width:350
(
pickbutton choosecam "Pick Camera" align:#center width:140 height:20 filter:camera_filter
radiobuttons keep_btn "Keep: " labels:#("TL","TC", "TR","ML","MC","MR","BL","BC","BR") default:5 columns:3
spinner old_F_spin "Old Focal:" type:#float range:[0.01,5000,0.01] enabled:false across:2
spinner new_F_spin "New Focal:" type:#float range:[0,900000000,0] enabled:false
spinner old_W_spin "Old Width:" type:#float range:[0,900000000,0] enabled:false across:2
spinner old_H_spin "Old Height:" type:#float range:[0,900000000,0] enabled:false
spinner old_Sh_spin "Old H Shift:" type:#float range:[-900000000,900000000,0] enabled:false across:2
spinner old_Sv_spin "Old V Shift:" type:#float range:[-900000000,900000000,0] enabled:false
spinner new_W_spin "New Width:" type:#integer range:[0,500000,0] enabled:false across:2
spinner new_H_spin "New Height:" type:#integer range:[0,500000,0] enabled:false
spinner new_Sh_spin "New H Shift:" type:#float range:[-900000000,900000000,0] enabled:false across:2
spinner new_Sv_spin "New V Shift:" type:#float range:[-900000000,900000000,0] enabled:false
button Apply_btn "Apply" align:#center width:140 height:20 enabled:false
on AdjustWidth open do
(
if classof $ == Physical then
(
choosecam.text = $.name
old_F_spin.value = $.focal_length_mm
old_Sh_spin.value = $.horizontal_shift
old_W_spin.value = renderWidth
old_H_spin.value = renderHeight
new_W_spin.value = renderWidth
new_H_spin.value = renderHeight
new_W_spin.enabled = true
new_H_spin.enabled = true
)
else
(
camerapick = selectByName title:"Please select a single a Physical Camera" buttonText:"This one!" filter:camera_filter showHidden:true single:true
if classof camerapick == Physical then
(
select camerapick
choosecam.text = $.name
old_F_spin.value = $.focal_length_mm
old_W_spin.value = renderWidth
old_H_spin.value = renderHeight
old_Sh_spin.value = $.horizontal_shift
new_W_spin.value = renderWidth
new_H_spin.value = renderHeight
new_W_spin.enabled = true
new_H_spin.enabled = true
)
else
(
messagebox "Please pick a single Physical :)"
)
)
)
on choosecam picked obj do
(
select obj
choosecam.text = obj.name
old_F_spin.value = $.focal_length_mm
old_W_spin.value = renderWidth
new_W_spin.value = renderWidth
new_W_spin.enabled = true
)
on new_W_spin changed spinvalue do
(
spinvalue = new_W_spin.value
new_F_spin.value = (old_W_spin.value/new_W_spin.value)*old_F_spin.value
columnState = ((mod (keep_btn.state-1) 3) + 0) as integer
--rowState = ((keep_btn.state - 1) / 3) as integer
rowState = abs ((keep_btn.state-1)/3 - 2)
new_Sh_spin.value = calcShift columnState old_W_spin.value new_W_spin.value old_Sh_spin.value
new_Sv_spin.value = calcShift rowState old_H_spin.value new_H_spin.value old_Sv_spin.value
Apply_btn.enabled = true
)
on new_H_spin changed spinvalue do
(
spinvalue = new_H_spin.value
new_F_spin.value = (old_W_spin.value/new_W_spin.value)*old_F_spin.value
columnState = ((mod (keep_btn.state-1) 3) + 0) as integer
--rowState = ((keep_btn.state - 1) / 3) as integer
rowState = abs ((keep_btn.state-1)/3 - 2)
new_Sh_spin.value = calcShift columnState old_W_spin.value new_W_spin.value old_Sh_spin.value
new_Sv_spin.value = calcShift rowState old_H_spin.value new_H_spin.value old_Sv_spin.value
Apply_btn.enabled = true
)
on keep_btn changed state do
(
columnState = ((mod (keep_btn.state-1) 3) + 0) as integer
rowState = ((keep_btn.state - 1) / 3) as integer
print columnState
print rowState
new_Sh_spin.value = calcShift columnState old_W_spin.value new_W_spin.value old_Sh_spin.value
new_Sv_spin.value = calcShift rowState old_H_spin.value new_H_spin.value old_Sv_spin.value
)
on Apply_btn pressed do
(
if classof $ == Physical then
(
with undo on
(
$.focal_length_mm = new_F_spin.value
renderWidth = new_W_spin.value
renderHeight = new_H_spin.value
$.horizontal_shift = new_Sh_spin.value
$.vertical_shift = new_Sv_spin.value
)
destroydialog AdjustWidth
)
else
(
choosecam.text = "Pick"
messagebox "Please pick again a Physical Camera"
)
)
)
createdialog AdjustWidth fgcolor:[220,150,0] style:#(#style_toolwindow, #style_sysmenu) pos:[10,100]
)