I found this nice method getGroundObject() in VehicleWheel class. Problem is that either is has a bug or I misunderstood it’s capabilities. If I’m correct this should return PhysicsCollisionObject of the ground under the wheel if wheel is touching it and null if wheel is in the air, am I correct? But it always returns null. Maybe there is bug in somewhere, because I tested this with FancyCar sample code and found odd behavior.
I added this line to FancyCar’s simpleUpdate method:
[java]
System.out.println("ground: " + player.getWheel(0).getGroundObject());
[/java]
When car is dropping towards the ground, output is filled with text “ground: null” like it should. But when car hits the ground, VehicleWheel.getGroundObject() method is outputting text “RigidBody” and simpleUpdate is still outputting “ground: null”.
So, I think that getGroundObject() is recognized that there is a ground object but fails to return PhysicsCollisionObject. Is this a bug? I’m using jme3 from SVN.
Nope, it doesn’t even work in native bullet, sorry.
Damn, that would have been so nice to have… Thanks for the fast response.
Edit: It can recognize if there is something under wheel (like my prev. example prove). So how about to provide method to return boolean true in that case false if there is no contact, so that information can be used? Or is it unreliable and just happen to work with that sample? I think information about if there is ground contact might be usefull. Or is there any other way to get that information?
I mean to do this kind of method to VehicleWheel.
[java]
public boolean isGroundContact() {
if (wheelInfo.raycastInfo.groundObject == null) {
return false;
} else if (wheelInfo.raycastInfo.groundObject instanceof RigidBody) {
return true;
} else {
return false;
}
}
[/java]