collision sytem issue i think...(solved)

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
saulotmalo
Posts: 54
Joined: Wed Oct 04, 2006 6:56 am

collision sytem issue i think...(solved)

Post by saulotmalo »

hello, i'm working on irrlitch since 2 months but i still have a question without answer :( i break my brain out in order to do a collision system on an arkanoid.

first i put the bounding boxes of the bloks in a triagle selector then i make a line with the scaled and translated bounding box of the ball. but somethimes the ball "do as he want" and break a blok but continues walking :( i've spend at least 3 days on this :(

here is the code

Code: Select all

     core::vector3df  vertices[4];//here store the coordinates of the bounding box scaled
     vertices[0].set(core::vector3df(-1.25,1.25,0));
     vertices[1].set(core::vector3df(1.25,1.25,0));
     vertices[2].set(core::vector3df(1.25,-1.25,0));
     vertices[3].set(core::vector3df(-1.25,-1.25,0));   
     bool f=false;  
     for(int h=0;h<3;h++){    	 

     //node->getBoundingBox().getEdges(vertices);
     line.start=vertices[h]+node->getPosition();
     line.end=vertices[h+1]+node->getPosition();
     for (int i=0;i<selectoresBlokes.size();i++){//para que no ocurran errores es mejor primero comprobar paredes, luego comprobar otras cosas y así...

         if(smgr->getSceneCollisionManager()->getCollisionPoint(line,selectoresBlokes[i], colision,triangulo)){
             ITriangleSelector * tsAux;
             f=true;
             tsAux=selectoresBlokes[selectoresBlokes.size()-1];
             selectoresBlokes[i]=tsAux;
             selectoresBlokes.pop_back();
             blokes[i]->remove();
             blokes[i]=blokes[blokes.size()-1];
             blokes.pop_back();
             var=triangulo.getNormal();
             if (var.X > 10){
                 modo=0;break;
             }
             if (var.X < -10){
                 modo=1;break;
             }
             if (var.Y > 10){
                 modo=2;break;
             }
             if (var.Y < -10){
                 modo=3;break;
             }
         }
      }
      if(f)break;
      }

also, if someone wants the windows executable i can send it.
Last edited by saulotmalo on Mon Jan 15, 2007 4:27 am, edited 1 time in total.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

This is probably no help, but it would nice to see a physics sdk used in this kind of game :D
saulotmalo
Posts: 54
Joined: Wed Oct 04, 2006 6:56 am

Post by saulotmalo »

I think actually the physics sdk is very hard to use, but if I have time i'll try it, also i want to port my game to psp when it is complete and i don't know if exist any physics sdk :(
saulotmalo
Posts: 54
Joined: Wed Oct 04, 2006 6:56 am

Post by saulotmalo »

finally it worked but... i had to change alot of things :(. i want to say what i did if someone needs help i'll send the code by mp.

when collisions 2 box on the corner there can be that the collision algorithm test first the wall that does not want to test. I've solved this saying if the ball continues having the same movement as before chage the movement of the axys that don't have to... it sounds weird but works for my game.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Good Work :D
Post Reply