JV-ODE Physics Thread 5

Blitz3D Forums/Blitz3D Userlibs/JV-ODE Physics Thread 5

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Good Work Viper! Now that you can access fdir1 i have decided to release here the code to make proper wheels friction:

	Vector3 front;
	Vector3 up;
	dReal const * vel = dBodyGetLinearVel( wheel );

	int inv = 1;
	//  Compute fDir1 if a wheel
	dReal const * R = dBodyGetRotation( wheel );
	front = Vector3(R[2] * inv,R[6] * inv,R[10] * inv);
	up = Vector3(R[1] * inv,R[5] * inv,R[9] * inv);
		//  Set Slip2
	contact->surface.mode |= dContactFDir1;
	float v = sqrtf( vel[0]*vel[0] + vel[1]*vel[1] + vel[2]*vel[2] );
	//contact.surface.slip2 = TIRE_SLIP * v;				
	//  re-tweak mu and mu2
	//contact.surface.mu = contact.surface.mu2 = TIRE_MU;
	//  The theory is that it doesn't matter if "front" points "up" 
	//  because we want fdir2 to be orthogonal to "front" and contact 
	//  normal. Of course, if "front" points in the direction of the 
	//  contact, this can be a problem. In that case, choose "up".
	if( fabsf( dDot( contact->geom.normal, &front.x, 3 ) ) > 0.5f ) 
		{
		((Vector3 &)contact->fdir1) = up;
		}
	else
		{
		((Vector3 &)contact->fdir1) = front;
		}


Dvector3 is float[3] and dReal is float.

The code is based on the cardemo of official ode threads, and it is c++, but it should be easy to be included by Viper on the wrapper or by anyone in Blitz3D!

Happy Holidays Everyone!