Raised This Month: $ Target: $400
 0% 

Is ojbect visisble in screen (by angle).


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 10-18-2010 , 03:44   Is ojbect visisble in screen (by angle).
Reply With Quote #1

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?
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.
MPNumB is offline
Send a message via Skype™ to MPNumB
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 10-19-2010 , 02:18   Re: Is ojbect visisble in screen (by angle).
Reply With Quote #2

No one? Seriously?
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.
MPNumB is offline
Send a message via Skype™ to MPNumB
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-19-2010 , 05:46   Re: Is ojbect visisble in screen (by angle).
Reply With Quote #3

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.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Voi
Veteran Member
Join Date: Sep 2006
Location: Gdansk, Poland
Old 10-19-2010 , 09:11   Re: Is ojbect visisble in screen (by angle).
Reply With Quote #4

nvm :p
__________________

Last edited by Voi; 10-19-2010 at 09:21.
Voi is offline
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 10-19-2010 , 13:33   Re: Is ojbect visisble in screen (by angle).
Reply With Quote #5

Quote:
Originally Posted by ConnorMcLeod View Post
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).
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.
MPNumB is offline
Send a message via Skype™ to MPNumB
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-19-2010 , 13:39   Re: Is ojbect visisble in screen (by angle).
Reply With Quote #6

You may be interested by that : http://forums.alliedmods.net/showthread.php?t=135841
__________________
Arkshine is offline
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 10-19-2010 , 16:58   Re: Is ojbect visisble in screen (by angle).
Reply With Quote #7

Thanks guys for your help. But I already contacted someone who gave me 100% accurate calculation. I personally call him an alien (lol ). Anyway, get ready - soon a plugin with really hardcore calculation will be submitted by me.
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.
MPNumB is offline
Send a message via Skype™ to MPNumB
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 10-19-2010 , 17:32   Re: Is ojbect visisble in screen (by angle).
Reply With Quote #8

You could also use CHR Engine's get_hudmessage_locs stock, which returns 0 if the origin isn't on the ent's viewcone.
Seta00 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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