vehicle orientation

aboeing
Posts: 33
Joined: Tue Jul 26, 2005 2:28 pm

vehicle orientation

Post by aboeing »

Hi,

I am trying to create a vehicle orientated such that the X axis is fowards.

When I do this to the vehicle demo, the car renders correctly, but the program fails an assertion as soon as the vehicle hits the ground.

This occurs at 'resolveSingleBilateral', ASSERT2(btFabs(normalLenSqr) < btScalar(1.1));

The only modifications I have made is to the axis and wheel directions:
int rightIndex = 2;
int upIndex = 1;
int forwardIndex = 0;
btVector3 wheelDirectionCS0(0,-1,0);
btVector3 wheelAxleCS(0,0,1);

Does anyone know what the problem may be?

Thanks.
ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

Post by ola »

I also use the x axis as forward axis. X forwards, Y to the right, Z down. The following code works for me. Not quite sure why. I had trouble making it work with this kind of coordinate system in the beginning..

Code: Select all

 //                         right  up  forward
 car_->setCoordinateSystem(     0, -2,       0);

 float wheel_radius        =  0.50;
 float wheel_width_front   =  0.42;
 float wheel_width_rear    =  0.54;
 float wheel_friction      =  0.9;
 float roll_influence      =  0.9;
 
 float suspension_rest_length =  0.2;
 float suspension_stiffness   = 60.0; // 60.0
 float suspension_damping     = 5.0;  // 5.0
 float suspension_compression = 3.0;  // 3.0
 
 btVector3 wheel_direction( 0.0, 0.0, 1.0); // pointing down
 btVector3 wheel_axle     ( 0.0, 1.0, 0.0); // pointing to the right
 
 float wheel_z = 0.1;
  
 btVector3 wheelpos_front_left (  1.40, -1.35, wheel_z);
 btVector3 wheelpos_front_right(  1.40,  1.35, wheel_z);
 btVector3 wheelpos_rear_left  ( -1.60, -1.35, wheel_z);
 btVector3 wheelpos_rear_right ( -1.60,  1.35, wheel_z);

 car_->addWheel( wheelpos_front_left,  wheel_direction, wheel_axle, suspension_rest_length, wheel_radius, car_tuning_, true);
 car_->addWheel( wheelpos_front_right, wheel_direction, wheel_axle, suspension_rest_length, wheel_radius, car_tuning_, true);
 car_->addWheel( wheelpos_rear_left,   wheel_direction, wheel_axle, suspension_rest_length, wheel_radius, car_tuning_, false);
 car_->addWheel( wheelpos_rear_right,  wheel_direction, wheel_axle, suspension_rest_length, wheel_radius, car_tuning_, false);
 
 for(int i=0; i<car_->getNumWheels(); i++)
    {
    btWheelInfo& wheel = car_->getWheelInfo(i);
    wheel.m_suspensionStiffness        = suspension_stiffness;
    wheel.m_wheelsDampingRelaxation    = suspension_damping;
    wheel.m_wheelsDampingCompression   = suspension_compression;
    wheel.m_frictionSlip               = wheel_friction;
    wheel.m_rollInfluence              = roll_influence;
    }
Cheers
Ola