Bleeding Vehicle questions
SteelX
19-07-2008 15:03:46
Well not all about vehicles.
I have some vehicle code.
this my physx scene
m_physxScene = m_World->createScene("escena",m_sceneMgr,"renderer: ogre, controller: accumulator, gravity: yes, floor: yes");
m_body = m_physxScene->createBody( "carActor",new NxOgre::Cube(1.0f), NxOgre::Pose(mMainNode->getPosition(),
mMainNode->getOrientation()),renderableParams ,"mass:5000" );
m_body->setRenderMode(NxOgre::RenderableSource::RM_Interpolate);
NxOgre::WheelParams wheelP;
wheelP.setToDefault();
wheelP.mMass = 150.0f;
wheelP.mLocalPose.t.set(30 , -30.9 , 53.5 );
//wheelP.mDensity = 100.0f;
wheelP.mSuspension.spring = 27150.0f;
wheelP.mSuspension.damper = 1500;
wheelP.mSuspension.targetValue = 0.0f;
wheelP.mSuspensionTravel = 0.3f;
m_wheelSet = NxOgre::WheelSet::createFourWheelSet( 3.50f , NxOgre::float3( 30 , -30.9 , 53.5 ),
NxOgre::float3( -30 , -30.9 , -49.0 ), m_body, wheelP, "model: jeep_wheell.mesh, mode: interpolate, scale:30 30 30");
m_wheelSet->setAs( NxOgre::WheelSet::TL_Front );
m_body->wakeUp( 1e10 );
m_body->setSleepEnergyThreshold( 0.0 );
and the listener
if (input->isKeyDown (OIS::KC_UP))
{
m_wheelSet->drive(200);
m_wheelSet->brake(0);
}else if (input->isKeyDown (OIS::KC_DOWN))
{
m_wheelSet->brake(25);
m_wheelSet->drive(0);
}else
{
m_wheelSet->drive(0);
}
if (input->isKeyDown (OIS::KC_LEFT))
{
m_wheelSet->steer(0.75);
}else if (input->isKeyDown (OIS::KC_RIGHT))
{
m_wheelSet->steer(-0.75);
}else
{
m_wheelSet->steer(0);
}
and the questions
-how to show the gizmos to handle debug issue??
i tried with:
m_World->getPhysXDriver()->setVisualisationCollisionShapesEnabled(true);
m_World->getPhysXDriver()->setVisualisationCollisionSpheresEnabled(true);
m_World->getPhysXDriver()->setVisualisationCollisionStaticEnabled(true);
- the vehicle need static mesh, like a plane or a terrain to move??
- when i try to setup left and right wheels , rear wheel are together at same place, could you give some example using left and right wheels??
i'm using:
m_wheelSet = NxOgre::WheelSet::createFourWheelSet( 3.50f , NxOgre::float3( 30 , -30.9 , 53.5 ),
NxOgre::float3( -30 , -30.9 , -49.0 ), m_body, wheelP, "model: jeep_wheell.mesh, mode: interpolate, scale:30 30 30","model: jeep_wheelr.mesh, mode: interpolate, scale:30 30 30" );
thx for appreciated help.
zissakos
19-07-2008 21:29:09
just do this:
m_World->createDebugRenderer(m_sceneMgr);
SteelX
20-07-2008 03:36:15
Thx zissakos
now i can see the gizmos. i still need some little orientation about wheel issue.
.thx for the answer
SteelX
22-07-2008 03:13:20
Hi again.
here is an screenshot about vehicle.
the vehicle is in a big hole at the center.
also still i need add right wheels mesh and rear wheel appear at same place.
well the car is not moving i need some help with this.
zissakos
22-07-2008 12:36:36
that's probably because the car is too heavy (5000 kg) for the torque you are applying (m_wheelSet->drive(200); )
you should try different settings (like ->drive(2000) for example).
actually, this is the point where I am stuck right now as well, trying to find good settings for the whole car setup. Mass and torque is one thing, then you will find it necessary to tweak other settings, too, like Tirefunctions etc.
My car is flipping over all the time, or pitching up when accelerating...
Unfortunately, there is no good official best setting for all this, everybody must try this for their own application.
SteelX
22-07-2008 16:06:56
thx again zissakos. and what is the meaning of the big circle(hole) where the car is?
zissakos
22-07-2008 21:14:21
that's the visualization of the floor of the DebugRenderer. Once turned off, you won't see it.
SteelX
22-07-2008 22:46:59
Ok i understand is the floor bounding box, but the car is inside the floor, is this right??
or the floor is a big box with a hole at center, the car docks perfectly in the circle.
well i'll try later modifying some code, thx again.
regards
betajaen
22-07-2008 23:32:28
The center of the scene is those circles. The floor looks like it's below 0 for some reason, and the pink box should be the bounding box of the car chassis.
You can turn on or off parts of the debug renderer using the many many visualization functions in PhysXDriver.
@zissakos
The standard setup for a car in NxOgre is to lower the center of mass of the chassis (the cube) to below the car. Usually between 0 -0.5 0 and 0 -1.0 -0, that "mimics" extra mass and makes the car more stable. You can also try making the suspension more rigid and less bouncy.
SteelX
26-07-2008 17:14:26
I can't move the car yet, is a quite hard to do this.
well. maybe is because i scaled the car.
still have many many doubts, first i know how to set debug renders no problem with this part. car setup looks now:
m_physxScene->setGravity(Ogre::Vector3(0, -19.8, 0));
m_body = m_physxScene->createBody( "carActor",new NxOgre::Cube(1,2,2), NxOgre::Pose(mMainNode->getPosition(),
mMainNode->getOrientation()),renderableParams ,"mass:2000" );
m_body->setRenderMode(NxOgre::RenderableSource::RM_Interpolate);
NxOgre::WheelParams wheelP;
wheelP.setToDefault();
wheelP.mMass = 40.0f;
wheelP.mLocalPose.t.set(30 , -30.9 , 53.5 );
//wheelP.mDensity = 100.0f;
wheelP.mSuspension.spring = 27000.0f;
wheelP.mSuspension.damper = 800;
wheelP.mSuspension.targetValue = 0.0f;
wheelP.mSuspensionTravel = 3.01f;
m_wheelSet = NxOgre::WheelSet::createFourWheelSet( 2.0f , NxOgre::float3( 30 , -30.9 , 53.5 ),
NxOgre::float3( -30 , -30.9 , -49.0 ), m_body, wheelP, "model: jeep_wheell.mesh, mode: interpolate, scale:30 30 30");
the car pass througth floor and i don't know why...?????
the floor looks like a big cube, the car collide with the first face of cube with a height of 40.0 and when i try to move take the balloon behavior, bouncing anywhere.
when i complete vehicle setup, i promise write a short tutorial with an example included for all the newbies.
betajaen
26-07-2008 17:18:02
I do have a question though; Why are the wheels being scaled 30x?
SteelX
27-07-2008 00:20:22
the wheels were scaled cause the vehicle body is scaled 30x too, I will reverse the scale and try to handle normal scale.
betajaen
27-07-2008 00:24:59
I would do that. Unless you like to define the concept of Mega-Monster Trucks.
SteelX
27-07-2008 16:47:57
thx betajaen, the car is moving now. but when i try to turn for any side, and the car is turn over. I need to add a force but with wich function??
thx again.
betajaen
27-07-2008 16:52:58
You could increase the mass, or add a force each frame to the car to simulate downforce.
SteelX
06-08-2008 04:28:22
You could increase the mass, or add a force each frame to the car to simulate downforce.
hi betajaen its me again, i still get the car turn over

