2012-05-28 24 views
9

मैं बुलेट पुस्तकालय का एक सी # वितरण बुलेटशर्प का उपयोग कर रहा हूं। मुझे किसी ऑब्जेक्ट में कुछ उछाल आया है जो माना जाता है कि 0.0f की पुनर्वितरण है।मैं अपने भौतिकी वस्तु को कैसे व्यवस्थित कर सकता हूं?

मेरे पास एक स्थिर सिलेंडर (जल्द ही जाल क्या होगा) दो स्थैतिक सिलेंडरों पर आराम करने के लिए गिर रहा है। इसलिए जैसा:

starting object positions

शीर्ष पर सिलेंडर अक्सर बेतहाशा चारों ओर बाउंस, आमतौर पर पक्ष के लिए रवाना उछल।

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

और हर फ्रेम मैं world.StepSimulation(0.05f, 100, 0.0005f); का उपयोग भौतिकी सिमुलेशन अद्यतन करने के लिए:

यहाँ कोड मैं दृश्य स्थापित करने के लिए उपयोग कर रहा हूँ है।

क्या मुझे कोई स्पष्ट सेटिंग्स याद आ रही है? मेरा सिमुलेशन ऐसा क्यों कर रहा है?

छोटे अपडेट: मैंने ब्लेंडर की बुलेट सामग्री में सफलतापूर्वक एक समान सिमुलेशन किया है। वहाँ कोई उछाल नहीं था ... मुझे नहीं पता कि उस और उसके बीच क्या अंतर हो सकता है।

+0

क्या आप गिरने वाली वस्तु में पुनर्स्थापन जोड़ सकते हैं? – MoonKnight

+0

केवल गिरने वाली वस्तु को पुनर्स्थापन जोड़ना कोई सराहनीय अंतर नहीं बना। सभी तीन वस्तुओं के लिए पुनर्वितरण को 0.1 पर सेट करना थोड़ा सा बसने के लिए लग रहा था, लेकिन सिमुलेशन चरण आकार के आधार पर। कभी-कभी बाउंसिंग का थोड़ा सा हिस्सा था, कभी-कभी उछाल रहा था। – tugs

उत्तर

4

आपने अपने मॉडल में जड़ता नहीं जोड़ा है। यह झटके को धीमा कर देना चाहिए और रोलर्स को उछालते हुए उस रिवरब का उत्पादन नहीं करना चाहिए। रोलर्स पर शून्य सहित आपको तीनों ऑब्जेक्ट्स के लिए इसे जोड़ना होगा। इसे आज़माएं और मुझे बताएं कि यह कैसे काम करता है:

//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); 
संबंधित मुद्दे

 संबंधित मुद्दे