开发者

4 dimensional Hidden Surface Removal

I'm trying to program a little 4d game. I use C++ and OpenGL. This website brings a good explanation on how to enhance 4d images:

http://eusebeia.dyndns.org/4d/vis/07-hsr.html#Enhancing_4D_Projection_Images

they tell to apply a 4d Hidden Surface Removal (HSR) algorithm.

I have to say I am a newbie in programming and algorithms, and I don't really have an idea where to start to put together a 4d HSR, nor a 3d one.

If somebody have experience with those kind of algorithms, can explain me how to translate it in C++?

btw: I project the 4d space in 3d, so I will need an algorithm for vertex removal, rather than开发者_JAVA百科 pixel modification, or at least is what I think... I can be wrong...


In many cases, 3d hidden surface removal means that when you draw a surface, you also remember the depth of each pixel that you draw (distance from the 'eye'). When you go to draw a surface where a surface has already been drawn, you only draw the pixel if it's closer to the eye than the pixel that's already there. In the 3d graphics library, OpenGL (projects 3d scene descriptions to a 2d display), this is called the Depth Buffer Test.

You might also keep track of which direction the surface is facing. If it faces away from the 'eye', then don't draw it at all. In OpenGL, this is call backface culling. If you want to create the layered transparency look that your article describes, then you have to sort the pixels according to depth and draw the deepest ones first. Then draw the nearer ones on top, replacing the current pixel with a convex combination of the old pixel color and the current surface's color.

For your 4d case, you need to decide what it means to project a 4d thing. I think that any 3d model that's also animated is actually a 4d model. You could, if you wanted, draw all of the frames at once as with this simulated racquetball player:

4 dimensional Hidden Surface Removal

In this image, time is represented by grayscale value here. So you can see the player move across the court and hit the ball, all in a single static image. Of course, a proper 4d to 2d projection probably wouldn't display a bunch of discrete time frames drawn together, but would rather connect the vertices that bridge time so that instead of seeing a bunch of individual balls, you would see a 'tube' that represents the ball's trajectory. But, kind of like is mentioned in the article you link, for some cases, that might communicate less.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