Here's an intersection function.

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Here's an intersection function.

Post by 3DModelerMan »

If anyone's been having trouble with intersection with lines like I did. Then here's a function.

Code: Select all

//intersection function

bool isIntersection( ITriangleSelector* selector, line3df line )
{
   s32 ntris = 0;
   triangle3df tris[selector->getTriangleCount()];
   selector->getTriangles(tris, selector->getTriangleCount() , ntris);

   vector3df point;

   bool is_intersection;

    for(int i=0; i < selector->getTriangleCount(); ++i)
  {
   if ( tris[i].getIntersectionWithLimitedLine( line, point ) == true )
   {
    is_intersection = true;
    break;
   }
   else
   {
    is_intersection = false;
   }

  }


  return is_intersection;

}
Kind of a dopey function. But I thought I would share it so you could copy and paste it if you need a quick one.
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
Post Reply