I have a little problem. I have player position (pev_origin plus pev_view_ofs - lets name it Float:fEyePos[3]), player angle (am using pev_v_angle to be more accurate - Float:fAngle[3]), and I have a position in the world (Float:fPos[3]).
Now is there a really good way to check if Float:fPos[3] is visible on players screen with support of pev_fov (ignoring objects what can block visibility of that position)?
I tried:
PHP Code:
ExecuteHam(Ham_FVecVisible, iPlayer, fPos);
= crash.
I also tried:
PHP Code:
stock bool:fm_is_in_viewcone(index, const Float:point[3])
{
new Float:angles[3];
pev(index, pev_angles, angles);
engfunc(EngFunc_MakeVectors, angles);
global_get(glb_v_forward, angles);
angles[2] = 0.0;
new Float:origin[3], Float:diff[3], Float:norm[3];
pev(index, pev_origin, origin);
xs_vec_sub(point, origin, diff);
diff[2] = 0.0;
xs_vec_normalize(diff, norm);
new Float:dot, Float:fov;
dot = xs_vec_dot(norm, angles);
pev(index, pev_fov, fov);
if (dot >= floatcos(fov * M_PI / 360))
return true;
return false;
}
editing pev_angles to pev_v_angle, and adding pev_view_ofs to players origin - result not accurate by some degrees and when being close enough - not working at all.
---
Now I wonder, can anyone help me by giving the right and working calculation for this?
__________________