Show Posts
|
|
Pages: [1]
|
|
3
|
Game Development / Game Mechanics / Re: Java port of Bullet Physics Library
|
on: 2008-04-14 13:58:57
|
I've a pb when I try to remove rigidbodies from my dynamicworld (it's not systematic, and arryy index causing this exception change) 1 2 3 4 5 6 7 8 9
| Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 13 at gnu.trove.THashMap.removeAt(THashMap.java:414) at gnu.trove.THashMap.retainEntries(THashMap.java:315) at com.bulletphysics.util.HashUtil$TroveHashMapImpl.retainEntries(HashUtil.java:114) at com.bulletphysics.collision.broadphase.OverlappingPairCache.processAllOverlappingPairs(OverlappingPairCache.java:123) at com.bulletphysics.collision.broadphase.OverlappingPairCache.removeOverlappingPairsContainingProxy(OverlappingPairCache.java:127) at com.bulletphysics.collision.broadphase.SimpleBroadphase.destroyProxy(SimpleBroadphase.java:73) at com.bulletphysics.collision.dispatch.CollisionWorld.removeCollisionObject(CollisionWorld.java:164) at com.bulletphysics.dynamics.DiscreteDynamicsWorld.removeRigidBody(DiscreteDynamicsWorld.java:375) |
Here is how I do (I only have box rigidbodies and HingeConstraint) : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| public void deleteWorld() { int numConstraints = dynamicsWorld.getNumConstraints(); for (int i=0; i<numConstraints; i++) { TypedConstraint joints = dynamicsWorld.getConstraint(0); dynamicsWorld.removeConstraint(joints); } for (Node node : sceneGraph) { if (node instanceof PhysicNode) { RigidBody body = ((PhysicNode)node).getCollisionObject(); dynamicsWorld.removeRigidBody(body); body.destroy(); } } sceneGraph = new ArrayList<Node>(); dynamicsWorld.destroy(); dynamicsWorld = null; } |
Any idea ?
|
|
|
|
|
6
|
Game Development / Game Mechanics / Re: Java port of Bullet Physics Library
|
on: 2008-03-17 08:40:28
|
Hi I inspect HingeConstraint code, and there is some things a bit weird (also present in "upstream" Bullet), if I remember well my maths (which are years behind me now ...) So I' ve rewrite the constructor public HingeConstraint(RigidBody rbA, RigidBody rbB, Vector3f pivotInA, Vector3f pivotInB, Vector3f axisInA, Vector3f axisInB) and it seems ok : Here is the original code : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| rbAFrame.origin.set(pivotInA);
Vector3f rbAxisA1 = stack.vectors.get(); rbA.getCenterOfMassTransform().basis.getColumn(0, rbAxisA1);
float projection = rbAxisA1.dot(axisInA); if (projection > BulletGlobals.FLT_EPSILON) { rbAxisA1.scale(projection); rbAxisA1.sub(axisInA); } else { rbA.getCenterOfMassTransform().basis.getColumn(1, rbAxisA1); }
Vector3f rbAxisA2 = stack.vectors.get(); rbAxisA2.cross(rbAxisA1, axisInA);
rbAFrame.basis.setRow(0, rbAxisA1.x, rbAxisA2.x, axisInA.x); rbAFrame.basis.setRow(1, rbAxisA1.y, rbAxisA2.y, axisInA.y); rbAFrame.basis.setRow(2, rbAxisA1.z, rbAxisA2.z, axisInA.z);
Quat4f rotationArc = stack.quats.get(QuaternionUtil.shortestArcQuat(axisInA, axisInB)); Vector3f rbAxisB1 = stack.vectors.get(QuaternionUtil.quatRotate(rotationArc, rbAxisA1)); Vector3f rbAxisB2 = stack.vectors.get(); rbAxisB2.cross(rbAxisB1, axisInB);
rbBFrame.origin.set(pivotInB); rbBFrame.basis.setRow(0, rbAxisB1.x, rbAxisB2.x, -axisInB.x); rbBFrame.basis.setRow(1, rbAxisB1.y, rbAxisB2.y, -axisInB.y); rbBFrame.basis.setRow(2, rbAxisB1.z, rbAxisB2.z, -axisInB.z); |
And my code : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| rbAFrame.origin.set(pivotInA);
Vector3f rbAxisA1 = stack.vectors.get(); Vector3f rbAxisA2 = stack.vectors.get(); Vector3f tmpVect = stack.vectors.get(axisInA); rbA.getCenterOfMassTransform().basis.getColumn(0, rbAxisA1);
float projection = axisInA.dot(rbAxisA1); if (Math.abs(projection) >= 1.0f - BulletGlobals.SIMD_EPSILON) { rbA.getCenterOfMassTransform().basis.getColumn(1, rbAxisA2); tmpVect.scale(axisInA.dot(rbAxisA2)); rbAxisA2.sub(tmpVect); rbAxisA1.cross(rbAxisA2, axisInA); } else { tmpVect.scale(projection); rbAxisA1.sub(tmpVect); rbAxisA2.cross(axisInA, rbAxisA1); }
rbAFrame.basis.setRow(0, rbAxisA1.x, rbAxisA2.x, axisInA.x); rbAFrame.basis.setRow(1, rbAxisA1.y, rbAxisA2.y, axisInA.y); rbAFrame.basis.setRow(2, rbAxisA1.z, rbAxisA2.z, axisInA.z);
Quat4f rotationArc = stack.quats.get(QuaternionUtil.shortestArcQuat(axisInA, axisInB)); Vector3f rbAxisB1 = stack.vectors.get(QuaternionUtil.quatRotate(rotationArc, rbAxisA1)); Vector3f rbAxisB2 = stack.vectors.get();
rbAxisB2.cross(axisInB, rbAxisB1);
rbBFrame.origin.set(pivotInB); rbBFrame.basis.setRow(0, rbAxisB1.x, rbAxisB2.x, -axisInB.x); rbBFrame.basis.setRow(1, rbAxisB1.y, rbAxisB2.y, -axisInB.y); rbBFrame.basis.setRow(2, rbAxisB1.z, rbAxisB2.z, -axisInB.z); |
Maybe I should also post on Bullet forum ?
|
|
|
|
|
7
|
Game Development / Game Mechanics / Re: Java port of Bullet Physics Library
|
on: 2008-03-14 12:05:28
|
I'm trying to debug : In the first case which works, I get Tranforms for HingeContraints like this: 1 2 3 4 5 6 7 8 9 10 11
| rbAFrame (1.0, 0.0, 0.0) 1.0, 0.0, 0.0 0.0, 1.0, 0.0 0.0, 0.0, 1.0
rbBFrame (-1.0, 0.0, 0.0) 1.0, 0.0, -0.0 0.0, 1.0, -0.0 0.0, 0.0, -1.0 |
but the computed Tranforms from Vectors are like this : 1 2 3 4 5 6 7 8 9 10 11
| rbAFrame (1.0, 0.0, 0.0) 0.0, 1.0, 0.0 1.0, 0.0, 0.0 0.0, 0.0, 1.0
rbBFrame (-1.0, 0.0, 0.0) 0.0, 1.0, -0.0 1.0, 0.0, -0.0 0.0, 0.0, -1.0 |
|
|
|
|
|
8
|
Game Development / Game Mechanics / Re: Java port of Bullet Physics Library
|
on: 2008-03-14 08:24:43
|
I'm playing with HingeConstraint, and I have a issue : There is two constructors to join bodies, one which takes Transform, and one where you specify Vectors ... With the first one, hinge Limits and angularMotor work very well, but with the other constructor the physic explodes when it reaches limits ! Maybe I do something wrong, here is the 2 methods I use : 1 2 3 4 5 6 7 8
| HingeConstraint hingeC; Transform localA = stack.transforms.get(); Transform localB = stack.transforms.get(); localA.setIdentity(); localA.origin.set(1.0f, 0.0f, 0.0f); localB.setIdentity(); localB.origin.set(-1.0f, 0.0f, 0.0f); hingeC = new HingeConstraint(bodies.get(1), bodies.get(2), localA, localB); |
And my current issue : 1 2 3 4 5 6 7 8 9 10
| HingeConstraint hingeC; Vector3f pivotInA = stack.vectors.get(); Vector3f pivotInB = stack.vectors.get(); Vector3f axisInA = stack.vectors.get(); Vector3f axisInB = stack.vectors.get(); pivotInA.set(1.0f, 0.0f, 0.0f); pivotInB.set(-1.0f, 0.0f, 0.0f); axisInA.set(0.0f, 0.0f, 1.0f); axisInB.set(0.0f, 0.0f, 1.0f); hingeC = new HingeConstraint(bodies.get(1), bodies.get(2), pivotInA, pivotInB, axisInA, axisInB); |
Jezek, I can send you a test if you want to check by yourself.
|
|
|
|
|
11
|
Game Development / Game Mechanics / Re: Java port of Bullet Physics Library
|
on: 2008-03-12 14:22:30
|
It almost works, but I've a small bug : my joints are not correctly positionned. As I discover the vecmath api, I don't know if my port is correct for the following line : 1
| localB = m_bodies[1+2*i]->getWorldTransform().inverse() * m_bodies[0]->getWorldTransform() * localA; |
in this : 1 2 3
| tmpTrans.inverse(bodies[1+2*i].getWorldTransform()); tmpTrans.mul(tmpTrans, bodies[0].getWorldTransform()); localB.mul(tmpTrans, localA); |
|
|
|
|
|
13
|
Game Development / Game Mechanics / Re: Java port of Bullet Physics Library
|
on: 2008-03-12 08:33:25
|
|
Hi
I've just register to JGO because I'm searching a physic library in java and I've discover your porting effort. I've played a bit with JBullet, and you have done a very good work so far.
Your last post answer partially my current question : have you a comparison between Bullet and JBullet for features ported or not ?
For my project I'll need motors, so I think I'll port DynamicControlDemo if you have not started with it ?
|
|
|
|
|