예제 #1
0
 public IntersectionInfo(float distance, Ray4 localRay, Vector3 baryCoord, Geomertry geomertry)
 {
     Distance = distance;
     BaryCoord = baryCoord;
     LocalRay = localRay;
     Geomertry = geomertry;
 }
예제 #2
0
 public IntersectionInfo(float distance, Ray originalRay, Vector3 baryCoord, Geomertry geomertry)
 {
     Distance = distance;
     BaryCoord = baryCoord;
     OriginalRay = originalRay;
     Geomertry = geomertry;
 }
예제 #3
0
        public static Intersectable CreateIntersectable(Geomertry geomertry)
        {
            if (geomertry is Triangle)
                return new TriangeIntersectable((Triangle) geomertry);
            else if (geomertry is CalculatedTriangle)
            {
                return new CalculatedTriangeIntersectable((CalculatedTriangle) geomertry);
            }
            else if (geomertry is Sphere)
            {
                return new SphereIntersectable((Sphere) geomertry);
            }

            throw new Exception("Unsuported geometry type");
        }
예제 #4
0
        private static bool ContaiseGeomertry(BoundingBox box, Geomertry geomertry)
        {
            if (geomertry is Triangle)
            {
                Triangle triangle = (Triangle) geomertry;

                Vector3 at = Vector3.Transform(triangle.A, triangle.Transform);
                Vector3 bt = Vector3.Transform(triangle.B, triangle.Transform);
                Vector3 ct = Vector3.Transform(triangle.C, triangle.Transform);

                return box.Contains(at) == ContainmentType.Contains ||
                       box.Contains(bt) == ContainmentType.Contains ||
                       box.Contains(ct) == ContainmentType.Contains;
            }
            else if (geomertry is Sphere)
            {
                Sphere sphere = (Sphere) geomertry;

                Vector3 center = Vector3.Transform(sphere.Center, sphere.Transform);
                float rx = sphere.Radius*sphere.Transform.M11;
                float ry = sphere.Radius*sphere.Transform.M22;
                float rz = sphere.Radius*sphere.Transform.M33;
                float maxR = Math.Max(rx, Math.Max(ry, rz));

                float a = box.Max.X - box.Min.X;
                float b = box.Max.Y - box.Min.Y;
                float c = box.Max.Z - box.Min.Z;

                float halfDiagonal = (float) ((Math.Sqrt(a*a + b*b + c*c))/2.0);
                float distance = Vector3.Distance(center, (box.Max + box.Min)/2.0f);

                return distance <= halfDiagonal + maxR;
            }

            throw new Exception("Unsupported geometry");
        }
예제 #5
0
 public Intersectable(Geomertry geomertry)
 {
     Geomertry = geomertry;
 }
예제 #6
0
 public IntersectionInfo(float distance, Ray4 localRay, Geomertry geomertry)
 {
     Distance = distance;
     LocalRay = localRay;
     Geomertry = geomertry;
 }
예제 #7
0
 public IntersectionInfo(float distance, Ray originalRay, Geomertry geomertry)
 {
     Distance = distance;
     OriginalRay = originalRay;
     Geomertry = geomertry;
 }