Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Wed May 16, 2007 12:06 am 
Offline

Joined: Tue May 15, 2007 11:58 pm
Posts: 4
I integrated Bullet into my project and everything seems to work fine except one thing: When objects collide with other objects their rotation does not update. Things do not bounce off of other things and rotate how they should in response to the collision. They kind of just sit there in their normal orientation, bouncing off eachother.

It's not a graphical error as I can use setAngularVelocity and the objects (which are box shapes at the moment) will rotate and collide, climbing over eachother, etc. but they do not influence eachother's rotation.

I followed the user manual's integration steps and also looked at the other demos and it seems to me that I am initializing everything how I should.

I am using the newest version, 2.50b.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 16, 2007 2:12 pm 
Offline
Site Admin
User avatar

Joined: Sun Jun 26, 2005 6:43 pm
Posts: 3744
Location: California, USA
It sounds like the 'angularFactor' is set to zero in the rigidbody.

Did you use this one?
Code:
btRigidBody::setAngularFactor(btScalar angFac)

Hope this helps,
Erwin


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 16, 2007 3:06 pm 
Offline

Joined: Tue May 15, 2007 11:58 pm
Posts: 4
I didn't use that function, no. But I tried adding it in and setting it to 1 but there is still no rotation.

Should I be including more than just:
Code:
#include "Contrib\bullet-2.50b\src\btBulletDynamicsCommon.h"
#if defined(DEBUG) || defined(_DEBUG)
   #pragma comment( lib, "libbulletcollision_d.lib" )
   #pragma comment( lib, "libbulletdynamics_d.lib" )
   #pragma comment( lib, "libbulletmath_d.lib" )
#else
   #pragma comment( lib, "libbulletcollision.lib" )
   #pragma comment( lib, "libbulletdynamics.lib" )
   #pragma comment( lib, "libbulletmath.lib" )
#endif


Everything else seems to work fine but I can't figure out why they just won't rotate. I can link to a video if you would like to see exactly what is going on.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 16, 2007 3:18 pm 
Offline
Site Admin
User avatar

Joined: Sun Jun 26, 2005 6:43 pm
Posts: 3744
Location: California, USA
It might be some initialization issue.

Did you initialize the local inertia properly? Can you compare it more carefully with Bullet Demo initialization (see Bullet/Demos/OpenGL/DemoApplication.cpp )

Can you provide a snippet of collision shape and rigidbody creation?

Thanks,
Erwin


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 16, 2007 3:34 pm 
Offline

Joined: Tue May 15, 2007 11:58 pm
Posts: 4
Code:
btMotionState* g_motionState = NULL;
btRigidBody* g_rigidBody = NULL;
btCollisionShape* box = NULL;

   btTransform boxTrans;
   boxTrans.setIdentity();
   boxTrans.setOrigin(btVector3( 0.0f,100.0f,0.0f));
   g_motionState = new btDefaultMotionState(boxTrans);
   box = new btBoxShape( btVector3(1.0f, 1.0f, 1.0f) );
   g_rigidBody = new btRigidBody( 1.0f, g_motionState, box, btVector3(0,0,0), btScalar(0), btScalar(0), btScalar(0.5), btScalar(1.0) );
   g_DynamicsWorld->addRigidBody( g_rigidBody );
   g_rigidBody->setAngularFactor( btScalar(1) );
   g_rigidBody->setLinearVelocity( btVector3( 0.0f, 0.0f, 0.0f ) );
   g_rigidBody->setAngularVelocity( btVector3( 0.0f, 0.0f, 0.0f ) );


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 16, 2007 3:44 pm 
Offline
Site Admin
User avatar

Joined: Sun Jun 26, 2005 6:43 pm
Posts: 3744
Location: California, USA
g_rigidBody = new btRigidBody( 1.0f, g_motionState, box, btVector3(0,0,0), btScalar(0), btScalar(0), btScalar(0.5), btScalar(1.0) );

You should provide a proper local inertia tensor, instead of btVector3(0,0,0) as 4th argument in btRigidBody constructor.

The sample code in Bullet uses the shape and mass to calculate the localInertia:

Code:
btRigidBody*    DemoApplication::localCreateRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape)
{
        //rigidbody is dynamic if and only if mass is non zero, otherwise static
        bool isDynamic = (mass != 0.f);

        btVector3 localInertia(0,0,0);
        if (isDynamic)
                shape->calculateLocalInertia(mass,localInertia);

        //using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects

#define USE_MOTIONSTATE 1
#ifdef USE_MOTIONSTATE
        btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
        btRigidBody* body = new btRigidBody(mass,myMotionState,shape,localInertia);

#else
        btRigidBody* body = new btRigidBody(mass,startTransform,shape,localInertia);
#endif//
        m_dynamicsWorld->addRigidBody(body);

        return body;
}


Hope this helps,
Erwin


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 16, 2007 4:49 pm 
Offline

Joined: Tue May 15, 2007 11:58 pm
Posts: 4
Awesome! Thank you very much for your help.


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 4 guests


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