void ParticleSystem::collide(ParticlePtr part, PlanePtr plane) { //SimonState::exemplar()->messages << "Cloth: Kollision Kugel vs. Ebene gestartet" << SimonState::endm; float distance = dot(part->getPosition() - plane->getRigidBody()->getPosition(), plane->getNormal()); Vector3<float> n = plane->getNormal(); Vector3<float> v = part->getVelocity(); float vDotN = dot (v, n); //Vector3<float> f = getRigidBody()->getForce(); // no resting contact. check collision if ( distance <= 3.0) { if (vDotN<=0.5f) { // normal colliding contact: Vector3 <float> velPart = part->getVelocity(); Vector3 <float> normPlane = plane->getNormal(); normPlane.normalize(); float vDoN = dot(velPart, normPlane); normPlane *= vDoN; part->setVelocity(part->getVelocity() - normPlane); //cout << "Vel aus col " << part->getVelocity()<< endl; normPlane = plane->getNormal(); normPlane.normalize(); Vector3 <float> forcePart = part->getForce(); float fDotN = dot(forcePart, normPlane); normPlane *= fDotN; part->addForce((-1) * normPlane); //cout << "Acc aus Col " << part->getAcceleration() << endl; // factor in elasticity // geschummelt (eigentlich getBounciness) //vDotN *= 1 + 2.5f; // reflect veloctiy along normal //part->setVelocity( Vector3<float>(v[X] - vDotN*n[X], v[Y] - vDotN*n[Y], v[Z] - vDotN*n[Z])); SimonState::exemplar()->messages << "Cloth: Kollision Particle vs. Ebene beendet" << SimonState::endm; } } }