void CEntity::handleStaticCollision(CVector2D & collisionNormal)
{
float impulse;
CVector2D VRelativeVelocity;
collisionNormal.normalize();
VRelativeVelocity = this->m_VLinearVelocity;
VRelativeVelocity *= -(1 + this->m_coeffOfRestitution);
float inverseMassSum;
inverseMassSum = (1 / this->m_mass) + (1 / 10000000 // - MASS- because its a non moveable object);
float tester = collisionNormal.dotProduct(collisionNormal * inverseMassSum);
impulse = (VRelativeVelocity.dotProduct(collisionNormal)) / collisionNormal.dotProduct(collisionNormal * inverseMassSum);
this->m_VLinearVelocity = this->m_VLinearVelocity + collisionNormal * (impulse / this->m_mass);
}
reaction off non moveable object
I have the collision and a reaction working, I dont yet have the reaction I want... i am just apply the inverse force of the object thus sending him back from where he came... all i want is to find the correct perp angle to send it.. is there a way to do that if you only know 2 points
p1(the point that made contact with imoobile object)
p2( the previous point that had no contact).....
currnetly i am finding the collision normal by taking (p2 - p1) ...
I am not looking for a perfect reaction just one that would send the obeject in the correct 45degree perp..
heres what i got
any ways.. if anyone can shine some light please do......
h
This formula computes the new direction, given the original direction (D) and the normal to the surface (N). Both must be normalized.
Dreflected = D - 2 * dot( N, D ) * N
Dreflected = D - 2 * dot( N, D ) * N
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement