Car wheels and physics geometry

Hi everyone, i making a car game and when i was adjusting a problem in wheels they stop its rotation. My code before the modification was like that:

//wheel is a DynamicNode...
whell.generatePhysicsGeometry();
whell.attachChild(load3DModel()); //no problem here
//some other settings


The 'generatePhysicsGeometry()' line was before 3D model attach line. If i put the 'generatePhysicsGeometry()' after the attach it solves my problem but it doesn't rotate anymore. Above some images of my wheels:

Before:

After:

It's clear that there are differences, but i don't understand what's wrong. Does anyone know?

Thanks.

In general, when you want to see what's going on physically press [v] to see the physics collision geometries not to see the boundings (they do not necessarily match).



generatePhysicsGeometry generates collision geometries for all children of the node. So this means it generates collision geometries for the newly attached model, too. As this seems to have bounding boxes you get boxes as physical wheel representation. Rotation will still work, but as you can imagine not very well :wink:



Instead of generating the collision geometries you can specify them explicitly, e.g. by calling createCapsule() and adjusting it's scale to an appropriate size. Then have a look at the physics debugger (hit [v]).

I finished my TestAdvancedVehicle Irrisor… I'll post it here in some minutes…

I’ll also post this in USER CODE, but here is the primer:



TestAdvancedVehicle will show how to build a proper Car with independent suspension, 4 or 2 wheel drive and all customizable behavior.



Here is a screenshot of it:







…and the source code for it (tested against CVS versions of jME and jMEPhysics):



www.infoway-pi.com.br/erick/TestAdvanceVehicle.zip

I see, my code is based on perick's article on jme physics wiki, i will do some tests. Perick, your code will be helpful thanks.

Now it's better tuned…:slight_smile:

If you want to download the code again I did some refactoring and it's all comented out (in plain english). I'm going to post it in USER CODE now.

It is working now, thanks.



But i had to set the scale of the sphere because it was too small for my wheels

PhysicsSphere physicsSphere = wheel.createSphere(“wheel”);

physicsSphere.setLocalScale(2);