Vibrating objects

Post Reply
zalan
Posts: 1
Joined: Mon Jul 16, 2012 3:33 pm

Vibrating objects

Post by zalan »

Hy

I am working on a program using OgreBullet and it needs some basic shapes. Most of the shapes work well, but the cylinder, convex, concave and convex decomposition behaves strangely. When they land they don't stop and switch to sleep mode, but start vibrating. I thing it's something to do with the inertia, because when I modify that, the vibration increases.

This is the code for the convex shape:

Code: Select all

void addConvexShape(OgreBulletDynamics::DynamicsWorld *mWorld, string name, string file, string mat, bool stat, bool shadow, Ogre::Vector3 pos, Ogre::Vector3 scale, Ogre::Quaternion q, float mass, float friction, float restitution, SceneManager* mSceneMgr)
{
     Entity *entity = mSceneMgr->createEntity(name,file);
     entity->setCastShadows(shadow);
     if (mat != "") entity->setMaterialName(mat);
     SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
     node->attachObject(entity);
     node->scale(scale);
    OgreBulletCollisions::StaticMeshToShapeConverter *converter =
                new OgreBulletCollisions::StaticMeshToShapeConverter(entity);
    Ogre::Vector3 *vertices = (Ogre::Vector3*)converter->getVertices();
    int num = converter->getVertexCount();
    for (int i = 0; i < num; ++i)
        vertices[i]*=scale;
    OgreBulletCollisions::CollisionShape *sceneShape =
                (OgreBulletCollisions::CollisionShape*)converter->createConvex();
     OgreBulletDynamics::RigidBody *defaultBody = new OgreBulletDynamics::RigidBody(name+"-rigidbody",mWorld);
     if (stat) {
         defaultBody->setStaticShape(node, sceneShape, restitution, friction, pos, q);
     } else {
        defaultBody->setShape(node,sceneShape,restitution,friction,mass,pos,q);
     }
}
Has anyone any idea what the problem is?
Post Reply