friction request

misterface

02-03-2006 02:36:54

how can you set friction between 2 objects?
f.e. car and ground?

walaber

02-03-2006 03:17:38


OgreNewt::MaterialID* def_mat = mWorld->getDefaultMaterialID();
OgreNewt::MaterialID* other_mat = new Ogre::MaterialID( mWorld );

OgreNewt::MaterialPair* mat_pair = new OgreNewt::MaterialPair( mWorld, def_mat, other_mat );

mat_pair->setDefaultFriction( 1.0f, 0.9f );


then, apply these materials to bodies accordingly. body->setMaterialID().

misterface

02-03-2006 17:37:13


const OgreNewt::MaterialID* def_mat = m_World->getDefaultMaterialID();
OgreNewt::MaterialID* other_mat = new OgreNewt::MaterialID( m_World );
OgreNewt::MaterialPair* mat_pair = new OgreNewt::MaterialPair( m_World, def_mat, other_mat );
mat_pair->setDefaultFriction( 1.0f, 0.9f );



problem: MaterialID *ID instead of MaterialPair* in fonction below

bodRoot->setMaterialGroupID(const OgreNewt::MaterialID *ID);


(body->setMaterialID() does not exist btw)

Horizon

02-03-2006 17:56:28

That's because you assign the materials, not the materialpairs, to bodies.

misterface

02-03-2006 18:10:11

got it, thx both :)

misterface

02-03-2006 20:29:03

OgreNewt::Vehicle::Tire Class Reference

void setBrakeAcceleration (Ogre::Real accel, Ogre::Real limit) const

can somebody say what this function does exactly?
accel: acceleratin of the tire, so negative is braking???
limit: no idea

walaber

02-03-2006 23:00:22

yup. accel is how much you want to stop the tires, and limit is any limit on how much force the brake system can work (like the braking limit of the car's brake pads).

so if the accel you pass results in a force larger than limit, limit will be used instead.

misterface

04-03-2006 17:43:07

void SimpleVehicle::lets_brake_this_car(Ogre::Real accel, Ogre::Real limit)
{
for (SimpleTire* tire = (SimpleTire*)getFirstTire(); tire; tire=(SimpleTire*)getNextTire(tire))
{
//tire->setLongitudinalSlipCoefficient(0);
//tire->setMaxLongitudinalSlipSpeed(0);
//tire->setMaxSideSlipSpeed(0);
//tire->setSideSlipCoefficient(0);
//tire->setTorque(0);

tire->setBrakeAcceleration(limit-1, limit);
tire->updateNode();
}}


When I call this function, nothing happens, why
:? :)

walaber

05-03-2006 01:34:22

you can only call that function from the vehicle callback (userCallback) function. almost all of the vehicle functions have that limitation, that should be noted in the documentation (and therefore the header files).

misterface

05-03-2006 19:04:35

thx!!