[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - Checking if an entity is within a players view

Checking if an entity is within a players view

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Checking if an entity is within a players view

Postby Mexicouger » Sun Sep 02, 2012 12:29 am

Im having troubles on how I would code it to check if a certain entity is within the current viewing angles of the player. anyone mind pointing me in the right direction? And if Im a little unclear, let me explain.

Your the player. Say theres a rocket launcher on the ground. How could you check and see if that rocket launchers within the players camera? And lets just say you turn around and you can no longer see the rocket launcher. How could I calculate that?
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Re: Checking if an entity is within a players view

Postby Baker » Sun Sep 02, 2012 1:56 am

The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Checking if an entity is within a players view

Postby Mexicouger » Sun Sep 02, 2012 2:05 am

That's not what I'm trying to do haha. That checks around the player. With that code, the rocket could be behind the player and still detect it. I'm thinking something more like fisible from frikbots but from the perspective of the players v_angle detecting what the player can actually see.
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Re: Checking if an entity is within a players view

Postby Baker » Sun Sep 02, 2012 2:13 am

The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Checking if an entity is within a players view

Postby frag.machine » Sun Sep 02, 2012 3:11 am

I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2120
Joined: Sat Nov 25, 2006 1:49 pm

Re: Checking if an entity is within a players view

Postby Mexicouger » Sun Sep 02, 2012 4:30 am

User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Re: Checking if an entity is within a players view

Postby Spike » Sun Sep 02, 2012 5:45 am

This post is basically an explaination of the infront function.

in qc terms:
cos(anglebetweenvectors) == normalisedvector1 * normaliseedvector2

so vector*vector will be 1 if they are identical, -1 if they point in opposite directions, and 0 if they point 90 degrees to each other.
Considering the greatest angle difference you can have is 0 to 180 and fields of view are measured in both directions instead of just one, ((fwd*normalilze(targetpos - sourcepos)) > cos(fovvalue/2)) can be used to check whether the direction is within the given field-of-view angle.
cos, however, is an extension, but you can replace the result of that function with a constant (for example, quake's collision code reguarly uses 0.7 for surfaces that are considered pointing upwards for 'onground' checks).
Note that this is NOT the same as 'onscreen', as this would require a circular screen. The virtual circular screen will generally have the same width as the screen, thus this may fail for the corners of the screen. Also, you may also need to pay attention to bounding boxes.
Additionally, makevectors(self.angles) is generally only valid when angles_x=0 (which is true for monsters). If used for a player, you should be using makevectors(self.v_angle) instead. This will scale correctly with pitch (instead of being 1/3rd), and will also work around an old (unfixable) sw quake bug where .angles_x on alias models is inverted.

(qc's vector*vector operation/instruction is actually a 3-componant dotproduct)
(dotproduct is useful for all sorts of things!)
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Checking if an entity is within a players view

Postby Nahuel » Sun Sep 02, 2012 12:03 pm

I made this in the past days to get some effects, if the entity is infront and visible with the precise angles CSQC add some bloom effect ... maybee seems crapy in this early release :)
hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: Checking if an entity is within a players view

Postby toneddu2000 » Sun Sep 02, 2012 12:25 pm

Very very nice effect Nahuel! I loved it! Sun light is lightmapped or dynamic (achieving dynamic sun lights in DP is my only motivation of life in these days! :))?
- my first commercial game, made with FTEQW game engine
toneddu2000
 
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: Checking if an entity is within a players view

Postby Nahuel » Sun Sep 02, 2012 3:42 pm

hello tunedude, the map is darker, so is just a dynamic light place un a specific place !

@Spike it is posible to get something like (infront) function but instead of using a speciffic point like "self.origin" to use an area? i speak about an entire area of the brush, a something like func_wall, I wanna to get the bloom oriented effect with a brush, not with the specific origin of the entity . Thanks in advance :)
hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: Checking if an entity is within a players view

Postby Seven » Tue Sep 04, 2012 9:41 am

This is a very interesting topic.
Thank you Mexicouger for starting this thread and Nahuel for your demonstration.
It brings so many new ideas into the mind.

I am working on a zombie modification at the moment, in which the Axe weapon plays a special role.
Implementing a QC "zombiecheck" to find out if a zombie is in range and then starting an Axe animation,
where it starts to glow. Because zombies are killable with the Axe.
It is like a "holy-zombie-killing" weapon in this mod...

So this thread-knowledge is very helpful to achive this task.
Thank you again.
Seven
Seven
 
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: Checking if an entity is within a players view

Postby Spike » Tue Sep 04, 2012 12:03 pm

Nahuel, can you not just define a direction in the map, and use that against the player's v_forward? then its no specific point at all, though would be purely based upon the player's view direction.
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Checking if an entity is within a players view

Postby Alex » Sat Sep 15, 2012 4:34 pm

Alex
 
Posts: 24
Joined: Sun Feb 13, 2011 6:24 pm

Re: Checking if an entity is within a players view

Postby andrewj » Sun Sep 16, 2012 5:22 am

andrewj
 
Posts: 133
Joined: Mon Aug 30, 2010 3:29 pm
Location: Australia


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest