public GetDistance ( Axiom.Math.Vector3 point ) : Real | ||
point | Axiom.Math.Vector3 | |
return | Real |
/// <summary> /// Intersection test with <see cref="Sphere"/>. /// </summary> /// <param name="sphere">Sphere to test.</param> /// <returns>True if the sphere intersects this volume, and false otherwise.</returns> public bool Intersects(Sphere sphere) { for (int i = 0; i < planes.Count; i++) { Plane plane = (Plane)planes[i]; // Test which side of the plane the sphere is Real d = plane.GetDistance(sphere.Center); // Negate d if planes point inwards if (outside == PlaneSide.Negative) { d = -d; } if ((d - sphere.Radius) > 0) { return(false); } } // assume intersecting return(true); }
protected bool CalculateForPointLight( Plane plane, Vector3[] vertices, out Vector2[] texCoors, out ColorEx[] colors ) { texCoors = new Vector2[ vertices.Length ]; colors = new ColorEx[ vertices.Length ]; Vector3 lightPos, faceLightPos; lightPos = this.GetDerivedPosition(); float dist = plane.GetDistance( lightPos ); if ( Utility.Abs( dist ) < range ) { // light is visible //light pos on face faceLightPos = lightPos - plane.Normal * dist; Vector3 verAxis = plane.Normal.Perpendicular(); Vector3 horAxis = verAxis.Cross( plane.Normal ); Plane verPlane = new Plane( verAxis, faceLightPos ); Plane horPlane = new Plane( horAxis, faceLightPos ); float lightRadiusSqr = range * range; float relRadiusSqr = lightRadiusSqr - dist * dist; float relRadius = Utility.Sqrt( relRadiusSqr ); float scale = 0.5f / relRadius; float brightness = relRadiusSqr / lightRadiusSqr; ColorEx lightCol = new ColorEx( brightness * textureColor.a, textureColor.r, textureColor.g, textureColor.b ); for ( int i = 0; i < vertices.Length; i++ ) { texCoors[ i ].x = horPlane.GetDistance( vertices[ i ] ) * scale + 0.5f; texCoors[ i ].y = verPlane.GetDistance( vertices[ i ] ) * scale + 0.5f; colors[ i ] = lightCol; } return true; } return false; }