2012-05-28 11 views
9

Estoy usando BulletSharp, una distribución C# de la biblioteca de viñetas. He recibido algunos rebotes en un objeto que supuestamente tiene Restitución de 0.0f.¿Cómo puedo hacer que mi objeto de física se calme?

Tengo un cilindro dinámico (lo que pronto será una malla) que cae sobre dos cilindros estáticos. Al igual que:

starting object positions

El cilindro en la parte superior salta a menudo alrededor violentamente, por lo general rebotando hacia un lado.

Aquí está el código que estoy usando para establecer la escena:

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

Y cada cuadro utilizo world.StepSimulation(0.05f, 100, 0.0005f); para actualizar la simulación de la física.

¿Me falta alguna configuración obvia? ¿Por qué mi simulación hace esto?

Actualización pequeña: He realizado con éxito una simulación similar en Blender's Bullet. No hubo rebote allí ... No sé qué diferencia podría haber entre eso y esto.

+0

¿Se puede agregar restitución al objeto que cae? – MoonKnight

+0

Añadir restitución a solo el objeto que cae no hizo ninguna diferencia apreciable. Al establecer la restitución en 0.1 para los tres objetos, pareció asentarse un poco, pero dependiendo del tamaño del paso de simulación. Todavía había un poco de rebote, ocasionalmente rebotando. – tugs

Respuesta

4

No agregó Inercia a su modelo. Eso debería ralentizar la agitación y no debería producir la reverberación que termina rebotando en los rodillos. Tendrá que agregarlo para los tres objetos, incluido el cero en los rodillos. Pruébelo y dígame cómo funciona:

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