Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Macrosii
21
Years of Service
User Offline
Joined: 31st Mar 2004
Location: Essex, UK
Posted: 20th May 2004 17:16
Any bright spark.

If you have an enemy ship with its own FOV (no camera involed) how would you determine if an object is within the enemy's FOV. I guess you need some soft of projection matrix?
Macrosii
21
Years of Service
User Offline
Joined: 31st Mar 2004
Location: Essex, UK
Posted: 20th May 2004 17:23
Should have specified 3D.
Chaos
22
Years of Service
User Offline
Joined: 8th Feb 2003
Location: United Kingdom
Posted: 20th May 2004 17:27
Hey,
Your trying to see if an enemy can see an object am i right? If so this can be done using simple maths commands. Since its a ship i would guess it can see in all directions. The way i would do it is for any object you want to find get there x,y and z positions. Then calculate if they fall within the radius of the enemies FOV.

So say if your enemies FOV was 100. And it was placed and 0,0,0. Then say an object was positioned at 50,0,50 all you would have to do i a simple distance check to see if you are near to the enemie.


e = enemie o=object

This code may require some tweaking



Hope that helps
Chaos


[center] New Project announcment coming soon[center]
hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 20th May 2004 17:34
The "easiest" way to do this is to create a fov object (a triangle) with it's pivot|origin at one of it's vertices and position the fov object at the ships position like in commandos, you can optionally hide|show it. The good thing about this method is all it takes is a simple collision check to determine if a ship is within anothers fov and the ship's fov angle and view distance can be set simply by modifying the shape of the fov object.

The "hard" way would lie solely in mathematics, it would basically involve the same procedure as above but the fov object would be treated as a virtual object ( like it isn't already... ) i.e. not rendered, just equations.

Macrosii
21
Years of Service
User Offline
Joined: 31st Mar 2004
Location: Essex, UK
Posted: 20th May 2004 17:34
That gives the distance between them yes but if the eneny is facing the other way then he cant see the object.
Macrosii
21
Years of Service
User Offline
Joined: 31st Mar 2004
Location: Essex, UK
Posted: 20th May 2004 17:39
Hexgear, Was thinking about the math. Will give it a try the object way and see what overhead I get. Thanks.
hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 20th May 2004 17:50
this method takes into account only the 2D x and y axis (in 3d would be x and z). Basically you can use the object position and one of the vertex positions and using newxvalue and newzvalue project the other triangle vertex positions. Feed all 3 vertex positions as well as the position of the object you want check into the function below and hey presto

not particularly db code but if you understand it you could easily port the function into db code.



you can go the extra mile and make the virtual fov object rotate from side to side also like commandos and guess you could compensate for different heights by a y distance check.

Macrosii
21
Years of Service
User Offline
Joined: 31st Mar 2004
Location: Essex, UK
Posted: 20th May 2004 17:53
Hm,

Thinking about it I could position the camera at the enemy, orient it to the object then do a object in screen(target), then move camera back to where it should be. Not sure on the overhead this will give on a large number of enemies.
Macrosii
21
Years of Service
User Offline
Joined: 31st Mar 2004
Location: Essex, UK
Posted: 20th May 2004 17:55
Thanks Hex, will try out as soon as I get a chance.
Ron Erickson
Moderator
22
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 20th May 2004 21:21 Edited at: 20th May 2004 21:22
Sorry to keep pimpin my dll, but....

EZrotate will have something to make this really easy. Last night I added a command to check the angle between 3D points (1 vertex and 2 segments).

Basicly, it works like this. You tell it the first 3D point, which acts as the vertex of an angle. You then tell it 2 other points. Those 2 points create lines that go to the vertex. EZrotate then calculates the angle between those 2 segments.

To use this for your FOV problem, you would set the first point to the location of the FOV origin. You would set the second point as an extension of the facing direction of the FOV (easily done with the Get Matrix commands in EZrotate). You would then set the 3rd point as the location that you want to check. If the angle returned is less than the FOV angle, then it would be within the FOV.

Should be a really easy thing to do.

WOLF

EZrotate!
Tokamak Physics Wrapper!
Peter H
21
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 20th May 2004 21:53
sweeeett when does that come out? (BTW the return angle would have to be less then half of the real FOV you want the object to have....if i'm understanding you right


Formerly known as "DarkWing Duck"
Ron Erickson
Moderator
22
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 20th May 2004 22:09
Yeah... you are correct. I forgot to mention that.

The plug-in is just about finished. The features are all tested and working well. I have a couple of "things" to take care of before it is released though

EZrotate!
Tokamak Physics Wrapper!
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 21st May 2004 01:31
erm, don't forgot that just because the object is front of the viewer plane, it may well be obstructed by the terrain/static world..

Kevin Picone
[url]www.underwaredesign.com[/url]
Play Nice! Play Basic
Macrosii
21
Years of Service
User Offline
Joined: 31st Mar 2004
Location: Essex, UK
Posted: 21st May 2004 15:05
Wolf.., Im sold already, you had me with 'point towards'.
Perhaps you could include the FOV thing in one of your demos.

Good point uw, sort of forgot that, doh!
Ron Erickson
Moderator
22
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 21st May 2004 16:34
Quote: "...you had me with 'point towards'."

lol. That reminded me of Jerry McGuire. "You had me at hello,...you had me at hello"

I am goint to try to write up a mini-game that will showcase the features. It will probably be some type of space-sim/shooter so that should help you quite a bit.

EZrotate!
Tokamak Physics Wrapper!
Mussi
22
Years of Service
User Offline
Joined: 27th Jan 2003
Location: Netherlands
Posted: 22nd May 2004 15:43 Edited at: 22nd May 2004 15:46
if wolfs dll is not out yet you could do what wolf said easely with the dot product.

what if the player is behind an object? the enemy would still be able to see him



Specs: AMD Athlon 1800, 256 DDRRam 266mhz, 80GB HD 7200rmp U133, Geforce 4 Ti4400 128mb
Macrosii
21
Years of Service
User Offline
Joined: 31st Mar 2004
Location: Essex, UK
Posted: 22nd May 2004 23:42
With the dot produect I know I can get the angle between the two vectors but not quite sure how to relate the one angle to the object local rotations and then to the FOV.

Yeh AI starts getting complicated, target obscured, partially obscured .
EdzUp
22
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 23rd May 2004 00:53 Edited at: 23rd May 2004 17:19


Firstly place a dummy object at the location you wish to check from and point this at the target to check for. Secondly use the above code to work out the distance between the object angles your checking from and the dummy object angles, if all X,Y and Z are within the FOV range (for example if the FOV is 45 and they are all within -45 to 45 degrees) then that object can see the other one.

I use this system in Hunted and it works a treat, it also only needs one dummy object and no 'special' camera etc.

-EdzUp
Macrosii
21
Years of Service
User Offline
Joined: 31st Mar 2004
Location: Essex, UK
Posted: 23rd May 2004 00:59
Thanks edz, will give a try.

Login to post a reply

Server time is: 2025-06-05 19:16:28
Your offset time is: 2025-06-05 19:16:28