Jump to content
• Advertisement

# Transforming frustum to OBB space

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

If you intended to correct an error in the post then please contact us.

## Recommended Posts

Hi there! :) I need to check if the static mesh is in frustum. I already have a 'Frustum-AABB' test and it works, but I also need a 'Frustum-OBB' test... but everything I have is AABB in local space and object transform :) I tried to transform normals of frustum planes and add object translation to AABB 'min' and 'max', but this works only if I have translation OR rotation matrix applied to object. If I concatenate this transforms( R*T ) my function doesn't work :( Here is the code I wrote to check if OBB is in frustum:
// ** Only AABB in local space
// ** and object transform, as mentioned above :)
bool cFrustum::BoxInside( const cBoundingBox& box, const cMatrix4& T ) const
{
// ** Add object translation to AABB 'min' and 'max'
cBoundingBox aabb = box + T.GetTranslation();

const cVector3& min = aabb.min;
const cVector3& max = aabb.max;
cVector3 c = aabb.GetCenter();

// ** Half-extents
float w = aabb.GetWidth() * 0.5f;
float h = aabb.GetHeight() * 0.5f;
float d = aabb.GetDepth() * 0.5f;

// ** I don't have scale in matrix, so I just calculate a transpose
cMatrix4 tT = cMatrix4::Transpose( T );

for(int i = 0; i < 6; i++ )
{
cVector3 N = frustum.normal;
// ** Multiplies N by 3x3 transposed rotation matrix
tT.TransformVector( N );

// ** Intersection test as if it is an AABB
if( N * min + frustum.distance > 0 ) continue;
if( N * max + frustum.distance > 0 ) continue;

if(N.x * (c.x + w) + N.y * (c.y - h) + N.z * (c.z - d) + frustum.distance > 0)
continue;
if(N.x * (c.x - w) + N.y * (c.y + h) + N.z * (c.z - d) + frustum.distance > 0)
continue;
if(N.x * (c.x + w) + N.y * (c.y + h) + N.z * (c.z - d) + frustum.distance > 0)
continue;
if(N.x * (c.x - w) + N.y * (c.y - h) + N.z * (c.z + d) + frustum.distance > 0)
continue;
if(N.x * (c.x + w) + N.y * (c.y - h) + N.z * (c.z + d) + frustum.distance > 0)
continue;
if(N.x * (c.x - w) + N.y * (c.y + h) + N.z * (c.z + d) + frustum.distance > 0)
continue;

return false;
}
}

Thanks :)

#### Share this post

##### Share on other sites
Advertisement
Quote:
 Original post by 0xFFI need to check if the static mesh is in frustum. I already have a 'Frustum-AABB' test and it works, but I also need a 'Frustum-OBB' test.

Intersection of Orthogonal View Frustum and Oriented
Bounding Box using Separation Axis Testing

I also have an implementation of this at my geometrictools.com website.

#### Share this post

##### Share on other sites
WoW! Thanks! That's what I looked for :)

#### Share this post

##### Share on other sites

• Advertisement

### Announcements

• Advertisement

• ### Popular Contributors

1. 1
2. 2
Rutin
23
3. 3
4. 4
5. 5
khawk
14
• Advertisement

• 9
• 11
• 11
• 23
• 11
• ### Forum Statistics

• Total Topics
633653
• Total Posts
3013158
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!