3d projection problems

BlitzPlus Forums/BlitzPlus Programming/3d projection problems

Kalisme(Posted 2008) [#1]
I've been having some problems with 3d projection code...
I'm curently working on a simple vecor based wolfenstein 3d looking engine (just a step in self teaching myself 3d)
it renders the walls from connecting vector points together.
I rotate the map so that all that is infront of the camera appears above the camera vector.
The actaul projection code I'm using is based on the diagram at the bottom of this page:
http://en.wikipedia.org/wiki/3d_projection

which comes down to:
dx# = px# * (screen# / screen# - py#)
dx = the x location on screen of the projected point.
px = the X location of the point being projected.
py = the y location of the point being projected.
screen = the distance of the screen to the camera.

This seemed to work perfectly, but unfortunatley when the point goes past the camera, it scales inwards again... I know this is because the point is getting further away from the camera again... but is there another way of coding this? (trying to stick with simplicity)

This is horrible because if one vector for the wall is infront of the camera and the other is behind; it scales incorrectly, and seems to flip to the opposite side.
Very odd.

Well, I hope someone can help.
Also, please note that I haven't posted this in the blitz3d forums because I'm trying to use just blitz2d commands so it will be easier to convert to SDL using C++ later on.
(Oh, and I'm trying to code it from the ground up)


Kalisme(Posted 2008) [#2]
wow... turns out I was just handeling this whole thing in an extreamly silly fashion... I read that it was pretty much imposible to do things the way I was suggesting, so now I'm using a clipping plane, and using the gradient from the two dot points to see where it falls on the clipping plane, then using that X value instead (and the Y value becomes the clipping plane).
I have to re-write it again because I've made a mistake, but hopefully it will go alot smoother (until I have to try and remember texture code... erg.)