Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Field of vision

This topic is 6035 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! (I try(...) to explain my problem in english...) ) I try to program a Field of vision. How for example in Commandos. The enemy has a field where they see you. A triangular form with a circle end. (circlesector?? ) ) Hope you understand... ) Yeah... Now to the maths: How can I calculate if a Point(X/Y) is in this circle with angle and distance? Thanks... C.Ruiz (How exactly can I show pictures on this forum? If you show me I could send a picture...) Edited by - cruiz on January 2, 2002 1:26:11 PM

Share this post

Link to post
Share on other sites
The shape you''re referring to is a cone!

Anyway, here''s the simplest way: Keep track of a vector representing the direction the ai player is facing. Then, take the dot-product of that and the vector pointing towards the human player. If the angle is less than half of the field-of-view angle, then the player is in the field of view; otherwise he is not.

The dot product of two vectors, A and B, is expressed as follows:
A * B = cos(angle_between_vectors)*(|A||B|)

To find the angle between them, then you need to do this:
angle_between_vectors = acos((A*B)/(|A||B|))

The symbol |A| means the absolute value of A. This can be calculated as follows:
|A| = sqrt(a.x2+a.y2+a.z2).

This does not handle occlusion detection. What that means is that, if you are behind a wall that the ai player is looking directly at, then he can still "see" you even though he shouldn''t be able to. From the sounds of things, you should be able to ignore this limitation.

Good luck.

Share this post

Link to post
Share on other sites
Ok i''ve tried and it don''t works.
But I don''t understand the theory either!
What is if one or both vectors are zero??
A "man" don''t must walk not? It can stand around for example.
Ok explication to my game:
You are a ship and you see the field of vision.
If a opponent is in this field it should be visible.
Here my source:
double V1,W1, V2,W2;

double angle_between_vectors = acos((V1*W1+V2*W2)/((sqrt(V1*V1)+(V2*V2))*(sqrt(W1*W1)+(W2*W2))));

double currentangle=90;//for example

double bogennn=3.141* ((currentangle)/(180));
//Calculation in Radian


I hadn''t Vectors in shool yet.
I''ve read already an articel in the internet about them.
Really complicated!
Thanks for your posting.
Greets: C.Ruiz
(P.S.: A "cone"! Ok thanks! )

Share this post

Link to post
Share on other sites
Yesterday did school begann.
A math-teacher explained me a part of my problem.
This formula is wronger than wrong!!!!!!!!!!
I'm on it. I have changed the formul but
I'm still working.
But now I understand the theory!!
(ok a part of it)
I mean i had Vector-maths never in school.
I will have in next semester i heard.
Greets from here: C.Ruiz

Edited by - cruiz on January 8, 2002 3:35:51 AM

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
do be, everyone from switzerland, yoda?

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!