I havn’t published in a while. I was back up with work on a project for uni., work and my writing…
But the good thing with keeping busy, is that after a while – you have something to show for! So here’s what i’ve been working on for Comp. Graphics course – A Ray Tracer.
The Ray Tracer is built from scratch with Java/SWT. And the thing that blew me away was that ray tracing is a very simple concept to implement. It is – as the name suggest – just the matter of shooting rays in the right directions and checking for intersections with 3D objects. The cool results are just a couple of dosens of line codes away, really…
So basically, in the exercise we had to render a scene defined in a made-up scene language. The language has definitions of some primitive objects: Rectangle, Box, Sphere etc. And definition of various types of lights. The scene definition should be parsed, and the scene should be kept in memory. The next step is to render the scene by shooting rays and checking for intersections.
A little bit about ray tracing:
A ray is shot from the “eye of the beholder” (user’s eye), through all the pixels in the viewing pane (a part of the screen) and on to scene. The ray consists of an origin point P0, and a direction vector V. The goal is to find the distanct t from the eye to the nearest object in the scene.
There’s a whole bunch of theories of shooting the rays, lighting models, reflecting rays, intersection and more. But I won’t bore you with details.
You can get the source code here:
And here are some results:
That’s about it.
Next time i’ll update on the progress of my efforts to bring computer vision abilities to the iPhone. A thing that proves harder than it seems…