Hi, I'm trying to improve my physics plugin, I really need to know some of the finer details of how the object matrices are built in dark basic.
I can build a matrix the standard way and everything works great until I scale the object, then all the angles seem to break, here's the code:
int object_ = 3;
dbMakeObjectBox(object_, 5, 5, 5);
dbRotateObject(object_, 90, -45, 90);
dbScaleObject(object_, 50, 100, 100);
D3DXMATRIX matRotateX;
D3DXMATRIX matRotateY;
D3DXMATRIX matRotateZ;
D3DXMATRIX matScale;
D3DXMATRIX matTranslate;
float scaleX = dbObjectSizeX(object_, 1) / dbObjectSizeX(object_);
float scaleY = dbObjectSizeY(object_, 1) / dbObjectSizeY(object_);
float scaleZ = dbObjectSizeZ(object_, 1) / dbObjectSizeZ(object_);
D3DXMatrixRotationX(&matRotateX, D3DXToRadian(dbObjectAngleX(object_)));
D3DXMatrixRotationY(&matRotateY, D3DXToRadian(dbObjectAngleY(object_)));
D3DXMatrixRotationZ(&matRotateZ, D3DXToRadian(dbObjectAngleZ(object_)));
D3DXMatrixScaling(&matScale, scaleX, scaleY, scaleZ);
D3DXMatrixTranslation(&matTranslate, dbObjectPositionX(object_),
dbObjectPositionY(object_),
dbObjectPositionZ(object_));
D3DXMATRIX matResult = matRotateX * matRotateY * matRotateZ * matScale * matTranslate;
object_ = 4;
dbMakeObjectBox(object_, 5, 5, 5);
dbSetObjectWorldMatrix(object_, &matResult);
The above sample creates, rotates and scales an object, I build a matrix and create another object and set the matrix directly.
Without scaling I can translate and rotate any way I like and it works, does anyone know why adding scaling is breaking it?
Thanks.