vec_for_screen ( VECTOR*, VIEW*);
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 depth must also be given in the Z coordinate of the vector. The view must be visible for this instruction to work. This instruction 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:
NULL - Result is outside the view cone.
VECTOR* - Result is inside the view cone.
Modifies:
VECTOR*
Speed:
Fast
Example:
function spawn_sprite()
{
// spawn a sprite at mouse click position, 200 quants behind the screen
temp.x = mouse_pos.x;
temp.y = mouse_pos.y;
temp.z = 200;
vec_for_screen(temp,camera);
ent_create("arrow.pcx",temp,NULL);
}
...
on_mouse_left = spawn_sprite;