Jump to content
  • Advertisement
Sign in to follow this  
Jungle Boy

Detecting if a tri is inside an axis-aligned cube

This topic is 4903 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

how i do that? some approach to that is using ray-tracing collision and classifying the tri vertices about their side of cube planes, but i'm wondering if there is a faster way....

Share this post


Link to post
Share on other sites
Advertisement
you said axis-aligned so basically you're just checking against the box's min and max values along the axial directions.


bool isTriInside(Vertex *vertices)
{
for (int i = 0; i < 3; ++i )
{
if ( vertices.x < box.minX || vertices.x > box.maxX
|| vertices.y < box.minY || vertices.y > box.maxY
|| vertices.z < box.minZ || vertices.z > box.maxZ )
{
//this vertex is outside the box
return false;
}
}

return true;
}




Share this post


Link to post
Share on other sites
the seperating planes algorithm is what you need.

google is better at explaining than me.

Share this post


Link to post
Share on other sites
Quote:
Original post by Palidine
you said axis-aligned so basically you're just checking against the box's min and max values along the axial directions.

*** Source Snippet Removed ***

quite incorrect.

Share this post


Link to post
Share on other sites
Quote:
Original post by Eelco
quite incorrect.


no, it's correct. he said "axis-aligned", not Object Oriented BOunding Box, in which case you have to check against the planes. with axis aligned you just have to check the coords.

-me

Share this post


Link to post
Share on other sites
Palidine, your algorithm just check if the vertices is inside the cube
a poly could overlap a cube with all it's vertices outside the cube

Eelco, is "seperating planes algorithm" the fastest way for this case?

thx for your replies

Share this post


Link to post
Share on other sites
Quote:
Original post by Jungle Boy
Palidine, your algorithm just check if the vertices is in the cube
a poly could overlap an cube with all it's vertices outside the cube

Eelco, is "seperating planes algorithm" the fastest way for this case?

thx for your replies


Ah, you said inside, which i took to mean "contained by", not "intersecting".

-me

Share this post


Link to post
Share on other sites
Quote:
Palidine, your algorithm just check if the vertices is inside the cube
a poly could overlap a cube with all it's vertices outside the cube.
I take it from this that you don't want a 'tri in axis-aligned cube' test, but rather a 'tri intersects axis-aligned cube' test. In that case eelco's suggestion may be your best bet.

What's the test for? Is it a pre-processing step, e.g. octree construction? Or something else? Depending on the context, different solutions may be more or less appropriate. It's hard to say though without knowing more about the application.

Share this post


Link to post
Share on other sites
sorry again, it should be "tri intersects or inside an axis-aligned cube"
just a poor english issue

it's all about octree construction
i need to know which tris are intersecting/inside octree's cubes

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!