vec_to_screen ( VECTOR*, VIEW*): VECTOR*

Converts the XYZ coordinates of the given vector to screen coordinates. After the function call, the X and Y coordinates of the vector contain the XY screen position and the Z coordinate contains the distance to the camera. The view must be visible. This function can be used to attach 2D objects, like texts or panels, to screen positions of entities.

Parameters:

VECTOR* vector to be converted
VIEW* View pointer to be used for the conversion

Returns:

NULL - Result is outside the view window.
VECTOR* - Result is inside the view window.

Modifies:

VECTOR*

Speed:

Medium

Example (lite-C):

PANEL* flare_pan = { bmap = "lensflare.tga"; }
...
// attach a lens flare to an entity
VECTOR vv;
vec_set(vv,my.x);
if (vec_to_screen(vv,camera)) // if visible on screen
{
  flare_pan.pos_x = vv.x; // place the flare panel
  flare_pan.pos_y = vv.y;
  set(flare_pan,SHOW);
} else 
  reset(flare_pan,SHOW);  // otherwise disable it

See also:

vec_for_screen

► latest version online