]>
Dogcows Code - chaz/rasterize/blob - rotate.lua
4334dd8f714da36a755502833e74e648d7c51443
4 -- CS5600 University of Utah
6 -- mcgarvey@eng.utah.edu
9 -- Render a scene multiple times from different angles, like a camera
10 -- rotating around the object of a scene.
12 local size
= {w
= 640, h
= 480}
15 local center
= {x
= 0, y
= 1, z
= 0}
16 local look
= {x
= -2, y
= -1, z
= -2}
22 c 1.0 1.0 0.0 1.0 1.0 0.0 1.0 1.0 0.0
26 c 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1
30 c 0.7 0.3 0.2 0.8 0.2 0.1 0.9 0.2 0.2
34 c 0.1 0.2 0.7 0.1 0.3 0.9 0.2 0.1 0.8
38 c 0.9 0.8 0.9 0.8 0.7 0.9 0.9 0.8 0.7
43 function vec_add(a
, b
)
44 return {x
= a
.x
+ b
.x
, y
= a
.y
+ b
.y
, z
= a
.z
+ b
.z
}
47 function vec_scale(v
, s
)
48 return {x
= v
.x
* s
, y
= v
.y
* s
, z
= v
.z
* s
}
53 local out
= io
.popen("./project2 -", "w")
54 out
:write(string.format([[
62 ]], size
.w
, size
.h
, v
.x
, v
.y
, v
.z
, look
.x
, look
.y
, look
.z
, size
.w
/size
.h
, scene
))
63 local a
, b
= coroutine
.yield()
65 os
.rename("stdin.bmp", string.format("anim%04d.bmp", i
))
78 table.insert(threads
, coroutine
.wrap(render
))
81 for i
= 0,(slices
-1) do
82 local t
= start
+ 2 * i
* math
.pi
/ slices
88 v
= vec_add(vec_scale(v
, distance
), center
)
89 threads
[(i
% jobs
) + 1](i
, v
)
92 for k
,v
in ipairs(threads
) do
93 v(null
) -- clear up any leftover work
This page took 0.035607 seconds and 4 git commands to generate.