how to set up and control car in bleeding?
njw1985
26-04-2008 09:08:10
actorr = mScene->createBody("car", new NxOgre::Cube(1), Vector3(120, 5, 6), "model: gt.mesh", "mass: 1000");
actorr->setRenderMode(RenderableSource::RM_Interpolate);
f_left = new Wheel(2.5f, "position: -1 0 1", "model: gt_wheel.mesh, mode: interpolate");
actorr->addShape(f_left);
b_left = new Wheel(2.5f, "position: 1 0 1", "model: gt_wheel.mesh, mode: interpolate");
actorr->addShape(b_left);
f_right = new Wheel(2.5f, "position: -1 0 -1", "model:gt_wheel.mesh, mode: interpolate");
actorr->addShape(f_right);
b_right = new Wheel(2.5f, "position: 1 0 -1", "model:gt_wheel.mesh, mode: interpolate");
actorr->addShape(b_right);
and how to control it with key upã€
betajaen
26-04-2008 09:28:09
Usually, unless you have special circumstances, a "WheelSet" is used to create the wheels and just generally control them. Such as this example:
Body* car = mScene->createBody("car", new NxOgre::Cube(2,2,3), Vector3(6, 4, 6), "model: maddog_body.mesh", "mass: 4150");
car->setRenderMode(RenderableSource::RM_Interpolate);
// Set up the Params for all of the wheels.
WheelParams wp;
wp.setToDefault();
wp.mLocalPose.t.set(0.756, -0.55, 1.319);
wp.mSuspension.spring = 12.5e3;
wp.mSuspension.damper = 1500;
wp.mSuspensionTravel = 0.3f;
// Create the wheels.
WheelSet* mSet = WheelSet::createFourWheelSet(0.45f, float3(0.756, -0.55, 1.319), float3(-0.756, -0.55, -1.076), car, wp, "model: maddog_wheell.mesh, mode: interpolate");
// Set the wheels as front wheel drive.
mSet->setAs(WheelSet::TL_Front);
// Never make the Actor go to sleep. (important)
car->wakeUp(1e10);
And to control it:
if (mKeyboard->isKeyDown(KC_G)) {
mSet->drive(100);
mSet->brake(0);
}
else if (mKeyboard->isKeyDown(KC_B)) {
mSet->brake(25);
mSet->drive(0);
}
else {
mSet->drive(0);
}
if (mKeyboard->isKeyDown(KC_V)) {
mSet->steer(0.75);
}
else if (mKeyboard->isKeyDown(KC_N)) {
mSet->steer(-0.75);
}
else {
mSet->steer(0);
}
Hope that helps.
njw1985
26-04-2008 10:59:26
Thank u very much,but the question is:
when I push down the key 'V':all left vehicles are change, and push down key 'G',all left vehicles are rotate the axis 'X',so the car can't move!
what is wrong with it?
njw1985
26-04-2008 11:58:43
The picture is:
njw1985
27-04-2008 01:11:42
我的英文太差了,太难表达我的æ„
betajaen
27-04-2008 10:14:06
Did you do this?
// Set the wheels as front wheel drive.
mSet->setAs(WheelSet::TL_Front);
njw1985
27-04-2008 12:42:19
thank u ! I found out the problem: It is my car--wheels' question! and I change new wheels,and the result is OK! Hehe
njw1985
27-04-2008 14:22:38
Hi,,I set up wheels like this:
ww=WheelSet::createFourWheelSet(actorr, Vector3(-1.0f, -0.1f, 1.8f), Vector3(1.0f, -0.1f, -1.6f), 0.6,"",wp);
So the question is ,how to add material to wheels?
betajaen
27-04-2008 14:30:05
What kind of material; Ogre or NxOgre?
PhysX/NxOgre doesn't use materials for wheels (Look up API documentation and use it with the WheelParams), and for Ogre just set up the material for when you create the mesh.
njw1985
27-04-2008 14:45:22
I can't stop my car!
so how to add friction to wheels?
betajaen
27-04-2008 15:15:55
Via the WheelParams, like I just said. Read the PhysX API Documentation that is installed when you install the PhysX SDK. It's all there.
njw1985
27-04-2008 15:43:22
OK,OK,
Thank u,thank you!!
twilight17
27-04-2008 15:57:55
Heh reading this thread made me laugh
betajaen
27-04-2008 16:03:49
Heh reading this thread made me laugh
Lost in Translation.
njw1985
28-04-2008 01:37:58
Heh reading this thread made me laugh
我æ
njw1985
29-04-2008 08:02:50
my car so slip,and I try many many times,but can't solve,,
at last ,I felt so tired,,,and hope people can solve it for me,,,many thanks!!!
ShapeParams ssp;
ssp.mMaterialAsName="BumperCarMaterial";
-------can't solve
///////////////////////////////////
ww.frontLeft->getNxWheelShape()->setMaterial(mScene->getMaterialIndex("BumperCarMaterial"));
ww.frontRight->getNxWheelShape()->setMaterial(mScene->getMaterialIndex("BumperCarMaterial"));
ww.backLeft->getNxWheelShape()->setMaterial(mScene->getMaterialIndex("BumperCarMaterial"));ww.backRight->getNxWheelShape()->setMaterial(mScene->getMaterialIndex("BumperCarMaterial"));
-------can't solve
////////////////////////////////////
set the wheelparams like this:
NxOgre::WheelParams wp;
wp.setToNormal();
wp.suspension_damper = 1.0f;
wp.suspension_spring = 25000.0f;
wp.suspension_target = 0.0f;
wp.suspension_travel = 0.1f;
wp.clamped_friction = true;
wp.emulate_legacy_wheel = false;
wp.unscaled_spring_behavior = false;
wp.axle_speed_override = false;
wp.input_lat_slipvelocity = true;
wp.input_long_slipvelocity = true;
wp.lateral_tire_asymptoteSlip = 2.0f;
wp.lateral_tire_asymptoteValue = 0.007f;
wp.lateral_tire_extremumSlip = 0.15f;
wp.lateral_tire_extremumValue = 0.6f;
wp.lateral_tire_stiffnessFactor = 10.0e3f;
wp.longitudal_tire_asymptoteSlip = 2.0f;
wp.longitudal_tire_asymptoteValue = 0.7f;
wp.longitudal_tire_extremumSlip = 0.15f;
wp.longitudal_tire_extremumValue = 1.0f;
wp.longitudal_tire_stiffnessFactor = 30.0e3f;
wp.inverseWheelMass = 0.2f;
---------can't solve
so my god!!!!
who can save me?