diff options
| author | Jesse Morgan <jesse@jesterpm.net> | 2011-02-21 07:47:13 +0000 | 
|---|---|---|
| committer | Jesse Morgan <jesse@jesterpm.net> | 2011-02-21 07:47:13 +0000 | 
| commit | 1e08b5f73ed83d4d5d7050776f096630e52f0787 (patch) | |
| tree | e9b902521bf9f9c06d6d2300dcb818153f174dd1 /src/alden/CollidableObject.java | |
| parent | 525ae2426f46d2b5380b0153f3f2bba836f02ab8 (diff) | |
Not perfect, but here we go.
Diffstat (limited to 'src/alden/CollidableObject.java')
| -rw-r--r-- | src/alden/CollidableObject.java | 47 | 
1 files changed, 27 insertions, 20 deletions
| diff --git a/src/alden/CollidableObject.java b/src/alden/CollidableObject.java index 7246609..1f0d285 100644 --- a/src/alden/CollidableObject.java +++ b/src/alden/CollidableObject.java @@ -51,7 +51,7 @@ public abstract class CollidableObject {  		coefficientOfRestitution = 0.75f;
  		penetrationCorrection = 1.05f;
  		dynamicFriction = 0.02f;
 -		rotationalFriction = 0.3f;
 +		rotationalFriction = 0.05f;
  		TG = new TransformGroup();
  		TG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
  		BG = new BranchGroup();
 @@ -237,25 +237,6 @@ public abstract class CollidableObject {  				acceleration.scaleAdd(-1, other.previousVelocity, other.velocity);
  				other.velocity.scaleAdd(dynamicFriction * acceleration.dot(ci.contactNormal), perpVelocity, other.velocity);
  			}
 -			
 -			/* Rotational Friction */
 -			Vector3f w = new Vector3f();
 -			
 -			float radius = thisRelativeContactPosition.length();
 -			w.cross(angularVelocity, ci.contactNormal);
 -			velocity.scaleAdd(-1, previousRotationalVelocity, velocity);
 -			previousRotationalVelocity.scale(radius, w);
 -			velocity.scaleAdd(radius, w, velocity);
 -			
 -			radius = otherRelativeContactPosition.length();
 -			w.cross(other.angularVelocity, ci.contactNormal);
 -			other.velocity.scaleAdd(-1, other.previousRotationalVelocity, other.velocity);
 -			other.previousRotationalVelocity.scale(radius, w);
 -			other.velocity.scaleAdd(radius, w, other.velocity);
 -			
 -			
 -			angularVelocity.scaleAdd(-rotationalFriction * ci.contactNormal.dot(angularVelocity), angularVelocity, angularVelocity);
 -			other.angularVelocity.scaleAdd(-rotationalFriction * ci.contactNormal.dot(other.angularVelocity), other.angularVelocity, other.angularVelocity);		
  		}
  		Vector3f thisMovementUnit = new Vector3f();
 @@ -300,5 +281,31 @@ public abstract class CollidableObject {  		tmp2.mul(other.orientation);
  		other.orientation.add(tmp2);
  		other.orientation.normalize();
 +		
 +		if (rotationalFriction > 0) {
 +			/* Rotational Friction */
 +			Vector3f w = new Vector3f();
 +			
 +			/*float radius = thisRelativeContactPosition.length();
 +			w.cross(angularVelocity, ci.contactNormal);
 +			velocity.scaleAdd(-1, previousRotationalVelocity, velocity);
 +			previousRotationalVelocity.scale(radius, w);
 +			velocity.scaleAdd(radius, w, velocity);
 +			w.cross(previousRotationalVelocity, ci.contactNormal);
 +			angularVelocity.scaleAdd(-0.5f * w.dot(angularVelocity), w, angularVelocity);
 +			
 +			radius = otherRelativeContactPosition.length();
 +			w.cross(other.angularVelocity, ci.contactNormal);
 +			other.velocity.scaleAdd(-1, other.previousRotationalVelocity, other.velocity);
 +			other.previousRotationalVelocity.scale(radius, w);
 +			other.velocity.scaleAdd(radius , w, other.velocity);
 +			w.cross(other.previousRotationalVelocity, ci.contactNormal);
 +			other.angularVelocity.scaleAdd(-0.5f * w.dot(other.angularVelocity), w, other.angularVelocity);
 +			*/
 +			
 +			angularVelocity.scaleAdd(-rotationalFriction * ci.contactNormal.dot(angularVelocity), ci.contactNormal, angularVelocity);
 +			other.angularVelocity.scaleAdd(-rotationalFriction * ci.contactNormal.dot(other.angularVelocity), ci.contactNormal, other.angularVelocity);
 +			
 +		}
  	}
  }
 | 
