please, help with raycast vehcle example

jmramon
Posts: 2
Joined: Sat Dec 31, 2011 1:46 pm

please, help with raycast vehcle example

Post by jmramon »

Hello all,

This is my first post and first of all, Thank you for this wonderfull physics software.

Right now, I'm developing an Indie race game. I chose Bullet for the physics and I integrated the vehicle example in the engine code but the vehicle doesn't turn correctly. The problem could be seen in this video: http://www.youtube.com/watch?v=Bwz8Sgk0 ... e=youtu.be

The settings of the raycast vehicle are:

Code: Select all

#define PHYSCAR_SCALE 1
#define CUBE_HALF_EXTENTS 1

int rightIndex = 0;
int upIndex = 1;
int forwardIndex = 2;

const int maxProxies = 32766;
const int maxOverlap = 65535;

float	gEngineForce = 0.f;
float	gBreakingForce = 0.f;

float	maxEngineForce = 100000.f;//this should be engine/velocity dependent
float	maxBreakingForce = 10000.f;

float	gVehicleSteering = 0.f;
float	steeringIncrement = 0.04f;
float	steeringClamp = 0.3f;

float	wheelRadius =  0.35f * PHYSCAR_SCALE;	
float	wheelWidth = 0.2f * PHYSCAR_SCALE;		

float	wheelFriction = 10;						

float	suspensionStiffness = 50.f;				

float	suspensionDamping =	 0.3f * 2.0f * btSqrt(suspensionStiffness);

float	suspensionCompression = 0.2f * 2.0f * btSqrt(suspensionStiffness);	

float	rollInfluence = 1.f;							

btVector3 wheelDirectionCS0(0,-1,0);
btVector3 wheelAxleCS(-1,0,0);

btScalar suspensionRestLength = 0.15f * PHYSCAR_SCALE;  


And the wheels are created like this:

Code: Select all

float connectionHeight = 1.2f;

bool isFrontWheel=true;

//choose coordinate system
m_vehicle->setCoordinateSystem(rightIndex, upIndex, forwardIndex);

// front left
btVector3 connectionPointCS0(CUBE_HALF_EXTENTS-(0.3*wheelWidth),connectionHeight,2*CUBE_HALF_EXTENTS-wheelRadius);

m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxleCS,suspensionRestLength,wheelRadius,m_tuning,isFrontWheel);	
			
// front right
connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),connectionHeight,2*CUBE_HALF_EXTENTS-wheelRadius);

m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxleCS,suspensionRestLength,wheelRadius,m_tuning,isFrontWheel);

// rear left
connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),connectionHeight,-2*CUBE_HALF_EXTENTS+wheelRadius);

isFrontWheel = false;
m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxleCS,suspensionRestLength,wheelRadius,m_tuning,isFrontWheel);
		
// rear right
connectionPointCS0 = btVector3(CUBE_HALF_EXTENTS-(0.3*wheelWidth),connectionHeight,-2*CUBE_HALF_EXTENTS+wheelRadius);

btWheelInfo& wheel_RR = m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxleCS,suspensionRestLength,wheelRadius,m_tuning,isFrontWheel);
		
for (int i=0;i<m_vehicle->getNumWheels();i++){
	btWheelInfo& wheel = m_vehicle->getWheelInfo(i);
	wheel.m_suspensionStiffness = suspensionStiffness;
	wheel.m_wheelsDampingRelaxation = suspensionDamping;
	wheel.m_wheelsDampingCompression = suspensionCompression;
	wheel.m_frictionSlip = wheelFriction;
   wheel.m_rollInfluence = rollInfluence;
}
Thank you for all and Happy New Year!
jmramon
Posts: 2
Joined: Sat Dec 31, 2011 1:46 pm

Re: please, help with raycast vehcle example

Post by jmramon »

Oh, it's my fault. I created the vehicle like a static body. Sorry! :oops: