var vi;
void camera_scan()
{
VECTOR tempv,temp;
while(1)
{
if(mouse_left) //scan while left mouse if pressed
{
tempv.x = mouse_pos.x;
tempv.y = mouse_pos.y;
tempv.z = 2000;
vec_for_screen(tempv,camera);
c_trace(camera.x, tempv, IGNORE_ME);
//get vertex coordinate with vec_for_vertex
vec_for_vertex(temp,hit.entity,hit.vertex); //if fails to return hit.vertex
vi = hit.vertex; //store it for panel
//Debugging draw point of contact and nearest vertex then draw a line between.
draw_point3d(temp.x,vector(0,0,255),100,300);
draw_point3d(vector(hit.x,hit.y,hit.z),vector(0,0,255),100,300);
draw_line3d(vector(hit.x,hit.y,hit.z),vector(0,0,255),100);
draw_line3d(temp.x,vector(0,0,255),100);
}
wait(1);
}
}