Strange Behavior when adding a rotation to btghostobject

Post Reply
jchen114
Posts: 12
Joined: Wed Jun 08, 2016 1:39 am

Strange Behavior when adding a rotation to btghostobject

Post by jchen114 »

Hello,
I have added a btPairCachingGhostObject to my world like so:

Code: Select all

// Initialize ghost objects at the vertex locations
	sphere = std::unique_ptr<btSphereShape>(new btSphereShape(0.05)); 
	btTransform xform;
	xform.setOrigin(m_vertexPos);
	//xform.setBasis(btMatrix3x3(btQuaternion(btVector3(0, 0, 1), 0.0)));
	xform.setRotation(btQuaternion(0, 0, 0, 1));
	m_ghostVertex = std::unique_ptr<btPairCachingGhostObject>(new btPairCachingGhostObject());
	m_ghostVertex->setCollisionShape(sphere.get());
	m_ghostVertex->setWorldTransform(xform);
	m_ghostVertex->setUserPointer(object);

	ContactLearningApp::GetInstance()->GetWorld()->addCollisionObject(m_ghostVertex.get(), btBroadphaseProxy::StaticFilter, btBroadphaseProxy::AllFilter^btBroadphaseProxy::StaticFilter);
Then I update the position and rotation of the ghost object on the pretick of the physics step.
The problem is that if I tried to get the world transform of the ghost object without modifying rotation, I get huge values in my transform matrix..
I get the wold transform like this:

Code: Select all

btScalar transform[16];
btTransform wt = m_ghostVertex->getWorldTransform();
wt.getOpenGLMatrix(transform);
glPushMatrix();
glMultMatrixf(transform);
glColor3f(0.0f, 0.0f, 1.0f);
DrawCircle(0.05f);
glPopMatrix();
However, if I modify the rotation component of the transform, my object doesn't fall straight down anymore, it seems to rotate on some axis. However, the positions seem to be drawn correctly.
I'm not quite sure what is going on. Please advise.

P.S Also, if I could get notified when the ghost object overlaps with a static object that would be a bonus too.
Post Reply