[gameprogrammer] Re: Looking for a good storage method.
- From: Bob Pendleton <bob@xxxxxxxxxxxxx>
- To: Gameprogrammer Mailing List <gameprogrammer@xxxxxxxxxxxxx>
- Date: Wed, 27 Oct 2004 09:03:40 -0500
On Tue, 2004-10-26 at 20:54, jclark wrote:
> I have irregular shaped objects that I need to check for mouse clicks. I am
> storing an outer bounding box for a quick check to see if the mouse click
> occurred in a possible area of the object, but if that returns true, I need
> to see if the mouse click actually occurred in the object. Any ideas on ways
> to store a representation of the data without storing a huge array of pixels?
> Thanks,
> Jason.
There are two methods that are usually used to solve that problem. Which
you use depends on the problem you are trying to solve. If you have to
detect intersecting and overlapping objects it is best to use a
rectangle list sorted first by Y and then by X of the upper left hand
corner. This is the next step up from a single bounding box. You can do
intersection operations on a rectangle list very quickly. It can handle
an object with any shape. It can handle objects with holes. All in all,
very handy.
For simpler case just create a bounding polygon and use a point in
polygon test to see if the cursor has entered the polygon. You can find
some very nice PNP code at:
http://www.ecse.rpi.edu/Homepages/wrf/research/geom/pnpoly.html and also
at http://www.faqs.org/faqs/graphics/algorithms-faq/ in section 2.03.
Anyone doing graphics needs to know about the graphics FAQ and should at
least skim the last link I listed.
Bob Pendleton
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.775 / Virus Database: 522 - Release Date: 10/8/2004
>
>
>
>
> ---------------------
> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
>
--
+--------------------------------------+
+ Bob Pendleton: writer and programmer +
+ email: Bob@xxxxxxxxxxxxx +
+ blog: www.Stonewolf.net +
+ web: www.GameProgrammer.com +
+--------------------------------------+
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- Follow-Ups:
- [gameprogrammer] Re: Looking for a good storage method.
- From: Frank Herrera
- References:
Other related posts:
- » [gameprogrammer] Looking for a good storage method.
- » [gameprogrammer] Re: Looking for a good storage method.
- » [gameprogrammer] Re: Looking for a good storage method.
- » [gameprogrammer] Re: Looking for a good storage method.
- » [gameprogrammer] Re: Looking for a good storage method.
- » [gameprogrammer] Re: Looking for a good storage method.
- » [gameprogrammer] Re: Looking for a good storage method.
- [gameprogrammer] Re: Looking for a good storage method.
- From: Frank Herrera