Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed May 30, 2012 5:01 pm 
Offline

Joined: Wed May 30, 2012 4:51 pm
Posts: 1
I'm having a problem when using the bulletsharp port/wrapper.
I have three cylinders, I want the top one(dynamic) to rest on the other two(static). My setup looks like this:
Image

For some reason, after jittering a bit, the top cylinder bounces off of the other two and falls out of view.

Here's my code to set up the scene.
    //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);

And every frame is updated using:
    world.StepSimulation(0.05f, 100, 0.0005f);

While debugging, the Restitution for all three objects is listed as 0.0f.
Is there anything I might be missing?

I can also mention that I have put together a similar setup in Blender using the Bullet physics there, and there is no jitter.


Top
 Profile  
 
PostPosted: Sat Jun 02, 2012 10:54 am 
Offline

Joined: Wed Feb 24, 2010 9:49 pm
Posts: 26
You need to calculate the inertia as well:
Code:
            float mass = 1.0f;
            Vector3 localInertia;
            shape.CalculateLocalInertia(mass, out localInertia);
            RigidBodyConstructionInfo constructInfo = new RigidBodyConstructionInfo(mass, still, shape, localInertia);

And for the static objects:
Code:
            RigidBodyConstructionInfo r1ci = new RigidBodyConstructionInfo(0.0f, r1m, r1s, Vector3.Zero);

Vector3.Zero is actually the default inertia parameter value, so it's not really needed, but there's currently a bug in BulletSharp where the default value isn't passed correctly. I'll fix that soon, but for now you need to pass the zero vector.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group