# Bullet physics 4x4 matrix problem

Posted by copete23
 copete23 Bullet physics 4x4 matrix problem July 21, 2011 01:15AM Registered: 13 years agoPosts: 54
Hi, i'm trying to integrate Bullet physics in my project, I got it working, but I'm not sure how to translate the transformation of physical objects, to the 3D models.

Bullet uses this function to store the transformations of objects in a Matrix, then pass it to the 3d model:

`btRigidBody-> getWorldTransform ().getOpenGLMatrix(Matrix);`

But there is a problem, OpenGL uses 4x4 matrix (float [16]) and Gx uses 3x4 matrix, and i don`t know how to convert that array from 4x4 to 3x4.

Anyone know how I could solve this problem?

 Titmouse Re: Bullet physics 4x4 matrix problem July 21, 2011 07:35PM Registered: 11 years agoPosts: 99
You will know this but I had no idea, anyway I found out the that GX Mtx[3][4] is able to translate and rotate, having a vector for each x,y,z axis & a vector for translation if I understand things.

So any idea what the extra vector in the GL 4x4 does?
Maybe it's possible to just drop it the extra part? If it's used say for perspective, I guessing instead you might need to 'guMtxConcat' the cut down matrix with with the camera matrix instead.

How come youâ€™re using openGL for the Wii platform
 copete23 Re: Bullet physics 4x4 matrix problem July 21, 2011 08:41PM Registered: 13 years agoPosts: 54
Thanks, I've solved, it was not so complicated after all xD actually the 4x4 matrix is only a 3x4 matrix with some extra vectors that bullet physics do not use , so the only thing to do is find out the position vector x, y, z, the scale vector, etc... in each type of matrix,

This is what I've done:
```
f32 worldMat[16]; //the 4x4 matrix
Mtx m; // 3x4 matrix

obj->_btRigidBody->getWorldTransform().getOpenGLMatrix(worldMat);

//Then copy all the values ??to the  3x4 array in this order

m[0][0]=worldMat[0];
m[1][0]=worldMat[1];
m[2][0]=worldMat[2];

m[0][1]=worldMat[4];
m[1][1]=worldMat[5];
m[2][1]=worldMat[6];

m[0][2]=worldMat[8];
m[1][2]=worldMat[9];
m[2][2]=worldMat[10];

m[0][3]=worldMat[12];
m[1][3]=worldMat[13];
m[2][3]=worldMat[14];```

And that's all, is not very nice, but it works perfectly :D

PS: i`m not using opengl, was only, that function, uses typical matrices of OpenGL :)

Edited 1 time(s). Last edit at 07/21/2011 09:04PM by copete23.
Sorry, only registered users may post in this forum.