, i tried with a really high mass and not working.
could you give some sample(snippet) where the force is applied??.
thx.
DanielH
11-08-2008 16:11:23
Only way I have been able to make a vehicle steerable with PhysX is by doing:
* Offset CoM (Center of Mass) approx -0.5f. This however makes the vehicle cringe the wrong direction during tight turns.
* Add 50 times normal gravity or so. This totally f*cks up the suspension, but it makes it very stable and also stops the car from climbing almost vertical hills as it does otherwise...
* Remember to disable friction for the tire material (raise NX_MF_DISABLE_FRICTION flag on the material).
* Add the NX_WF_INPUT_LNG_SLIPVELOCITY flag and maybe NX_WF_INPUT_LAT_SLIPVELOCITY to the wheel shape.
* Scale down the steering when speed goes up. It is also important that the steer angle isn't changed too quick.
* Changing the cars mass doesn't seem to affect anything. I find this very odd, but theres no difference if i give the car a weight of 1000.0f or 50000.0f.
* If the vehicle drives over a heightfield, add the NX_MESH_SMOOTH_SPHERE_COLLISIONS flag to the height field shape.
syedhs
11-08-2008 19:44:02
I think if you increase the mass, it actually increases the tire mass which actually affects the vehicle pickup. To simulate the car's weight, add impulse every frame like this:-
mActor->addLocalForce(NxVec3(0, -mass, 0), NX_IMPULSE);
Yes adding mass that way fuckup the suspension, so you have to adjust the suspension too - preferably thru script. It also causes your car to have more pickup because the impulse force which originally pointed downward has become slightly 'horizontalized' (hehe dont know the right word for it). Maybe because it is combined with force on the wheels - maybe.
Edit: Regarding the formula of how wheel mass affect stuff, this was what Ageia's staff said:-
Note: AGEIA formula
axleSpeed = axleSpeed - brakeDelta;
axleSpeed = axleSpeed + (motorTorque * dt) * inverseWheelMass;
brakeDelta = brakeTorque * dt * inverseWheelMass;
DanielH
12-08-2008 20:56:04
syedhs,
Gravity should not be added as an impulse. Use NX_FORCE instead.
What I mean with the suspension is that when enough gravity force has been added for making the car act realistic, that will say, it doesn't turn around when taking a turn and doesn't have spiderman-super-glued-tire abilities that allows it to climb any mountain without a slow down. Then you need to add such high values to stiffness that causes single-precision floating point precision issues giving very ugly results. The car jumps up and down and looses all stability. Flips over when affected by any forces etc.
Also, should inverseTireMass relate to vehicle mass or is it only ment to be 1.0/actual mass of a wheel?
betajaen
12-08-2008 21:52:20
I'm sure gravity isn't a force but an acceleration and NX_IMPULSE is more suited than NX_FORCE. I haven't been near the wheel code in a while, but what about (-mass * -gravity.y).
DanielH
13-08-2008 14:11:31
Are you really sure about that betajaen?
NX_FORCE has unit of mass * distance/ time^2, and NX_IMPULSE has unit of mass * distance /time. If you use the impulse you will have multiply it with delta time for the simulation. Impulses are sudden change of momentum and torque, forces that should be continuous over several step of a simulation, should be added with NX_FORCE. That's why I believe gravity must be a force.
I add my extra gravity like this:
m_actor->addForce(NxVec3(0, -9.82 * m_actor->getMass() * m_gravityScalar, 0));
... or am I totally mistaken?
syedhs
13-08-2008 15:41:07
I got the tip (applying impulse instead of force) from Ageia guys - they specifically mentioned it. And I have tried it, it does work.
And another, if you want to think it this way: applying force ONCE to a ball does cause the ball to move & bounce and finally stops after a few seconds. But here, we are applying impulse every physics tick, so there is a difference here. Applying force every physics tick will cause acceleration, so maybe that is not needed.
But I could be wrong, I didn't really remember the physics lesson back in the high school - this could be just a logical guess.
And inverse mass of tire is no way related to vehicle mass, and I dont think you can simulate vehicle mass by setting the mass of the chassis.