void PhysicsSystem::BroadPhaseCollisions() { for(vector<PhysicsNode*>::iterator i = allNodes.begin() ; i != allNodes.end(); ++i) { if((*i)->isPlane) { for(vector<PhysicsNode*>::iterator j = i; j != allNodes.end(); ++j) { if(*i != *j) { c_Sphere c2 = c_Sphere((*j)->GetPosition(), 50); CollisionData cd = CollisionData(); if(SphereInPlane((*j)->GetPosition(), c2.m_radius, c2, &cd)) { AddCollImpulse2(*j, cd); //(*j)->SetLinearVelocity((*j)->GetLinearVelocity()); //Vector3 temp = (*j)->GetLinearVelocity(); //temp.y = -temp.y; //(*j)->SetLinearVelocity(temp); } } } } //Getting the position from and making the spaceship backfire. if(((*i))->isShip && (*i)->isHit == false) { RandPos = (*i)->GetPosition();// + Vector3(100, 100, 100); //hitCount++; } //Check if hit the player/camera. if((*i)->isBackFire) { cubeAABB a = cubeAABB((*i)->GetPosition(), Vector3(100,100,100)); cubeAABB b = cubeAABB(CamPos, Vector3(300, 300, 300)); if(AABBCollision(a, b)){ lifes -= 1; jitter = true; } } for(vector<PhysicsNode*>::iterator j = i; j != allNodes.end(); ++j) { if(*i != *j) { c_Sphere c1 = c_Sphere((*i)->GetPosition(), 50); c_Sphere c2 = c_Sphere((*j)->GetPosition(), 50); CollisionData cd = CollisionData(); if(SphereSphereCollision(c1, c2, &cd) == true){ AddCollisionImpulse(*i, *j, cd); (*i)->m_HasHit = true; if((*i)->isShip == true) { ((*i))->isHit = true; score += 100; pos = ((*i))->GetPosition(); } } // AI if (AI){ if((*i)->isShip && (*j)->isMissile) { if(*i != *j) { Vector3 a = (*i)->GetPosition(); Vector3 b = (*j)->GetPosition(); float diffX = abs(a.x-b.x); float diffY = abs(a.y-b.y); float diffZ = abs(a.z-b.z); Vector3 diff = Vector3(diffX, diffY, diffZ); float sep; sep = (AIlevel == 0) ? 100.0 : 150.0f; if(diff.x <= 100) { if(diff.y <= 100) { if(diff.z <= 100) { (*i)->SetPosition((*i)->GetPosition() + Vector3(100, 100, 100)); RandPos = (*i)->GetPosition() + Vector3(100, 100, 100); } // add force or velo or acce } } } } } } } } }
CollisionData iTest(const ConvexHull & chull, const AABB & rect) { return CollisionData(); }
CollisionData iTest(const ConvexHull & chull, const Plane & plane) { return CollisionData(); }
CollisionData iTest(const ConvexHull & chull, const Ray & ray) { return CollisionData(); }
CollisionData iTest(const ConvexHull & chull, const Circle & circle) { return CollisionData(); }
CollisionData iTest(const ConvexHull & chullA, const ConvexHull & chullB) { return CollisionData(); }