PDA

View Full Version : 3d projection



jeppa
10-04-2001, 03:06 AM
how can I project a 3dpoint correctly when its z is negative?
I would want to visualize correctly
a polygon also when is behind the observer

es:this this example produces an incorrect result.

Distance=2.56f // Distance of the observer

x=-0.5f // 3d x
y=-0.5f // 3d y
z=-2.50f // 3d z
Inverse=1.0f/(z+Distance); // reciprocal
Xp=(x*Distance)*Inverse; //x projected
YP=(y*Distance)*Inverse; //y projected

thanks in advance

[This message has been edited by jeppa (edited 10-04-2001).]

qwert
10-04-2001, 03:24 AM
As I understood you do the projection yourself already in eyespace. So any point with negativ z-value is behind the viewer. Your problem seems to be the "Inverse = 1.0f/(z+Distance);". Try to do a "z = (float)fabs(z);"(or something like that) before you calculate the "Inverse".

qwert

jeppa
10-04-2001, 04:42 AM
yes it know.when z is(-2.57f)the point 3d changes direction!!!And the polygon returns in the scene!

thanks in advace