Alright, thank you all very much for your help so far. ;D ;D ;D
Is there anyway I can see if the point is facing the normal in this code (from Eli)? My player is getting stuck on corners.
Edit: I’m using the circle in triangle for ground collision, so it’s not going to waste. :>
public boolean isPointInTriangle( Vector3f p, Vector3f a, Vector3f b, Vector3f c )
{
return ( pointsAreOnSameSide(p, a, b, c) && pointsAreOnSameSide(p, b, a, c) && pointsAreOnSameSide(p, c, a, b) );
}
public boolean pointsAreOnSameSide( Vector3f p1, Vector3f p2, Vector3f a, Vector3f b )
{
Vector3f diffba = new Vector3f(0,0,0);
Vector3f.sub( b, a, diffba );
Vector3f diffp1a = new Vector3f(0,0,0);
Vector3f.sub( p1, a, diffp1a );
Vector3f diffp2a = new Vector3f(0,0,0);
Vector3f.sub( p2, a, diffp2a );
Vector3f cross1 = new Vector3f();
Vector3f.cross(diffba, diffp1a, cross1);
Vector3f cross2 = new Vector3f();
Vector3f.cross(diffba, diffp2a, cross2);
return ( Vector3f.dot( cross1, cross2 ) >= 0 );
}