• Create Account

### #Actualmasterbubu

Posted 31 October 2012 - 09:04 AM

Hi all,

I'm trying to create an OBB for my engine but failed to do so.

I have read good articles/tutorials on line, and I think I understand the concept, but still the OBB does not look good.

The algorithm I use:

for each vertex on the mesh vertices do:
m+= vertex

m/= vertices.size()

Now calculation the covariance matrix:

for each vertex on the mesh vertices do:
{

upperRight3x3Triangle[0] += p.x*p.x - m.x*m.x;
upperRight3x3Triangle[1] += p.x*p.y - m.x*m.y;
upperRight3x3Triangle[2] += p.x*p.z - m.x*m.z;
upperRight3x3Triangle[3] += p.y*p.y - m.y*m.y;
upperRight3x3Triangle[4] += p.y*p.z - m.y*m.z;
upperRight3x3Triangle[5] += p.z*p.z - m.z*m.z;
}

basically I have computed the upper right triangle of the covariance matrix.

Then I just create the matrix from those values, so that the lower triangle of the matrix is symmetrical to the upper triangle.

My problem is that according to the resources I have read, this matrix has the form of [ Right, Up, Forward ] (3x3 rotation matrix ),

Those 3 axes that represents the OBB orientations should be orthogonal to each other ( because the matrix is symmertic ). I have draw

the box axes, and they are not orthogonal to each other.

what am I missing ?

Any help/reference would be great.

tnx a lot

### #1masterbubu

Posted 31 October 2012 - 09:04 AM

Hi all,

I'm trying to create an OBB for my engine but failed to do so.

I have read good articles/tutorials on line, and I think I understand the concept, but still the OBB does not look good.

The algorithm I use:

for each vertex on the mesh vertices do:
m+= vertex

m/= vertices.size()

Now calculation the covariance matrix:

for each vertex on the mesh vertices do:
{

upperRight3x3Triangle[0] += p.x*p.x - midPoint.x*midPoint.x;
upperRight3x3Triangle[1] += p.x*p.y - midPoint.x*midPoint.y;
upperRight3x3Triangle[2] += p.x*p.z - midPoint.x*midPoint.z;
upperRight3x3Triangle[3] += p.y*p.y - midPoint.y*midPoint.y;
upperRight3x3Triangle[4] += p.y*p.z - midPoint.y*midPoint.z;
upperRight3x3Triangle[5] += p.z*p.z - midPoint.z*midPoint.z;
}

basically I have computed the upper right triangle of the covariance matrix.

Then I just create the matrix from those values, so that the lower triangle of the matrix is symmetrical to the upper triangle.

My problem is that according to the resources I have read, this matrix has the form of [ Right, Up, Forward ] (3x3 rotation matrix ),

Those 3 axes that represents the OBB orientations should be orthogonal to each other ( because the matrix is symmertic ). I have draw

the box axes, and they are not orthogonal to each other.

what am I missing ?

Any help/reference would be great.

tnx a lot

PARTNERS