visible surface detection w.r.t. ray tracing

I’m not sure if this is an advanced topic or not. If not, I apologize. Anyways, here’s my question/problem:

I need to raytrace a surface of revolution(a spline revolved around the z-axis). In order to do this I’ve created a polygon mesh representation of the surface and stored the polygons in a list.

The part I’m not sure of is how to calculate the intersetion of rays with the mesh. My initial thoughts on it are to loop through the list of polygons and check to see if N dot V is negative(N = normal of polygon, V = ray sent out from camera). If so, it is a front-facing polygon. I can then keep track of the polygon closest to the camera that is front-facing. I believe this will work, but perhaps there’s a better/more efficient way???

Secondly, how can I test for intersection between the ray and the polygon? Using the method described above, I only get the closest, front-facing polygon. But how to I test if the ray intersects this polygon?

as always, all help appreciated.


I think that your looking at this problem in the wrong way - OpenGL is not a raytracer. It works in a fundamentally different way:

A raytracer renders each pixel on the screen in turn - this is what you are trying to do.

OpenGL renders each polygon in the scene in turn - this is what everybody in this discussion forum does .

If you are using OpenGL for this problem, then you don’t need to do anything special to find out which of the polygons is closest to the viewer. You just keep drawing each of the polygons in turn, and if a new polygon is closer to the viewer than any already drawn, it will be drawn ontop (as long as you are using z-buffering).

If on the other hand, you are using a raytracing method (nothing to do with OpenGL), then your best bet is to find another discussion forum.

Hope this clarifies things a bit.

I realize this isn’t an openGL question. My apologies for not making this clear up front. I will, however, be using OGL to draw the pixels I have seen several threads regarding methodologies and algorithms for doing things on this board, so I figured such a post was acceptable. I mean, this is a graphics-related question and anyone reading this board is into some kind of graphics programming, so I figured it was a good forum. If I was wrong, I apologize once again.

O.K. - maybe I should start reading messages properly before I reply to them…

For what it’s worth, I can’t think of a better way of raytracing a surface of revolution, than the way you’ve outlined.

For your second point, you could get the rendered screen coords for a polygons nodes, and see if the ray (pixel) lies inside this region. This way does seem a little long winded though, and I have to admit that I’ve never tried writing a raytracer…