2012-05-28 8 views
9

BulletSharp, bullet 라이브러리의 C# 배포를 사용하고 있습니다. 나는 0.0f의 반발을 가진 것으로 추정되는 물체에서 약간의 튀는 것을 얻고있다.피직스 오브젝트를 안정화하려면 어떻게해야합니까?

두 개의 고정 실린더에 떨어지는 하나의 동적 실린더 (곧 메쉬가 될 것입니다)가 있습니다. 그래서 같이 :

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를 포함하여 세 가지 오브젝트 모두에 대해이를 추가해야합니다. 시도해보고 작동 원리를 알려주세요.

//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);