I was wondering if there was a way to get the 3D coordinates to 2D coordinates so that I could have some text properly float. Is there a way to do this in the wolf code?
help:getting 3Dcoordinates to 2D coordinates and vice versa
zinx
(zinx)
#2
You’ll probably need to do more than just get the coordinates, but here’s some code I wrote for q3/et to convert a single point:
qboolean WorldToScreen(vec3_t point, vec_t world[2])
{
vec3_t trans;
vec_t xc, yc;
vec_t px, py;
vec_t z;
px = tan(cg.refdef.fov_x * M_PI / 360.0);
py = tan(cg.refdef.fov_y * M_PI / 360.0);
VectorSubtract(point, cg.refdef.vieworg, trans);
xc = cg.refdef.width / 2.0;
yc = cg.refdef.height / 2.0;
z = DotProduct(trans, cg.refdef.viewaxis[0]);
if (z <= 0.001)
return qfalse;
world[0] = xc - DotProduct(trans, cg.refdef.viewaxis[1])*xc/(z*px);
world[1] = yc - DotProduct(trans, cg.refdef.viewaxis[2])*yc/(z*py);
return qtrue;
}
It returns ‘true’ if the point might be visible
rince_vng
(rince__vng)
#3
interesting, this leads me to another question (more simple than that mysterious formula) : Does anyone know of any sites that have a decent explanation of vectors or vector math or formulas related to vectors ? (Don’t worry, I can do this on my own so don’t feel too guilty if you don’t feel like responding)