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;
}