September 24th, 2004 in Programming, Projects.
I’m currently working on a projects to display 3-D graphs, like this applet. It turns out that this is a lot harder than it seems…
The Concept
Basically, in “rendering” a 3-D picture, you have to take each point (x,y,z), and convert it to 2-D (x,y). Yay. However, that’s easiers said than done. There are three main methods: projection, ray-tracing, and shading.
In projection, you simply forget z (the depth), or make the object appear smaller if it’s farther away. That’s cool, but you can’t really get a good view of a graph from a straight-on angle like that. Imagine looking at a car only head-on, then trying to draw a picture of the whole thing. It doesn’t work.
Raytracing is the opposite of projection: all points are plotted without loss of information. Raytracing takes these 3-D points, and, taking into account the angle of which you want to see the object, it puts the point onto the graph. Have you ever drawn a box, by making two squares and conecting the corners? Same idea.
Finally, shading is just what it says. In shading, you make the general projection shape, but then make the regions closer to the “light” brighter, and vica versa. So a sphere looks bright in the middle, and fades to dark on the edges.
I chose to use Raytracing, because it’s the easiest possible while still getting a good view of the image. However, there are many “rendering” programs (programs that allow you to make 3-D images) like PovRay, Bryce, etc, that you a combination of these. Done well, you can produce a VERY nice image with not a lot of time.
I don’t think my program will be quite like that…
Currently…
…I’m trying to get those raytracing formula’s down. I’ve found many of them…. but they don’t seem to work. (probably user error.) I’m working on it! Please drop me a line if you might be able to help!
Here’s a good tutorial on all this, by the way: Software Rendering School
See ya later!
Leave a comment
Leave a Reply