### Welcome, Unregistered.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 19-Aug-2003, 11:15 #1 ShinHoshi Member   Join Date: Aug 2003 Location: Barcelona Posts: 132 Help implementing collision detection Sorry if this is not the place for this. I am making a game for one of my University subjects and I am having problems with the collision detection. Right now I use a simple but fast sphere-based collision detection system. The problem of it is that it detects collisions a lot of time before "the real collision" happens. I am actually looking for a box-based system. That's the one I am currently using. I found it on gamedev. Very simple to understand and implement. The problem is that is too unefficient. bool bSphereTest(Object3D* obj1, Object3D* obj2 ) { point relPos = obj1->GetPos() - obj2->GetPos(); //Calculem el vector entre els 2 float dist = relPos.x * relPos.x + relPos.y * relPos.y + relPos.z * relPos.z; //DistĂ*ncia que els separa float minDist = obj1->GetRadi() + obj2->GetRadi(); //La suma de les 2 distĂ*ncies return dist <= minDist * minDist; //Si aixĂ˛ es compleix vol dir que s'estan tocant ! retornem 1 } Can you give me the scopes of a better algorythm ??? __________________ Shos !!!
 19-Aug-2003, 11:56 #2 Humus Crazy coder   Join Date: Feb 2002 Location: Stockholm, Sweden Posts: 3,216 What kinds of objects are you collision detecting? Are there any static objects? __________________ [ Visit my site ] I speak for myself and only myself.
 19-Aug-2003, 13:09 #3 ShinHoshi Member   Join Date: Aug 2003 Location: Barcelona Posts: 132 They are tanks in a 3D field. Only the x and z coordinates vary since the y is invariable. But I plan on put other objects such as houses, trees...and I would like to use the same collision detection system. __________________ Shos !!!
 19-Aug-2003, 14:05 #4 epicstruggle Passenger on Serenity   Join Date: Jul 2002 Location: Object in Space Posts: 1,891 does the turret stick out beyond the body of the tank? If it does, do you have to keep it that way? if the turret does not extend beyond the body of the tank then a simple bounding box should do the trick. later, epic __________________ "everyone is entitled to his own opinion, but not his own facts"
 21-Aug-2003, 15:42 #5 ShinHoshi Member   Join Date: Aug 2003 Location: Barcelona Posts: 132 I've tried to use a Bounding Box but it doesn't seem to work. First when loading the 3D model from the .ASE file, I save the greatest x, y, z coordinate in order to make the box. Then, every time I want to check a colision I create 4 points for the object to test (if I had movement in the Y-AXIS they would be 8) and for each point I test if it colides with the box of the other object. //Hem de mirar en quins 3 eixos es toquen bool bBoxTest(Object3D* obj1, Object3D* obj2 ) { float overlapx, overlapy,overlapz; obj1->calcular_BB(); for(int i=0;i<4;i++) { if(obj2->GetPos().x+obj2->caixa_contenidora.xmax<=obj1->test_points[i].x) return false; if(obj2->GetPos().x-obj2->caixa_contenidora.xmax>=obj1->test_points[i].x) return false; if(obj2->GetPos().z+obj2->caixa_contenidora.zmax<=obj1->test_points[i].z) return false; if(obj2->GetPos().z-obj2->caixa_contenidora.zmax>=obj1->test_points[i].z) return false; } return true; } However, it doesn't seem to work. __________________ Shos !!!
 21-Aug-2003, 17:56 #6 ShinHoshi Member   Join Date: Aug 2003 Location: Barcelona Posts: 132 I've found the problem. Probably nobody cares but I solved it: quins 3 eixos es toquen bool bBoxTest(Object3D* obj1, Object3D* obj2 ) { // float overlapx, overlapy,overlapz; bool sit=false; obj1->calcular_BB(); for(int i=0;i<4;i++) { sit=true; if(obj2->GetPos().x+obj2->caixa_contenidora.xmax<=obj1->test_points[i].x) sit= false; if(obj2->GetPos().x-obj2->caixa_contenidora.xmax>=obj1->test_points[i].x) sit= false; if(obj2->GetPos().z+obj2->caixa_contenidora.zmax<=obj1->test_points[i].z) sit= false; if(obj2->GetPos().z-obj2->caixa_contenidora.zmax>=obj1->test_points[i].z) sit= false; if(sit) return true; } return false; } __________________ Shos !!!

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home News Forums     Beyond3D News         Press Releases         Beyond3D Articles Core Forums     3D Architectures & Chips         3D Beginner's Questions     3D Technology & Algorithms         3D Programming & Tools     3D Hardware, Software & Output Devices         Video Technology, Displays, & HTPC     3D & Semiconductor Industry     GPGPU Technology & Programming Embedded 3D Forums     Console Forum         Console Technology         Console Games             PC Games     Handheld Gaming     Handheld Technology     CellPerformance@B3D PC Forums     Hardware & Software Talk         Politics & Ethics of Technology         Unix, Mac, & BSD (3D)     Processor & Chipset Technology     Purchase Decisions Help     PC Games         Console Games Site Forums     General Discussion     Folding For Beyond3D Team #32377     Industry Jobs     Site Feedback Beyond3D Hall of Fame     Pre-release GPU Speculation     General 3D Technology     Consoles     Other

 Similar Threads Thread Thread Starter Forum Replies Last Post pipo Console Technology 87 26-Jun-2005 05:58 K.I.L.E.R 3D Technology & Algorithms 4 19-Jun-2005 23:03 AlStrong 3D Technology & Algorithms 9 29-Jul-2004 08:16 ShePearl 3D Architectures & Chips 196 27-May-2004 09:11 Ooh-videogames Console Technology 21 24-Feb-2003 02:47

All times are GMT +1. The time now is 08:04.

 -- vB3D -- vBulletin Default Style Contact Us - Beyond3D - Archive - Top