Problem with Model imported from blender and Vehicle

Hi,

I wanted to give the native blender import a try :slight_smile: It worked so far, but there is a strange issue with vehicles.

I created a simple plane in blender and saved it as .blend file. I then copied PhysicsTestHelper.java and TestPhysicsCar.java into a new Project and instead of the floorBox I loaded the blender file:

[java]

//Box floorBox = new Box(140, 0.25f, 140);

//Geometry floorGeometry = new Geometry(“Floor”, floorBox);

Node floorGeometry = (Node) assetManager.loadModel(“Models/test.blend”);

[/java]

(around line 50 in PhysicsTestHelper.java)

The plane is loaded fine, but the vehicle accelerates as soon as it hits the plane, although I’m not pressing any keys.

As it is hard to explain, I made a video :slight_smile:

http://www.youtube.com/watch?v=pNK7RCy0ZPI


I hope that someone can help me, because I’d like to create some kind of race track in blender and load it directly, but I have no idea, why the wheels start to accelerate if they hit the model. If I remove all wheels from the vehicle, the box just collides with the plane as expected. Is this an issue with blender and bullet?

EDIT:

I zipped my test project, so if someone wants to test on his own: http://verbugt.de/BlenderVehicle.zip

I’ve added a border to the plane, so that the vehicle does not fall down everytime :slight_smile:

Maybe that plane is really bouncy? Might wanna lower the bounce factor a little bit

Thanks for the reply :slight_smile:

I tried setting different values for the restitution of the plane, but it has no effect (except for the bounciness of course, but the wheels still accelerate on their own). Does the blender importer import any kind of physic settings? If I use a Plane Object from jME3 instead everything seems to be fine. I wonder what is different between a simple plane imported from blender and a plane from jME3.

I don’t know if it makes any sense or if you already did it, but you can try to apply the object’s visual transform to its data by doing ctrl+a ----> visual transform.

I’ve just tested your advise, but unfortunately nothing changed. I made another video :slight_smile:



Please, can someone have a look at this issue? I’m really stuck.

The code is here: http://verbugt.de/BlenderVehicle.zip , blender file included.



Is this an issue with physics (@normen ?) or is this maybe an issue with the blender model importer (@Kaelthas ?) ? If it is my fault, shame on me :slight_smile:



http://www.youtube.com/watch?v=_t63NXrIQbs

I’d say the weight of the car is too high so that the wheels go into the ground, lower the weight or raise the maxSuspensionForce

Thanks for your fast reply, normen. I tried the following:



[java]

//vehicle = new VehicleControl(compoundShape, 400);

vehicle = new VehicleControl(compoundShape, 50);

[/java]

and

[java]

//vehicle.setMaxSuspensionForce(10000.0f);

vehicle.setMaxSuspensionForce(30000.0f);

[/java]



but unfortunately, the behaviour of the car becomes even worse.

http://www.youtube.com/watch?v=Z5n_VnheXCs

Hi,



I think I’m running into similar behavior and I think this is not so much a physics issue but a blender import issue.

In my case I’m using a heightmap image for the terrain, but I’m using a bridge I created in blender.



My car is working fine while driving over the heightmap terrain, but it fails when I try to drive over the bridge. Depending on which side I try to enter, it will either push me away or propel me along at high speed over the bridge. My wheels will also sink through the top layer.



The direction is constant. I’ve tried rotating the parts that make up my bridge 180 degrees, after which I had the same behavior, but in the opposite direction.



I’ve simplified my bridge parts to a rectangular box, which did not change the behavior.

After reading your posts I replaced the blender boxes with a simple box geometry of the same dimensions and suddenly it behaves as expected.



I’m wondering if this might be an issue with incorrect normal vectors. In blender the down vector is along the z axis, while in jme3 it is along the y axis. Lightning seems to be in order though.



I’m using blender 2.59 btw.

I forgot to mention one last thing. This behavior only occurs when using CollisionShapeFactory.createMeshShape(Spatial).

I’ve also create a BoxCollisionShape manually and that behaves as expected.



If I use CollisionShapeFactory.createBoxShape(Spatial) I don’t get any collision shape, but no error either.

I seem to have solved our problem, or at least found a work around…

In blender, in edit mode, rotate the mesh -90 degrees around the x axis. This way the y axis points upwards in the same way as it is in jme3. Then, in object mode, rotate it 90 degrees around the x axis to have it look the same way as before. After this, it will work as expected.



I’m not certain if this behavior is intended. My initial guess would be that local and global orientations got mixed up. Perhaps someone with more knowledge on the blender import can answer that?



The issue is definitely with the blender import and not the physics though.

2 Likes

Great! Thank you very much for your investigation. I will try that as soon as possible.



Maybe @Kaelthas has some spare time and could have a look at this issue.

Yeah, it seems that for the model loader the y=up parameter is ignored…