Path: chuka.playstation.co.uk!scea!peter_alau@playstation.sony.com From: Elliott Lee Newsgroups: scee.yaroze.programming.3d_graphics Subject: Re: Collision Detection Date: Tue, 26 May 1998 12:11:57 -0700 Organization: Cisco Systems Lines: 38 Message-ID: <356B13FD.520924B6@netmagic.net> References: <35660ea7.1320731@news.playstation.co.uk> <3567CC85.C5E2D6BF@netmagic.net> <6k8shv$hca1@chuka.playstation.co.uk> Reply-To: tenchi@cisco.com NNTP-Posting-Host: dhcp-e-39-237.cisco.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.03 [en] (Win95; U) Anders Clerwall wrote: > > >There's no standard way of doing it but I'd suggest creating a > >bounding box around your 3D object. You should know the extent > >of the object in all 3 dimensions, so you just define 8 vertices > >that create the box/cube around it. Then you just test for > >intersections with other objects. > > > How exactly is this done?.. Okay, take a simple world (or "scene") that has only two objects: a couple of cubes. You should know the exact XYZ positions of them and now you want to test to see if they intersect. From that you just do a bunch of simple tests to see if things overlap in any way: 1) do the two Z values collide? if NO then STOP. 2) do the two Y values collide? if NO then STOP. 3) do the two X values collide? if NO then STOP. 4) they've collided, now deal with it. ^_^ You can visuallize the Z test this way: ---[::::::::]---------[:::::::]----- o1.z1 o1.z2 o2.z1 o2.z2 Two objects o1 and o2 with end coordinates z1 and z2. The way to check a collision is: if( (o2.z1<=o1.z2 && o2.z1>=o1.z1) || (o2.z2>=o1.z1 && o2.z2<=o1.z2) ) { // handle collision } Then you just repeat that test for the other 2 axis. This works for any number of dimensions... (e.g. X, XY, XYZ, XYZ-time, ...) - e! tenchi@netmagic.net http://www.netmagic.net/~tenchi/yaroze/