Code: Select all
btRigidBody* rag::addSphere(float rad,float x,float y,float z,float mass)
{
btTransform t;
t.setIdentity();
t.setOrigin(btVector3(x,y,z));
btSphereShape* sphere=new btSphereShape(rad);
btVector3 inertia(0,0,0);
if(mass!=0.0)
sphere->calculateLocalInertia(mass,inertia);
btMotionState* motion=new btDefaultMotionState(t);
btRigidBody::btRigidBodyConstructionInfo info(mass,motion,sphere,inertia);
btRigidBody* body=new btRigidBody(info);
world->addRigidBody(body);
bodies.push_back(body);
return body;
}
void rag::renderSphere(btRigidBody* sphere)
{
if(sphere->getCollisionShape()->getShapeType()!=SPHERE_SHAPE_PROXYTYPE)
return;
glColor3f(1,0,0);
float r=((btSphereShape*)sphere->getCollisionShape())->getRadius();
btTransform t;
sphere->getMotionState()->getWorldTransform(t);
float mat[16];
t.getOpenGLMatrix(mat);
glPushMatrix();
glMultMatrixf(mat); //translation,rotation times mat
gluSphere(quad,r,20,20);
glPopMatrix();
}
Code: Select all
void rag::renderSphere(btRigidBody* sphere, matrices& pipeline, unsigned int programObject)
{
if(sphere->getCollisionShape()->getShapeType()!=SPHERE_SHAPE_PROXYTYPE)
return;
glColor3f(1,0,0);
float r=((btSphereShape*)sphere->getCollisionShape())->getRadius();
btTransform t;
sphere->getMotionState()->getWorldTransform(t);
float mat[16];
t.getOpenGLMatrix(mat);
physx = getMatrix(mat); //getMatrix function changes array of float to matrix form
pipeline.pushMatrix();
pipeline.getModelViewProjectionMatrix() = physx * pipeline.getModelViewProjectionMatrix();
pipeline.updateMatrices(programObject); //changes the value of matrix to be passed to shader
gluSphere(quad,r,20,20);
pipeline.popMatrix();
}
no effect of physics transformation at all. Also, I am unsure about the order in which the two transformation matrices are multiplied. What could be the problem?