Dimension RayIntersectionWithPlane (const SRay &Ray, const SRay &PlaneNormal) // RayIntersectionWithPlane // // Returns the distance along the ray at which it intersects the given plane // If the two do not intersect, we return INFINITY // // Source: Foley/vanDam, p.703 { // Get the coefficients for the plane equation Dimension A, B, C, D; PlaneEq(PlaneNormal, &A, &B, &C, &D); // Compute ray deltas Dimension dX = Ray.vDir.X(); Dimension dY = Ray.vDir.Y(); Dimension dZ = Ray.vDir.Z(); // Compute intersection Dimension rDenominator = A * dX + B * dY + C * dZ; if (EqZero(rDenominator)) return INFINITY; // Done return -(A * Ray.vOrigin.X() + B * Ray.vOrigin.Y() + C * Ray.vOrigin.Z() + D) / rDenominator; }
PositionShapePart( const Moo::Colour& col, int axis ) : colour_( col ), isFree_( false ), isPlane_( true ) { Vector3 normal( 0, 0, 0 ); normal[axis] = 1.f; planeEq_ = PlaneEq( normal, 0 ); }
//TODO: create some general purpose clip plane functionality PlaneEq currentClipPlane() { return PlaneEq(Vector3(0,waterHeight(),0), Vector3(0,1,0)); }