Jump to content
  • Advertisement
Sign in to follow this  
Infini Face

Polygon Collision Detection

This topic is 4237 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! I am working on a homebrew game for the Sony PSP, and I am wondering if any one can tell me how to calculate collision based on polygon intersection instead bounding spheres or boxes. I would use them, but I am building a desert like the one in JAK III with hills and bumps everywhere. I am not conerned with rotations at the moment, but I need to know how to detect collisions with the ground so the dune buggies can go over the hills! Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
You guys might find what I am doing for collision detections of polygons kind of funny.

bool RotatingPong::CRotatingSquare::intersects( const CRotatingSquare & o ) const
{

// The aliases of these functions do not correspond
// to their real meaning. Top left can be rotated to be bottom right, etc.

CPoint ( CRotatingSquare::* t [ 4 ] )( void ) const =
{
&CRotatingSquare::topleft,
&CRotatingSquare::topright,
&CRotatingSquare::borromleft,
&CRotatingSquare::bottomright
};

for( int i = 0; i < sizeof(t) / sizeof(t[0]) - 1; ++i )
{
CLineSegment c( (*this.*t)(), (*this.*t[i + 1])() );

for( int j = 0; j < sizeof(t) / sizeof(t[0]) - 1; ++j )
{
CLineSegment d( (o.*t[j])(), (o.*t[j + 1])() );

if( c.intersects(d) )
{
return true;
}
}
}

return false;
}


And then checking for the line segment intersections using the code I detailed here.

http://www.gamedev.net/community/forums/topic.asp?topic_id=428579

I think I might just finish it like this for the hell of it and do some major optimizing / reconstruction of these algorithms later.

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!