Example:
create_object(create_sphere(blah), 42, 1337);
create_sphere returns two parameters, but create_object() only gets 3 passed to it.
So, I have to do this:
a, b = create_sphere(blah);
create_object(a, b, 42, 1337);
In any case, here's my new scene file:
-- Test script-- Set camera (pos, lookat, up, fov (Degrees))set_camera({0, 0, -20}, {0, 0, 1}, {0, 1, 0}, 45);-- Set output data (filename, width, height)set_output_file("out.bmp", 640, 480)-- Set quality params (samples per pixel, reflection depth)set_scene_params(1, 10);-- Create directional lights (dir, colour)create_directional_light({0, 0, 1}, {1, 1, 1});-- Create point lights (pos, colour, intensity)create_point_light({0, 5, 5}, {0.4, 0.4, 0.4}, 0.1);create_point_light({2, 5, 1}, {0.6, 0.6, 0.8}, 0.1);-- Init objects (colour, diffuse, specular, reflection)name, obj = create_sphere({1, -0.8, 3}, 2.5);create_object(name, obj, {0.7, 0.7, 0.7}, 0.2, 0.8, 0.6);name, obj = create_sphere({-5.5, -0.5, 7}, 2);create_object(name, obj, {0.7, 0.7, 1.0}, 0.1, 0.9, 1.0);name, obj = create_plane({0, 1, 0}, 4.4);create_object(name, obj, {0.4, 0.3, 0.3}, 1.0, 0, 0);-- Silly time...num_objs = 30;radius = 1;for i=1, num_objs do ofs = i - num_objs/2; progress = (i-1) / num_objs; x = ofs * radius*2; y = math.sin(progress*math.pi*4)*3.5; z = 14; name, obj = create_sphere({x, y, z}, radius); create_object(name, obj, {1.0, 0.5, 0.5}, 0.75, 0.1, 1.0);end
And here's the output image:
![Ooh, Sine-y](http://members.gamedev.net/EvilSteve/JournalStuff/Raytracer/ShadowsAndSine.png)
As you can probably tell, I've added shadows now. Refraction is coming up next, after I've tidied up material stuff a bit more, then textures (woo). I also decided to actually use the fact my scene is scripted to give a more interesting image. I'll try doing something like a full circle of spheres soon, they always look cool.
I've always wanted to write a raytracer at some point, never got around to it though.