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.

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 on other sites
http://www.flipcode.com/articles/article_basiccollisions.shtml

Share on other sites
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.

1. 1
2. 2
3. 3
Rutin
21
4. 4
5. 5
gaxio
10

• 14
• 30
• 13
• 11
• 11
• Forum Statistics

• Total Topics
631778
• Total Posts
3002310
×