OK, I have a simple clipping function up that also sets values based on where the vertex is based on the player's view. Now I can get z (the distance form the player) and y (above/below the player) easily, but how do I calculate x? I also found out that i cannot use indirection floating point values, so how can I point x, y, and z in the function to the memory location of the three actual variables being clipped and drawn?
bool CheckClipPlane(float x, float y, float z)
distance = sqrt(((x - player.xpos) * (x - player.xpos)) + ((y - player.ypos) * (y - player.ypos)) + ((z - player.zpos) * (z - player.zpos)));
if(distance > 512)
if(x < (player.xpos + cos((player.heading - 45) * pi / 180.0) * distance) || z < (player.zpos - sin((player.heading - 45) * pi / 180.0) * distance))
if(x > (player.xpos + cos((player.heading + 45) * pi / 180.0) * distance) || z > (player.zpos + sin((player.heading + 45) * pi / 180.0) * distance))
//Now set x y z to how they appear in the FOV
z = distance; //How far out the vertex is
y -= player.ypos; //How far above or below the player the vertex is
// x = ?; //How do you do x???
Now you would call the function with say "if(CheckClipPlane(x_m, y_m, z_m))". Now if it is too far to be seen, or the vertex is outside the player's FOV, it will return false and go on to examine the next triangle. If the vertex IS in the FOV, I need to have x_m, y_m, and z_m modified so that when I send the data to OpenGL it'll draw it as if the player really was moving around. Thanks for the help!