vec_for_screen(VECTOR*, VIEW*): VECTOR*

The opposite of the vec_to_screen instruction. It converts XY screen coordinates, given through the vector, to a world position of the given view. Because a unique 3D position can not be determined from a XY screen position alone, a screen distance must also be given in the Z coordinate of the vector. This function can be used to place entities into a level on mouse click on the screen.

Parameters:

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

Returns:

VECTOR* - screen coordinates converted to world positon.

Modifies:

VECTOR*

Speed:

Fast

Example (lite-C):

function spawn_sprite()
{
// spawn a sprite at mouse click position, 200 quants behind the screen
  VECTOR vv;
  vv.x = mouse_pos.x;
  vv.y = mouse_pos.y;
  vv.z = 200;
  vec_for_screen(vv,camera);
  ent_create("arrow.pcx",vv,NULL);
}
...
on_mouse_left = spawn_sprite; 

See also:

vec_to_screen► latest version online