OBB transformation

This topic is 4458 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I am trying to figure out how to transform an OBB by a 4x4 transformation matrx that can include scale rotation and translation.. my OBB has these Vector3 center Vector3 extents Vector3[3] orientation any help would be great.. thanks

Share on other sites
Quote:
 Original post by MTclipI am trying to figure out how to transform an OBB by a 4x4 transformation matrx that can include scale rotation and translation..my OBB has theseVector3 centerVector3 extentsVector3[3] orientationany help would be great..thanks
I think the easiest way would be to:

1. Transform the OBB position and orientation by the 4x4 matrix position and orientation
2. Scale the extents by the 4x4 matrix scaling

That's assuming that your 4x4 matrix is an S->R->T matrix, which is most likely the case. It also requires storing the scaling part of the 4x4 matrix separately, but that shouldn't be a problem.

There are probably other ways to do it, such as storing the OBB transform itself as a matrix. But center/extents/orientation is a useful form for many OBB algorithms, so it's probably just as well to keep it in that form.

Share on other sites
I'm a little mixed up here.. how do i get the orientation from the matrix..
I keep getting incorrect results?

is it not
axisX = _11, _12, _13
axisY = _21, _22, _23
axisZ = _31, _32, _33

thanks

Share on other sites
Quote:
 Original post by MTclipI'm a little mixed up here.. how do i get the orientation from the matrix..I keep getting incorrect results?is it notaxisX = _11, _12, _13axisY = _21, _22, _23axisZ = _31, _32, _33thanks
First of all I should say that although I think this is the best way to approach this problem, I'm not sure; I've never had occasion to re-scale or otherwise transform an OBB.

Anyway, I'm guessing that you either got this 4x4 matrix from somewhere (a file, an API, etc.) or constructed it yourself. If it's the latter, then you must have had the original scaling, rotation and translation to begin with, in which case you can use that data to do what I described earlier. If it's the latter, it would involve extracting the scale, which requires square roots. In that case, my solution might not be so good.

If you can provide some info about where the 4x4 matrix comes from, and/or post your current code for transforming the OBB, it might be easier to provide suggestions.

Oh, and yes, the axes are as you described them above (at least in DirectX). However, if the matrix incorporates scale the axes don't describe a pure orientation.

Share on other sites
Quote:
 Original post by jykFirst of all I should say that although I think this is the best way to approach this problem, I'm not sure; I've never had occasion to re-scale or otherwise transform an OBB.

if you dont transform the OBB then how do you update its position, and orientation with the object it evelopes?

Am I misusing it?

Share on other sites
Quote:
Original post by MTclip
Quote:
 Original post by jykFirst of all I should say that although I think this is the best way to approach this problem, I'm not sure; I've never had occasion to re-scale or otherwise transform an OBB.

if you dont transform the OBB then how do you update its position, and orientation with the object it evelopes?

Am I misusing it?
Actually, reading your posts again I'm not sure exactly what you're wanting to do. Do you just want an OBB that reflects the scaling, rotation and translation stored in the 4x4 matrix? Or do you have an OBB with its own rotation, translation and extents, and you want to apply the 4x4 matrix to it?

It might also be useful if you were to describe what you're doing and why it's necessary to transform the OBB.

Share on other sites
lets see..

I have the OBB to do collision detection amugst objects in the scene
each Mesh gets an OBB generated at load time ( the mesh is assumed to be oriented in such a way that axisX = (1,0,0) axisY = (0,1,0) axisZ = (0,0,1)

each object has a mesh pointer. an OBB, and a movement controller. The OBB is first copyied from the Mesh, and transformed based on the worldMatrix of the controller each frame

i have working collision following this... how ever i am only getting the extracting the position world matrix...

void SFOBB::Transform ( SFMatrix & mat ){		// get position	m_center.X() = inv.Get(3,0);	m_center.Y() = inv.Get(3,1);	m_center.Z() = inv.Get(3,2);	// still need extents	// still need orientation}

I can easily send in the separte transform matricies.. pos, rot, scale...
but is this the way OBBs are used?

Share on other sites
I am also trying to figure out the best way to handle this atm. Did you get any resolution to this? I assume games have to transform an objects OBB by its world transform all the time... how do most engines handle this?

Regards
Rael

1. 1
2. 2
Rutin
21
3. 3
JoeJ
18
4. 4
5. 5

• 14
• 40
• 23
• 13
• 13
• Forum Statistics

• Total Topics
631722
• Total Posts
3001892
×