This is a small tutorial aimed at getting you started so you can learn the rest of LibTrace by yourself.
In this tutorial I presume that you know how to compile and link programs using LibTrace properly.
First things first you should set the scene:
Scene scene;
Well that's enough. Let's move on.
Let's just create a yellow sphere above a grey plane:
Sphere sphere(Vector(0, 1, 5), 2); Plane plane(Vector(0, 1, 0), -1); sphere.set_child(&plane); TPlain yellow, white, diffuse; yellow.surface.color=YELLOW; white.surface.color=WHITE; diffuse.surface.diffuse=1.0; yellow.slave=white.slave=&diffuse; sphere.texture=&yellow; plane.texture=&white;
Using the texture slave for this example was a bit overkill but it's there so you can see how it is done. If
yellow
or white
had had their own diffuse
settings then
they would have overridden the level set by the slave texture diffuse
.
Light light1(Vector(5,0,0), WHITE), light2(Vector(-5,0,0), WHITE); light1.set_child(&light2);
scene.set_objects(&sphere); scene.set_lights(&light1); scene.render(); scene.save_to_file("tutorial.ppm");
Wasn't that painless? Now that you know the basics you should just look things up if and when you need them.