Skip to main content
gamedev.net
🔒 Locked

GetTransform() Question

Started by j_smith4 3 replies 850+ views
Original Post
j_smith4
j_smith4
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?
--------Ratings - Serious internet buisness
Evil Steve
Evil Steve
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?
j_smith4
j_smith4
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, &m_objectBounds, &matWorld);

--------Ratings - Serious internet buisness
Buckeye
Buckeye
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.
Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly. You don't forget how to play when you grow old; you grow old when you forget how to play.
j_smith4
j_smith4
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.
--------Ratings - Serious internet buisness

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.