AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Is ojbect visisble in screen (by angle). (https://forums.alliedmods.net/showthread.php?t=140959)

MPNumB 10-18-2010 03:44

Is ojbect visisble in screen (by angle).
 
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_FVecVisibleiPlayerfPos); 

= crash.

I also tried:
PHP Code:

stock bool:fm_is_in_viewcone(index, const Float:point[3])
{
 new 
Float:angles[3];
 
pev(indexpev_anglesangles);
 
engfunc(EngFunc_MakeVectorsangles);
 
global_get(glb_v_forwardangles);
 
angles[2] = 0.0;
 
 new 
Float:origin[3], Float:diff[3], Float:norm[3];
 
pev(indexpev_originorigin);
 
xs_vec_sub(pointorigindiff);
 
diff[2] = 0.0;
 
 
xs_vec_normalize(diffnorm);
 new 
Float:dotFloat:fov;
 
dot xs_vec_dot(normangles);
 
 
pev(indexpev_fovfov);
 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?

MPNumB 10-19-2010 02:18

Re: Is ojbect visisble in screen (by angle).
 
No one? Seriously?

ConnorMcLeod 10-19-2010 05:46

Re: Is ojbect visisble in screen (by angle).
 
is_in_viewcone only take in account horizontal view, you would have to implement it with Z origin checks.
Check for last opened thread about in_view_cone.

Voi 10-19-2010 09:11

Re: Is ojbect visisble in screen (by angle).
 
nvm :p

MPNumB 10-19-2010 13:33

Re: Is ojbect visisble in screen (by angle).
 
Quote:

Originally Posted by ConnorMcLeod (Post 1329175)
is_in_viewcone only take in account horizontal view, you would have to implement it with Z origin checks.
Check for last opened thread about in_view_cone.

Ya, I checked for Z also, and results are:
horizontal check doesn't check the edges properly (as if fov is 85 and not 90).
Z check works as if fov is 100 and not 90).

Arkshine 10-19-2010 13:39

Re: Is ojbect visisble in screen (by angle).
 
You may be interested by that : http://forums.alliedmods.net/showthread.php?t=135841

MPNumB 10-19-2010 16:58

Re: Is ojbect visisble in screen (by angle).
 
Thanks guys for your help. But I already contacted someone who gave me 100% accurate calculation. I personally call him an alien (lol :D ). Anyway, get ready - soon a plugin with really hardcore calculation will be submitted by me. :D

Seta00 10-19-2010 17:32

Re: Is ojbect visisble in screen (by angle).
 
You could also use CHR Engine's get_hudmessage_locs stock, which returns 0 if the origin isn't on the ent's viewcone.


All times are GMT -4. The time now is 10:17.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.