Hello,
has anyone successfully used JBullet on Android? I got some weird behaviour when using a simple BoxShape. It acts almost like a cylinder. It comes to rest correctly on two opposite sides (say 1 and 6 on a dice). But it roles like a wheel when on any other side (with a line from 1 to 6 as the axis).
This is how I initialize the world (That's basically the same as in the BasicDemo):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| CollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration();
CollisionDispatcher dispatcher = new CollisionDispatcher( collisionConfiguration);
BroadphaseInterface broadphase = new DbvtBroadphase();
ConstraintSolver solver = new SequentialImpulseConstraintSolver();
mDynamics = new DiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
mDynamics.setGravity(new Vector3f(0f, -10f, 0f)); |
Afterwards I define some static shapes for the ground and for the walls and then I just want to create a simple cube:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| CollisionShape colShape = new BoxShape(new Vector3f(1, 1, 1));
Transform startTransform = new Transform(); startTransform.setIdentity();
float mass = 1f;
Vector3f localInertia = new Vector3f(0, 0, 0); colShape.calculateLocalInertia(mass, localInertia);
DefaultMotionState myMotionState = new DefaultMotionState( startTransform);
RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia); dice = new RigidBody(rbInfo);
dice.setActivationState(RigidBody.ACTIVE_TAG);
mDynamics.addRigidBody(dice); |
Most of the code is taken directly from the examples so I wonder what I am doing wrong here.
Here is a video for demonstration:
http://www.youtube.com/watch?v=oIe5sYJKQSsAny suggestions?