Hi!, Im migrating from jme physics 2 to jbullet-jme. Im working with jme 2 as graphics engine.
I created a type CompoundMeshShape with shapes of type GImpactCollisionShape inside. When activated the Debug View, there is a class cast exception. The error occurs in the com.jmex.jbullet.debug.CompoundWireframe class, in createChildWireframe( CollisionShape shape ) method.
I've corrected as follows:
Original code in jbullet-jme:
private TriMeshWireframe createChildWireframe( CollisionShape shape )
{
TriMeshWireframe wireframe = null;
// Assert the CollisionShape is of the appropiate type
assert shape instanceof ConvexShape : "Expecting CollisionShape to be a ConvexShape";
ConvexShape convexShape = (ConvexShape) shape;
// Create a wireframe for the Convex Shape
wireframe = new ConvexWireframe( convexShape );
//TODO hack - either all child shapes are convex or they could be anything - find out which
if ( wireframe == null )
{
throw new IllegalArgumentException( "Shape not yet catered for: " + shape.getName() );
}
return wireframe;
}
GImpactCollisionShape are ConcaveShape type, not ConvexShape, so this code creates a class cast exception. Here's my modification:
private TriMeshWireframe createChildWireframe( CollisionShape shape )
{
TriMeshWireframe wireframe = null;
// Assert the CollisionShape is of the appropiate type
assert shape instanceof ConvexShape : "Expecting CollisionShape to be a ConvexShape";
if (shape instanceof ConvexShape) {
// Create a wireframe for the Convex Shape
wireframe = new ConvexWireframe( (ConvexShape) shape );
} else if (shape instanceof ConcaveShape) {
// Create a wireframe for the Concave Shape
wireframe = new ConcaveWireframe( (ConcaveShape) shape );
}
//TODO hack - either all child shapes are convex or they could be anything - find out which
if ( wireframe == null )
{
throw new IllegalArgumentException( "Shape not yet catered for: " + shape.getName() );
}
return wireframe;
Normen, can you add this change in your code or give me another solution?. Thanks
Sorry for my English. I'm Spanish. Greetings from Spain!!