Guest User

Untitled

a guest
Apr 26th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.98 KB | None | 0 0
  1. scene_info = SceneInfo() {
  2.   image_width = 320,
  3.   image_height = 240,
  4.   frames = 30
  5. }
  6.  
  7. function scene(clock)
  8.     local s = Scene() {
  9.         background_color = Color(0, 0, 0),
  10.         camera = Perspective(90) { transform = Rotate(y, clock * 360)
  11.                                                * Translate(6*y - 6*z)
  12.                                                * Rotate(x, 30)
  13.                                  }
  14.     }
  15.    
  16.     s:add_lights({
  17.         Light() {
  18.             color = white,
  19.             transform = Translate(8*y + -6*z + 4*x),
  20.             area = true,
  21.             rows = 8,
  22.             cols = 8
  23.         }
  24.     })
  25.    
  26.     local teapot_texture = Texture() {
  27.         pigment = ColorPigment() { color = Color(1.0, 0.2, 0.2) },
  28.         finish = Finish() {
  29.             ambient = Color(0.1, 0.1, 0.1),
  30.             diffuse = 0.5,
  31.             specular = 0.9,
  32.             exponent = 170,
  33.             reflection = 0.8
  34.         }
  35.     }
  36.    
  37.     local ball_texture = Texture() {
  38.         pigment = ColorPigment() { color = Color(0.7, 0.7, 0.8) },
  39.         finish = Finish() {
  40.             ambient = Color(0.1, 0.1, 0.1),
  41.             diffuse = 0.8,
  42.             specular = 0.9,
  43.             exponent = 64
  44.         }
  45.     }
  46.  
  47.     m = mesh_from_obj("C:\\temp\\bunny.obj") {
  48.         transform = Scale(.5,.5,.5) * Rotate(y, 180),
  49.         texture = teapot_texture,
  50.         smooth = true
  51.     }
  52.     s:add_mesh(m)
  53.    
  54.     for i = 1,15 do
  55.         local v = Vector(3 * math.sin((i/15)*2*math.pi), 1, 3 * math.cos((i/15)*2*math.pi))
  56.         local tf = Translate(v) * Scale(.3, .3, .3)
  57.         s:add_entity(Sphere(tf) { texture = ball_texture })
  58.     end
  59.    
  60.     floor = Mesh() {
  61.         vertices = {
  62.             {-100.0, 0.0, -100.0},
  63.             {100.0, 0.0, -100.0},
  64.             {100.0, 0.0, 100.0},
  65.             {-100.0, 0.0, 100.0},
  66.         },
  67.         indices = {
  68.             { 1, 4, 2 },
  69.             { 2, 4, 3 }
  70.         }
  71.     }
  72.     s:add_mesh(floor)
  73.  
  74.     return s
  75. end
Add Comment
Please, Sign In to add comment