[SOLVED]car front wheels bumps when start driving

deshan

30-01-2010 07:16:22

Hi
This is my first try of implementation of a car using NxOgre.
I am using betajaen example of a vehicle. viewtopic.php?f=6&t=10348&p=59499&hilit=wheels#p59499
I have a problem. When I drive the car by adding a setMotorTorque(...) initially car front wheels bumps each time it hit the floor. I am not adding a big torque as a starting torque, instead i am adding a small torque initially and continuously increase it until it reach some max value.
some sample vehicle properties

Mass =1000;
driving torque applies to two front wheels
wheel radious = 35;
using NxOgre::TriangleGeometry as the body.

mScene->getMaterial(0)->setStaticFriction(0.62);
mScene->getMaterial(0)->setDynamicFriction(0.62);
mScene->getMaterial(0)->setRestitution(0.1f);


Any idea of doing this correctly?

betajaen

30-01-2010 10:15:02

Couple of remarks;

- Cannot ever use a TriangleGeometry in dynamic bodies, ever. I'm pretty sure I've even written code to forbid you to do it. Convex, Cubes, Spheres or Capsules only.
- Your wheel radius is insane; NxOgre units are measured in metres, so you have a wheel that is 70 metres in diameter! You could image in real life such a huge car with such a tiny mass (relativity speaking) would cause it to bounce around like that.

So what I suggest is, use the correct scale, and increase the mass of the chassis a bit or you can also play with setting the Center of mass (COM) and setting it to be underneath the car body.

deshan

30-01-2010 16:05:41

Hi betajaen.
Thank you for answering
this is my code of using the car body.
NxOgre::Shapes shapes;
NxOgre::Mesh* forkliftMesh = NxOgre::MeshManager::getSingleton()->load("media:car_body.nxs");
NxOgre::TriangleGeometry* forkliftGeometry = new NxOgre::TriangleGeometry(forkliftMesh);
shapes.insert(forkliftGeometry);
mActor = mScene->createActor(shapes, position, description);

I mentioned it as the body. Don't know whether I am used the correct word :D. How ever this works fine, because i can see the effect of shape when the car rolls. I cannot create the convex mesh body because car model vertices count exceed the 255 size. Please correct me if i am wrong here.

I have just used the size as 35 radius . Yes it's sound insane :) my car model is too big. This is the rest of my code
addWheel(Vec3(-120,-35,130), true, true, false, "car_wheelL.mesh");
addWheel(Vec3(120,-35,130), true, true, false, "car_wheelR.mesh");
addWheel(Vec3(-120,-35,-130), false, false, true, "car_wheelL.mesh");
addWheel(Vec3(120,-35,-130), false, false, true, "car_wheelR.mesh");

It sound really insane :D. But had to use these values to match the wheels with correct positions. However could you please tell me why did you use 0.433f * 0.5f; as the radious in your original code. Does 0.433f have some combination with previous calculations?
i will rescale the model and will adjust the value to see the effect.
Thank you again for answering

betajaen

30-01-2010 16:41:03

Your going to have to loose some vertices in your mesh, or at least split it up into separate bits.

Using a TriangleMesh in a dynamic actor will do a number of things;
- PhysX hates them being moved, it upsets everything. Performance will drop and collisions will be odd.
- TriangleMeshes don't collide with other TriangleMeshes (Terrain too - I think), so no car crashes!
- PhysX and NxOgre will write to the log every frame that your moving a TriangleMesh around. Excessive harddrive writing will cause a massive lag, and think how big the log will be at the end!


For your scale; I'm sure you can scale it down in a modeller or using meshmagick. I chose 0.433 as a diameter because it was the diameter of a wheel I made. It's slightly smaller than a normal car tyre; which google tells me it's 60cm.

deshan

31-01-2010 07:23:41

Using a TriangleMesh in a dynamic actor will do a number of things;
- PhysX hates them being moved, it upsets everything. Performance will drop and collisions will be odd.
- TriangleMeshes don't collide with other TriangleMeshes (Terrain too - I think), so no car crashes!
- PhysX and NxOgre will write to the log every frame that your moving a TriangleMesh around. Excessive harddrive writing will cause a massive lag, and think how big the log will be at the end!


Thanks for explanation. Learned many things which i didn't know before. Thank you
I have converted it to convex mesh. Used polygon cruncher to reduce the faces and vertices and scaled the model. car looks odd but physics works fine now. no bumps at all.
But still car rolling away when it takes tight turns(I am not instantly changing of the angle but continuously increasing to value 0.4). I think if i can lower the point which affect the gravity(center of the mass) (I do not know the correct English term) car won't roll.
RigidBodyDescription description;
description.mMassLocalPose = NxOgre::Vec3(0,-0.5,0);

Is above wrong here? I can't recognize any significant change.

betajaen

31-01-2010 10:57:53

Yep, you've got the right idea now.

Lowering the center of mass is the correct term, and it will help. In a lot of games (and real-life too) it is desirable to have the centre of mass as low as possible, to to make it more stable when it encounters turns. In physics engines we can cheat a lot more and make it excessive if needed.

So what you can do as well, is add a "spoiler", and apply it when the car turns. Basically it's a force say; (0,-100,0 to start with) to the car body, to push the car down when you turn, then release it when you've finished the turn. You can also try playing with the wheel suspension as well to make it a bit looser.

Also remember the car steering angle is measured in radians, so 0.4 radians is 23 degrees.

deshan

31-01-2010 11:05:49

Awesome explanation !!!
Thank you very much.
Now I can understand how to do this.