Raised This Month: $ Target: $400
 0% 

Best player in viewcone


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Simon Logic
Senior Member
Join Date: Nov 2006
Location: RF
Old 12-27-2006 , 09:16   Re: Best player in viewcone
Reply With Quote #1

HLSDK::combat.cpp
Code:
//=========================================================
// FInViewCone - returns true is the passed vector is in
// the caller's forward view cone. The dot product is performed
// in 2d, making the view cone infinitely tall. 
//=========================================================
BOOL CBaseMonster :: FInViewCone ( Vector *pOrigin )
{
	Vector2D	vec2LOS;
	float		flDot;

	UTIL_MakeVectors ( pev->angles );
	
	vec2LOS = ( *pOrigin - pev->origin ).Make2D();
	vec2LOS = vec2LOS.Normalize();

	flDot = DotProduct (vec2LOS , gpGlobals->v_forward.Make2D() );

	if ( flDot > m_flFieldOfView )
	{
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}
m_flFieldOfView = 0 // 180 degrees
m_flFieldOfView = 0.5 // 90 degrees
Simon Logic is offline
Send a message via Skype™ to Simon Logic
MrDev
Member
Join Date: Sep 2005
Old 12-27-2006 , 09:36   Re: Best player in viewcone
Reply With Quote #2

Thanks for the reply. I have reviewed the function myself and I must admit it didn't really work well. But that doesn't mean the function is wrong ;)

I noticed they didn't normalize the aimvec and I assume the fldot calculation is in radians?

So if i want to extract the angle from all this I would have to add something like:

new anglemode:mode = radians;
float angle = floatacos(fldot,mode)

and then compare the different angles?

I could make the check first (fldot > 0.5) to make sure the player we're trying to find IS in the viewcone. However I think it was stated somewhere else that ViewCone didn't really work well?
MrDev is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 12-27-2006 , 10:46   Re: Best player in viewcone
Reply With Quote #3

Quote:
Originally Posted by Simon Logic View Post
HLSDK::combat.cpp
Code:
//=========================================================
// FInViewCone - returns true is the passed vector is in
// the caller's forward view cone. The dot product is performed
// in 2d, making the view cone infinitely tall. 
//=========================================================
BOOL CBaseMonster :: FInViewCone ( Vector *pOrigin )
{
    Vector2D    vec2LOS;
    float        flDot;
 
    UTIL_MakeVectors ( pev->angles );
 
    vec2LOS = ( *pOrigin - pev->origin ).Make2D();
    vec2LOS = vec2LOS.Normalize();
 
    flDot = DotProduct (vec2LOS , gpGlobals->v_forward.Make2D() );
 
    if ( flDot > m_flFieldOfView )
    {
        return TRUE;
    }
    else
    {
        return FALSE;
    }
}
m_flFieldOfView = 0 // 180 degrees
m_flFieldOfView = 0.5 // 90 degrees
this is a very stupid thing to do Stop posting cut out sections of C++ files . All your doing is confusing people . And your not even attempting to explaine it .
The Specialist is offline
Send a message via AIM to The Specialist
Zenith77
Veteran Member
Join Date: Aug 2005
Old 12-27-2006 , 12:40   Re: Best player in viewcone
Reply With Quote #4

Quote:
Originally Posted by The Specialist View Post
this is a very stupid thing to do Stop posting cut out sections of C++ files . All your doing is confusing people . And your not even attempting to explaine it .
Maybe you, but the thread starter clearly understood as you can see in his response to the post.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 12-27-2006 , 22:20   Re: Best player in viewcone
Reply With Quote #5

Quote:
Originally Posted by Zenith77 View Post
Maybe you, but the thread starter clearly understood as you can see in his response to the post.
I dont remember any one talking to you . Go play little boy
The Specialist is offline
Send a message via AIM to The Specialist
Zenith77
Veteran Member
Join Date: Aug 2005
Old 12-28-2006 , 11:14   Re: Best player in viewcone
Reply With Quote #6

Quote:
Originally Posted by The Specialist View Post
I dont remember any one talking to you . Go play little boy
And when we're they talking to you? You posted something completely invalid. If in fact you are older than me, you still don't seem to have the mental capacity that I and every other person on this forum (excluding a few people) possess. In fact from now on, everytime you respond to my post, I'm just going to sit there and continually let you make a fool of yourself. And stop trying to turn everything to a flame thread. Goodbye.

End flame here
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred

Last edited by Zenith77; 12-28-2006 at 11:16.
Zenith77 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 22:24.


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