2012-05-28 17 views
9

私は弾丸ライブラリのC#ディストリビューションであるBulletSharpを使用しています。私は、おそらく0.0fの返還を持っているオブジェクトでいくつかのバウンスを取得しています。どのようにして物理オブジェクトを解決できますか?

私は2つの静的なシリンダーの上に落ちる1つのダイナミックシリンダー(すぐにメッシュになるでしょう)を持っています。これと同じように:

starting object positions

上部のシリンダーは、多くの場合、通常の側に跳ね返る、乱暴に周りバウンス。私は物理シミュレーションを更新するためにworld.StepSimulation(0.05f, 100, 0.0005f);を使用

 //now figure out bulletsharp stuff... 
     CollisionConfiguration collConfig = new DefaultCollisionConfiguration(); 
     Dispatcher collDispatch = new CollisionDispatcher(collConfig); 

     BroadphaseInterface broadphase = new DbvtBroadphase(); 
     ConstraintSolver sol = new SequentialImpulseConstraintSolver(); 
     world = new DiscreteDynamicsWorld(collDispatch, broadphase, sol, collConfig); 

     world.Gravity = new Vector3(0.0f, -10.0f, 0.0f); 

     //log (moving object) 
     MotionState still = new DefaultMotionState(); 
     CylinderShape shape = new CylinderShapeZ(0.5f, 1.0f, 1.0f); 
     still.WorldTransform = Matrix.Translation(0.0f, 0.4f, 0.0f); 
     RigidBodyConstructionInfo constructInfo = new RigidBodyConstructionInfo(1.0f, still, shape); 
     logBody = new RigidBody(constructInfo); 
     logBody.SetDamping(0.04f, 0.1f); 
     world.AddRigidBody(logBody); 

     //rollers (static objects) 
     CylinderShape r1s = new CylinderShapeZ(0.1f, 1.0f, 1.0f); 
     MotionState r1m = new DefaultMotionState(); 
     r1m.WorldTransform = Matrix.Translation(-0.2f, -0.4f, 0.0f); 
     RigidBodyConstructionInfo r1ci = new RigidBodyConstructionInfo(0.0f, r1m, r1s); 
     r1 = new RigidBody(r1ci); 
     world.AddRigidBody(r1); 

     CylinderShape r2s = new CylinderShapeZ(0.1f, 1.0f, 1.0f); 
     MotionState r2m = new DefaultMotionState(); 
     r2m.WorldTransform = Matrix.Translation(0.2f, -0.4f, 0.0f); 
     RigidBodyConstructionInfo r2ci = new RigidBodyConstructionInfo(0.0f, r2m, r2s); 
     r2 = new RigidBody(r2ci); 
     world.AddRigidBody(r2); 

そして、すべてのフレーム:

は、ここで私はシーンを設定するために使用しているコードです。

明白な設定がありません。なぜ私のシミュレーションはこれをしていますか?

小規模なアップデート:私は、BlenderのBulletで同様のシミュレーションを成功させました。そこにはバウンスはありませんでした...私はそれとこれの間にどのような違いがあるのか​​分かりません。

+0

落ち着いたオブジェクトに反発力を追加できますか? – MoonKnight

+0

落下物だけに反発力を加えても、大きな違いはありませんでした。 3つすべてのオブジェクトの反発力を0.1に設定すると、少し落ち着いているように見えましたが、シミュレーションのステップサイズによって決まりました。まだ少しバウンスがあり、時々バウンスしていました。 – tugs

答えて

4

モデルに慣性を追加していません。これは、ジッタを遅くし、ローラでバウンスするリバーブを生成しないはずです。ローラーのZeroを含む3つのオブジェクトすべてに追加する必要があります。これを試して、それがどのように動作するか教えてください:

//now figure out bulletsharp stuff... 
CollisionConfiguration collConfig = new DefaultCollisionConfiguration(); 
Dispatcher collDispatch = new CollisionDispatcher(collConfig); 

BroadphaseInterface broadphase = new DbvtBroadphase(); 
ConstraintSolver sol = new SequentialImpulseConstraintSolver(); 
world = new DiscreteDynamicsWorld(collDispatch, broadphase, sol, collConfig); 

world.Gravity = new Vector3(0.0f, -10.0f, 0.0f); 

//log (moving object) 
Vector3 cylinderInertia; 
MotionState still = new DefaultMotionState(); 
CylinderShape shape = new CylinderShapeZ(0.5f, 1.0f, 1.0f); 
still.WorldTransform = Matrix.Translation(0.0f, 0.4f, 0.0f); 
shape.CalculateLocalInertia(1.0f, out cylinderInertia);  
RigidBodyConstructionInfo constructInfo = new RigidBodyConstructionInfo(1.0f, still, shape, cylinderInertia); 
logBody = new RigidBody(constructInfo); 
logBody.SetDamping(0.04f, 0.1f); 
world.AddRigidBody(logBody); 

//rollers (static objects) 
CylinderShape r1s = new CylinderShapeZ(0.1f, 1.0f, 1.0f); 
MotionState r1m = new DefaultMotionState(); 
r1m.WorldTransform = Matrix.Translation(-0.2f, -0.4f, 0.0f); 
RigidBodyConstructionInfo r1ci = new RigidBodyConstructionInfo(0.0f, r1m, r1s, Vector3.Zero); 
r1 = new RigidBody(r1ci); 
world.AddRigidBody(r1); 

CylinderShape r2s = new CylinderShapeZ(0.1f, 1.0f, 1.0f); 
MotionState r2m = new DefaultMotionState(); 
r2m.WorldTransform = Matrix.Translation(0.2f, -0.4f, 0.0f); 
RigidBodyConstructionInfo r2ci = new RigidBodyConstructionInfo(0.0f, r2m, r2s, Vector3.Zero); 
r2 = new RigidBody(r2ci); 
world.AddRigidBody(r2); 
関連する問題