Пример #1
0
 public Intersection(Intersectable intersectsWith, Ray ray, Vector3 surfaceNormal, Vector3 location, float distance, Material material)
 {
     IntersectsWith = intersectsWith;
     Ray            = ray;
     SurfaceNormal  = surfaceNormal;
     Location       = location;
     Distance       = distance;
     Material       = material;
 }
Пример #2
0
        public static Ray CreateFromTwoPoints(Vector3 origin, Vector3 target, Intersectable originalPrimitive)
        {
            var dir = target - origin;

            return(new Ray(origin, dir, Constants.MaxRayBounces, originalPrimitive)
            {
                T = dir.LengthFast
            });
        }
Пример #3
0
 public Intersection(Intersectable intersectsWith, Ray ray, Vector3 surfaceNormal, Vector3 location, float distance, Material material)
 {
     IntersectsWith = intersectsWith;
     Ray = ray;
     SurfaceNormal = surfaceNormal;
     Location = location;
     Distance = distance;
     Material = material;
 }
Пример #4
0
        public override float?intersects(Ray ray)
        {
            //return Intersection.intersects(ray, resourceBlocks.Keys);
            Intersectable intersected = Intersection.getNearestIntersectableAlongRay(ray, stockpiles);

            if (intersected != null)
            {
                return(intersected.intersects(ray));
            }
            return(null);
        }
Пример #5
0
 public static bool DoesIntersect(Ray ray, IEnumerable<Intersectable> intersectables, Intersectable ignore = null)
 {
     foreach (var obj in intersectables)
     {
         //if (obj is DebugSphere)
         //{
         //    continue;
         //}
         Intersection intersection;
         if (obj != ignore && obj.Intersect(ray, out intersection))// && !ReferenceEquals(ray.OriginPrimitive, obj))
         {
             return true;
         }
     }
     return false;
 }
Пример #6
0
        public new HitRecord Intersect(Ray ray)
        {
            //Transform ray to object coordinate system
            Ray       transfRay = RayTransformer.TransformRayToObject(ray, InvTransformationMatrix);
            HitRecord hit       = Intersectable.Intersect(transfRay);


            if (hit != null)
            {
                if (Material != null)
                {
                    hit.Material = Material;
                }
                //Transform HitRecrod back to world coordinate system
                RayTransformer.TransformHitToWorld(hit, TransformationMatrix, TransposedTransformationMatrix);
            }
            return(hit);
        }
Пример #7
0
        public static float?intersects(Ray ray, IEnumerable <Intersectable> intersectables)
        {
            float?        minDist = float.MaxValue;
            Intersectable result  = null;

            foreach (Intersectable site in intersectables)
            {
                float?thisDist = site.intersects(ray);
                if (thisDist.HasValue)
                {
                    if (minDist > thisDist)
                    {
                        minDist = thisDist;
                        result  = site;
                    }
                }
            }
            return(minDist);
        }
Пример #8
0
 public static bool DoesIntersect(Ray ray, IEnumerable <Intersectable> intersectables, Intersectable ignore = null)
 {
     foreach (var obj in intersectables)
     {
         //if (obj is DebugSphere)
         //{
         //    continue;
         //}
         Intersection intersection;
         if (obj != ignore && obj.Intersect(ray, out intersection))// && !ReferenceEquals(ray.OriginPrimitive, obj))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #9
0
 public Ray(Vector3 origin, Vector3 direction, int bouncesLeft, Intersectable originPrimitive, Material medium) : this(origin, direction, bouncesLeft)
 {
     OriginPrimitive = originPrimitive;
     Medium          = medium;
 }
Пример #10
0
 public Ray(Vector3 origin, Vector3 direction, int bouncesLeft, Intersectable originPrimitive) : this(origin, direction, bouncesLeft)
 {
     OriginPrimitive = originPrimitive;
 }
Пример #11
0
 public int GetNumberOfComponents()
 {
     return(Intersectable.GetNumberOfComponents());
 }
Пример #12
0
 public new Vector3 GetSamplePoint(LightSample sample)
 {
     return(Intersectable.GetSamplePoint(sample));
 }
Пример #13
0
 public override void BuildBoundingBox()
 {
     Intersectable.BuildBoundingBox();
 }
Пример #14
0
 public Intersection(Intersectable intersectsWith, Ray ray, Vector3 surfaceNormal, Vector3 location,
                     float distance, Material material, bool insidePrimitive)
     : this(intersectsWith, ray, surfaceNormal, location, distance, material)
 {
     InsidePrimitive = insidePrimitive;
 }
Пример #15
0
 public void Add(Intersectable intersectable)
 {
     _intersectables.Add(intersectable);
 }
Пример #16
0
 public Intersection(Intersectable intersectsWith, Ray ray, Vector3 surfaceNormal, Vector3 location,
     float distance, Material material, bool insidePrimitive)
     : this(intersectsWith, ray, surfaceNormal, location, distance, material)
 {
     InsidePrimitive = insidePrimitive;
 }
Пример #17
0
 public new float GetArea()
 {
     return(Intersectable.GetArea());
 }
Пример #18
0
 public void Add(Intersectable intersectable)
 {
     _intersectables.Add(intersectable);
 }