🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Untitled

posted in DruinkJournal
Published November 27, 2007
Advertisement
Ok, I changed the way objects are created, which is a bit nicer. But there's an annoyance I found in Lua which stops it being as neat as it could be. If you have a C function that returns two return values, and you use the return value of that function as a parameter to another C function, the other C function only gets the first return value.
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:


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.
Previous Entry Untitled
Next Entry Untitled
0 likes 1 comments

Comments

benryves
Looking great. [smile]

I've always wanted to write a raytracer at some point, never got around to it though.
November 27, 2007 11:48 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement