# GetTransform() Question

## Recommended Posts

j_smith4    100
Playing around with trying to figure out AABB. When I'm setting the transforms on my models I'm using whole numbers and the lengths of my models are in whole numbers. So when I construct the eight point OOB all the points are in whole numbers. But when I make the call to m_D3DDevice->GetTransform(D3DTS_WORLD, &matWorld) to make the AABB box after I'm done the points are decimals. I have to multiply by 100 to get what should be the proper coordinates. Am I doing something wrong or is GetTransform supposed to give by a matrix thats in decimal numbers?

##### Share on other sites
Evil Steve    2017
GetTransform() will return the exact same matrix as you set with SetTransform(). Also, the matrix is made up from floating point numbers, which can't always represent decimal numbers exactly.

Do you have any example code?

##### Share on other sites
j_smith4    100
Maybe it was silly for me to assume that since with the helper functions to create the world view you can use whole numbers (ie D3DXMatrixTranslation(&matT, 0, 0, 10.0f)) that the matrix would stay in whole numbers.

Here is where I transform the eight point bounding box with the world view. The numbers held in m_objectBounds are numbers like -21 but after the transform they will be something like -0.21. It does work, just the result is in the wrong format.

D3DXMATRIXA16 matWorld;m_D3DDevice->GetTransform(D3DTS_WORLD, &matWorld);D3DXVECTOR3 worldBounds[8];for(int i = 0; i < 8; i++)	D3DXVec3TransformCoord(&worldBounds[i], &m_objectBounds[i], &matWorld);

##### Share on other sites
Buckeye    10747
D3DXMATRIX is a matrix of float values. D3DXVECTOR3 is also a set of float values so they will never "hold" integers.

What's the format of m_objectBounds? It should be D3DXVECTOR3[], in which case the numbers are floating point, not integers. Have you looked at the vectors in m_objectBounds to see what they are after you set them and before you try the transform?

Is matWorld what you expect it to be before you call the transform? It may simply be scaling the values.

Try some debugging code (e.g.,OutputDebugString) to see what the values are.

You could also post the code for setting matWorld and m_objectBounds.

##### Share on other sites
j_smith4    100
I just noticed something, the models are to big so I scale them by 0.01 which happens to be the scaling factor on worldBounds after transforming it by the world view matrix. So I'm assuming this is what the problem is. I'll just have to reset the camera to view larger models or scale worldBounds after doing the transform.