SoftBody Vehicle not translating

Xcoder79
Posts: 42
Joined: Sun Aug 07, 2011 5:27 am

SoftBody Vehicle not translating

Post by Xcoder79 »

Hi, Im trying to build a SoftBody Vehicle using Angular and Linear Joints just like the softbody Bunny car in the demo it seems to be kind of
working I have the wheels spinning but the Body of The Vehicle looks like it dosent wont to move at all.

here is my code that im using and a short video describing my problem.

http://youtu.be/TOL-oKqZnW0


Truck->m_cfg.kDF =1 ;
Truck->m_cfg.kDP =1;
Truck->generateClusters(64);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Wheel->m_cfg.kDF =1;
Wheel->m_cfg.kDP = 1;
Wheel->generateClusters(64);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Wheel2->m_cfg.kDF =1;
Wheel2->m_cfg.kDP = 1;
Wheel2->generateClusters(64);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


//
static struct MotorControl : btSoftBody::AJoint::IControl
{
MotorControl()
{
goal=0;
maxtorque=0;
}
btScalar Speed(btSoftBody::AJoint*,btScalar current)
{
return(current+btMin(maxtorque,btMax(-maxtorque,goal-current)));
}
btScalar goal;
btScalar maxtorque;
} motorcontrol;

//
struct SteerControl : btSoftBody::AJoint::IControl
{
SteerControl(btScalar s)
{
angle=0;
sign=s;
}
void Prepare(btSoftBody::AJoint* joint)
{
joint->m_refs[0][0]=btCos(angle*sign);
joint->m_refs[0][2]=btSin(angle*sign);
}
btScalar Speed(btSoftBody::AJoint* joint,btScalar current)
{
return(motorcontrol.Speed(joint,current));
}
btScalar angle;
btScalar sign;
};

static SteerControl steercontrol_f(+1);
static SteerControl steercontrol_r(-1);


motorcontrol.maxtorque=40;motorcontrol.goal+=3;
// steercontrol_f.angle+=1;steercontrol_r.angle+=1;

Wheel->setFriction( (btScalar)2.50 );
Wheel2->setFriction( (btScalar)2.50 );

btSoftBody::LJoint::Specs ls;
ls.cfm = 1;
ls.erp = 1;
ls.position = btVector3(0, 0, 0);
Truck->appendLinearJoint(ls,Wheel);
Truck->appendLinearJoint(ls,Wheel2);


btSoftBody::AJoint::Specs aspecs;
aspecs.cfm = 1;
aspecs.erp = 1;
aspecs.axis = btVector3(0,0,0);
aspecs.icontrol = &motorcontrol;
aspecs.icontrol = &steercontrol_f;
Truck->appendAngularJoint(aspecs,Wheel);
Truck->appendAngularJoint(aspecs,Wheel2);