|
-
May 26th, 2007, 03:51 PM
#1
Objects in FOV
I am writing a half-assed graphical interface in VB.NET. The reason I say it is half-assed is that this particular interface may have more diagnostic value, and may be scrapped after the system is tested. Therefore, this question is not exactly critical.
I am drawing some number of points on the screen representing items in the field of view, which ranges from 1 to 500 cm deep. No problem there, the screen area is 500 pixels deep. Thus, each point gets a point on the screen, and are nothing but tiny rectangles.
The question arises from the fact that it appears easiest to draw every point within a radius of 500 cm, regardless of whether or not they actually fall into the current field of view. This should be somewhat slow, but that may be ok, as drawing will probably not take place any faster than once every couple seconds.
If there was a way to quickly and easily exclude some or all of the points which are not actually in the current field of view, then it would be good for me to do so. Is there such a technique? I realize it can be done with DirectX types of things, but since this is an interface which may just get thrown out later in the project, I don't feel very motivated to go beyond the simple.
My usual boring signature: Nothing
 
-
May 26th, 2007, 04:37 PM
#2
Lively Member
Re: Objects in FOV
The way OpenGL, and I think DirectX (not entirely sure), do it is by using a frustrum and clipping the points/objects. A frustrum is basically a pyramid with a flat top instead of a point. So what you could do is make 4 planes that define the sides of a frustrum, have all the normals point inward. Then to see if a point is inside the frustrum, plug the point into the plane equation for each plane. If they are all greater than (or equal to) 0 and the depth value is in between 0 and 500, the point is in the field of view. If any time you find a negative one you can discard it (<0 as a result of the plane equation means its behind it).
Its a fairly simple way I think, and pretty quick. The only thing you might get trouble with this is actually making the frustrum walls out of 4 planes or maybe if your interface moves or rotates anything. I would suggest working some of it out on paper (if the field of view never changes). But if you implement it, the best thing to do would be to adjust the planes until it looks good.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|