-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender.lua
More file actions
189 lines (159 loc) · 6.35 KB
/
render.lua
File metadata and controls
189 lines (159 loc) · 6.35 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
require( "globals" )
local controls = require( "controls" )
local skin = require( "skin" )
local settings = require( "settings" )
local render = {}
function render.stack( pass )
pass:draw( skin.mdl_case, 0, 0, 0 )
pass:draw( skin.mdl_amp, 0, 0, 0 )
local next_y = 0
if settings.session.show_eq then
next_y = 0 - metrics.case_height - metrics.feet_height
pass:draw( skin.mdl_case, 0, next_y, 0 )
pass:draw( skin.mdl_eq, 0, next_y, 0 )
end
if settings.session.show_pl then
next_y = settings.session.show_eq and 2 * (0 - metrics.case_height) - (2 * metrics.feet_height) or 0 - metrics.case_height - metrics.feet_height
pass:draw( skin.mdl_case, 0, next_y, 0 )
pass:draw( skin.mdl_pl, 0, next_y, 0 )
end
-- color LEDs
-- render.led( pass, "amp_led_eq" )
if winamp_info.eq == 1 then render.led( pass, "amp_led_eq" ) end
if winamp_info.pl == 1 then render.led( pass, "amp_led_pl" ) end
if winamp_info.shuffle == 1 then render.led( pass, "amp_led_shuffle" ) end
if winamp_info.repeatval == 1 then render.led( pass, "amp_led_repeat" ) end
-- color sliders
-- NOTE Add EQ sliders
render.tint_slider( pass, "amp_slider_vol", "amp_slider_vol_bg" )
render.tint_slider( pass, "amp_slider_pan", "amp_slider_pan_bg" )
-- NOTE test render khz
font:setPixelDensity( metrics.pixel_density_khz )
local x, y, z = controls[ "amp_lcd_khz_bg" ].pos:unpack()
local dx, dy, dz = controls[ "amp_lcd_khz_bg" ].dim:unpack()
local tex = controls[ "amp_lcd_khz_bg" ].tex
local tex_pass = controls[ "amp_lcd_khz_bg" ].pass
tex_pass:reset()
tex_pass:setProjection( 1, mat4():orthographic( tex_pass:getDimensions() ) )
tex_pass:setColor( 0, 1, 0, 1 )
local tdx, tdy = tex:getDimensions()
tex_pass:text( tostring( winamp_info.track_khz ), tdx / 2, tdy / 2, 0, 1 )
pass:setMaterial( tex )
pass:plane( x, y, z + 0.001, dx, dy )
pass:setMaterial()
passes[ #passes + 1 ] = tex_pass
-- NOTE test render kbps
font:setPixelDensity( metrics.pixel_density_kbps )
local x, y, z = controls[ "amp_lcd_kbps_bg" ].pos:unpack()
local dx, dy, dz = controls[ "amp_lcd_kbps_bg" ].dim:unpack()
local tex = controls[ "amp_lcd_kbps_bg" ].tex
local tex_pass = controls[ "amp_lcd_kbps_bg" ].pass
tex_pass:reset()
tex_pass:setProjection( 1, mat4():orthographic( tex_pass:getDimensions() ) )
tex_pass:setColor( 0, 1, 0, 1 )
local tdx, tdy = tex:getDimensions()
tex_pass:text( tostring( winamp_info.track_kbps ), tdx / 2, tdy / 2, 0, 1 )
pass:setMaterial( tex )
pass:plane( x, y, z + 0.001, dx, dy )
pass:setMaterial()
passes[ #passes + 1 ] = tex_pass
-- NOTE test get song title
local hwnd = find_window( "Winamp v1.x", nil )
local text_length = user32.GetWindowTextLengthA( hwnd )
local buffer_size = text_length + 1
local title_buffer = ffi.new( "char[?]", buffer_size )
user32.GetWindowTextA( hwnd, title_buffer, buffer_size )
local title_string = ffi.string( title_buffer, text_length )
local x, y, z = controls[ "amp_lcd_info_bg" ].pos:unpack()
local dx, dy, dz = controls[ "amp_lcd_info_bg" ].dim:unpack()
local tex = controls[ "amp_lcd_info_bg" ].tex
local tex_pass = controls[ "amp_lcd_info_bg" ].pass
tex_pass:reset()
tex_pass:setProjection( 1, mat4():orthographic( tex_pass:getDimensions() ) )
tex_pass:setColor( 0, 1, 0, 1 )
local tdx, tdy = tex:getDimensions()
font:setPixelDensity( metrics.pixel_density_title )
local w = font:getWidth( title_string )
if w > tdx then
if timer_scroll_title:get_elapsed() > 0.2 then
timer_scroll_title:reset()
if scroll_title_amount > w then
scroll_title_amount = 0
end
scroll_title_amount = scroll_title_amount + 30
end
tex_pass:text( title_string, (w / 2) - scroll_title_amount, tdy / 2, 0, 1 )
tex_pass:text( title_string, (w + (w / 2)) - scroll_title_amount, tdy / 2, 0, 1 )
else
scroll_title_amount = 0
tex_pass:text( title_string, (w / 2) - scroll_title_amount, tdy / 2, 0, 1 )
end
pass:setMaterial( tex )
pass:plane( x, y, z + 0.001, dx, dy )
pass:setMaterial()
passes[ #passes + 1 ] = tex_pass
-- NOTE test render label
font:setPixelDensity( metrics.pixel_density_monostereo )
local col1, col2 = { 0.8, 0.8, 0.8 }, { 0, 1, 0 }
if winamp_info.mono_stereo == 1 then
col1, col2 = col2, col1
end
local x1, y1, z1 = controls[ "amp_label_mono" ].pos:unpack()
local dx1, dy1, dz1 = controls[ "amp_label_mono" ].dim:unpack()
local tex1 = controls[ "amp_label_mono" ].tex
local tex_pass1 = controls[ "amp_label_mono" ].pass
tex_pass1:reset()
tex_pass1:setProjection( 1, mat4():orthographic( tex_pass1:getDimensions() ) )
tex_pass1:setColor( col1 )
local tdx1, tdy1 = tex1:getDimensions()
tex_pass1:text( "mono", tdx1 / 2, tdy1 / 2, 0, 1 )
local x2, y2, z2 = controls[ "amp_label_stereo" ].pos:unpack()
local dx2, dy2, dz2 = controls[ "amp_label_stereo" ].dim:unpack()
local tex2 = controls[ "amp_label_stereo" ].tex
local tex_pass2 = controls[ "amp_label_stereo" ].pass
tex_pass2:reset()
tex_pass2:setProjection( 1, mat4():orthographic( tex_pass2:getDimensions() ) )
tex_pass2:setColor( col2 )
local tdx2, tdy2 = tex2:getDimensions()
tex_pass2:text( "stereo", tdx2 / 2, tdy2 / 2, 0, 1 )
pass:setBlendMode( "alpha" )
pass:setShader()
pass:draw( tex1, x1, y1, z1 + 0.001, dx1, dy1 )
passes[ #passes + 1 ] = tex_pass1
pass:draw( tex2, x2, y2, z2 + 0.001, dx2, dy2 )
passes[ #passes + 1 ] = tex_pass2
end
function render.led( pass, led_id )
local parent = controls[ led_id ].parent
local x, y, z = controls[ led_id ].pos:unpack()
local px, py, pz = controls[ parent ].model:getNodePosition( parent )
local dx, dy, dz = controls[ led_id ].dim:unpack()
pass:setColor( 0, 1, 0 )
pass:plane( x, y, pz + 0.0026, dx, dy )
end
function render.tint_slider( pass, slider_id, bg_id )
local min = controls[ slider_id ].min
local max = controls[ slider_id ].max
local val, y, z = controls[ slider_id ].model:getNodePosition( slider_id )
local t = (val - min) / (max - min)
if slider_id == "amp_slider_pan" then
t = math.abs( 2 * t - 1 );
end
local R = t
local G = 1 - t
local B = 0
local x, y, z = controls[ bg_id ].pos:unpack()
local dx, dy, dz = controls[ bg_id ].dim:unpack()
pass:setColor( R, G, B, 1 )
pass:plane( x, y, z + 0.001, dx, dy )
pass:setColor( 1, 1, 1, 1 )
end
function render.set_environment( pass )
pass:setFaceCull( "back" )
pass:setBlendMode()
pass:skybox( skybox )
pass:setShader( shader )
pass:send( "cubemap", environmentMap )
pass:send( "sphericalHarmonics", sphericalHarmonics )
end
return render