Thanks for the replies, I figured out my problems. As for sliding vs rolling, once the angular velocity of the ball matches the linear velocity, the point where the ball is in contact with the ground, the relative velocity is zero. Therefore the ball is technically at rest so there is no friction.
To account for slipping from the ball sliding + the ball spinning during my "slide" state, I calculate the velocity at the point of contact which is the sum of the velocity at the center of mass and the radius x angular velocity. I find my friction from that velocity and apply it to the center of mass and also as a torque.
if ( bodyState == STATE_SLIDING ){ // -- find the velocity at a point on the surface of the ball contactVec = new Vector3D( 0.0, 0.0, radius ); vp = angularVelocity.crossProduct( contactVec ); vp.incrementBy( velocity ); vp.normalize(); // -- friction is a vector in the opposite direction of the velocity vp.scaleBy( -MU_SLIDE * gravity * mass ); addForce( vp, contactVec );}
as for my addForce method, it applies a force to the center of mass as well as a torque based off a point from the cm
public function addForce( af : Vector3D, point : Vector3D ) : void{ atRest = false; force.incrementBy( af ); torque.incrementBy( point.crossProduct( af ) ); }
I tried my code with top spin and back spin and the results look good.
Here is a link to my project as a swf. Click anywhere in the swf to shoot the ball. Currently, it's hard coded to add backspin at the hit.
http://megaswf.com/view/215cfff8869689bdfaa557a1df99ab53.html