1. Because I haven't really done much with java, other than little programs here and there. The largest thing I've done in it was when a friend and I implemented Tetris, and then a genetic algorithm to play Tetris, in it. Sorry, it had no GUI. We could spit out an ascii drawing of the board if we wanted to though.
2. I like ray tracers. I've been itching to trace some rays lately. I also would like to learn Swing better. This seems like a good mix. Games are fun too, but then you have the pressure of being "done" some day. With raytracers, you just get some diffuse light on spheres and you good. Everything else is "extra". Ok, so any self respecting raytracer will have specularity and reflection, because otherwise what's the point.
Why Java, you should use C++.
I've done a ray tracer in C++. Originally for a class at my uni, I developed it in C++ on Linux using Qt for the GUI. It was a lot of fun. If you look at my old journal entries you can see the development of it. I have also ported it to Windows, though I couldn't get Qt compiling correctly here, so it's just command line. I was going to start a new one anyway, without a deadline, and try to make it truely extendable. This is because there was all sorts of things I wanted to implement but didn't get the chance to, and I think it will be easier and more fun to experiment with a more moddable design from the start. Figure why not try Java, with all it's cool GUI and Threadness and 1.5ness (I haven't actually done anything in Java since 1.5 came out).
Also, I think it will be a challenge.
So, what's first? Achieve C++ speed. Or at least close enough.
Right now I have the basics in place, and can render this image:
In actuality, I also have reflection in place, but for my purposes I'm leaving it out. I have it set up (scene files) to render that exact image in both my java implementation and my C++ implementation.
Giving the render thread maximum priority, the java raytracer (JRT) finished that in ~980ms. Slooooooowwwwwwwwwwwww........
C++ verion (CRT) did it in 390ms. Better (not exactly real-time either...).
But that wasn't totally fair, CRT has bounding sphere support, so, turn that off: 312ms. Doh. But of course it's faster...THERE'S ONLY 4 SPHERES ON SCREEN (and 3 lights, FYI, though bounding spheres don't affect those)! The bounding sphere's aren't gaining anything. But I'll keep it off until JRT get's culling methods too.
So much of my problem is, as I implied, I'm not a Java programmer. And for efficiency, I don't know how best to set up classes (OMG EVERYTHING'S A CLASS!). I would like to improve speed, but keep the understandability and extendability of my code. First thing I'm doing is I'm going to remove as many "new"'s as possible. Although passing everything by reference will take a bit of getting used to. So, that's what I'm off to do now.