示例#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;
 }
        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
文件: Scene.cs 项目: tincann/AGR
 public void Add(Intersectable intersectable)
 {
     _intersectables.Add(intersectable);
 }