Hi Ken, a while back I posted some notes on collision detection and vectors to 
the Audyssey list and Thomas's Developers list. I'll re-post a couple of these 
here now.

This first one is concerning axis-aligned bounding boxes. All this means is 
that you represent a box which stays lined up with the x y and z axes in a 
virtual world.

My below note represents a way of detecting collisions between two boxes.

HTH

Cara :)
---
  Hey All, this is just a quickie before my workout!  lol!  I just  
wanted to post a bit on Bounding boxes as we've been chatting about  
them / collision detection.  I'll go ahead and post the code first,  
and then give a little quick snippet about it.  Just as an FYI, this  
is my own code so there are other ways to do this.  this is pretty  
quick / easy though, so I like it much.  <smile>

Anyway, here it is.

// just setting variables here for the sake of the example

float box1MinX, box1MinY, box1MinZ = 1.0F;
float box1MaxX, box1MaxY, box1MaxZ = 11.0F;
float box2MinX, box2MinY, box2MinZ = 20.0F;
float box2MaxX,box2MaxY,box2MaxZ = 26.0F;

// the above variables would really be dynamically set based on the  
dimensions
// of the objects in question as their values would be passed to this  
method

// All of the conditions in the below statement must be true for a  
collision to happen
// if they're not then the statement will short circuit and the else  
clause will be called

if(((box1MaxX >= box2MinX) && (box1MaxY >= box2MinY) && (box1MaxZ >=  
box2MinZ)) && ((box1MinX <= box2MaxX) && (box1MinY <= box2MaxY) &&  
(box1MinZ <= box2MaxZ)))
{// code for collision goes here}
else
{// no collision happened}

  So in this example, no collision will have happened.

So what's going on up there?…

It's actually extremely simple, and you can think of it by simply  
starting with only a one dimensional number line like in grade school.

I.E.  think of a number line which goes from 0 upward.  Say you have a  
point on that line, and another point some distance away further along  
the line.

For the sake of the example, let's say the first point is at zero. The  
second point is at 20.  Checking for a collision using an axis aligned  
bounding box as I've done above, is really no more than seeing if a  
number is greater or less than another number, so in this example, our  
first number on the number line is obviously less than our second  
number.

  So now say that each of those numbers represented an edge of a box,  
or shape.  I.E.  our first point on the number line at zero represents  
the right edge of some mystery shape, and the second point at 20  
represents the left edge of a second mystery shape.  Are they  
touching, no not by any means.  to be touching, they'd need to be  
equal, I.E. they'd need to be occupying the same space on our number  
line.  Or, as we've decided that they'll represent a right edge and  
left edge respectively, of two shapes, they'd actually need to be  
either equal or the first point, which represents the right edge of  
our first shape could also be greater than the second point, which  
represents the left edge of our second shape.  In that case, these two  
mystery shapes might be touching.

Does this make sense so far?…

I.E. If we said that point 1 was now at 3 on our number line, and  
point 2 was now at 3 as well, then the right edge and left edge of our  
two unknown shapes would be touching, as the numbers which represent  
them are equal.

  This really is all that's happening in the above code.  It's just  
being expressed in more than one dimension and with a range of  
numbers, rather than just one for each shape or edge of a shape.

I.E.  let's say that our first shape takes up the range of numbers  
from 0 to 5 on our one dimensional number line, and the second shape  
takes up the range from 4 to 10.  Now, it should be obvious that these  
two areas of numbers overlap.  They obviously share the numbers 4 and  
5.  So they'd have collided in our one dimensional world.

We can show how we test this by the following pseudo code:

FirstMinimumValue = 0;
FirstMaximumValue = 5;
SecondMinimumValue = 4;
SecondMaximumValue = 10;

//  here's the test to see if they overlap

if((FirstMaximumValue >= SecondMinimumValue) && (FirstMinimumValue <=  
SecondMaximumValue))

If this statement is true, then it shows that these two ranges of  
numbers would be overlapping. if not, then they aren't .  lol!

NOw, the above code at the beginning of this note just does this same  
operation in three dimensions to check for a collision or overlap of  
two boxes.  It's just a statement to check three different ranges of  
numbers to see if they all overlap somewhere.  this is really all  
there is to bounding boxes.

  Of course, once you know there is a collision, you can do / check  
for, all kinds of things, but the basic routine is simple.

I hope this helps and please don't hesitate to send along any questions.

Am on my way to forget all this math stuff for a while and have an  
awesome workout!  woohoo!

Have a totally awesome day and rock on!…

Smiles,

Cara  :)

---
View my Online Portfolio at:

http://www.onemodelplace.com/CaraQuinn

Follow me on Twitter!

https://twitter.com/ModelCara

On Apr 24, 2013, at 1:39 AM, Ken The PionEar <[email protected]> wrote:

I'm starting another community project.
Right now, I have a very rudamentary soundscape explorer. It has no game play 
elements as of yet. What it does have is an external map file so I can create 
whole worlds, not just minigames like Heli. I don't even have proper collision 
subroutines worked out yet, because the main goal was getting a program up and 
running that actually used an external file for its map.
Here's how it works. The map generates objects in the form of cubes, having 
length, width, and height. (Think of each sound source as a speaker.) In this 
map there are two sound sources, each source having two speakers. The band, 
stationary for now, is right in front of you. Just hold down the up arrow or 
move the mouse forward and you'll crash right into it--and through it. The 
birds are toward the lower left-hand corner and up in the sky. Since they're up 
higher you can hear them from farther away. If you want to crash into them 
you'll have to find them, then ascend by pressing the i key. Press k to descend.

What would be really cool is if one of you advanced devs could convert this 
into vb.net. I never have been able to learn well from manuals, but if I can 
see this code in vb.net I'll learn what I need. I understand the premises of 
classes and modules and all that. I get object oriented programming to a point. 
What I don't know is, well, where to even begin with vb.net. I can't figure how 
to do 3d sound for example, but I can't even write a simple hello world starter 
program for that matter, so a vb.net version of this would be awesome.
Here's the link.
https://dl.dropboxusercontent.com/u/96692612/SoundscapeExplorer.zip
---
Gamers mailing list __ [email protected]
If you want to leave the list, send E-mail to [email protected].
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/[email protected].
If you have any questions or concerns regarding the management of the list,
please send E-mail to [email protected].


---
Gamers mailing list __ [email protected]
If you want to leave the list, send E-mail to [email protected].
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/[email protected].
If you have any questions or concerns regarding the management of the list,
please send E-mail to [email protected].

Reply via email to