コード例 #1
0
ファイル: Intersection.cs プロジェクト: tincann/AGR
 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
ファイル: Intersection.cs プロジェクト: tincann/AGR
 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
ファイル: IntersectionHelper.cs プロジェクト: tincann/AGR
 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
ファイル: Instance.cs プロジェクト: lunactic/RayTracer
        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
ファイル: Intersectable.cs プロジェクト: HImports/IslandGame
        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
ファイル: IntersectionHelper.cs プロジェクト: tincann/AGR
 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
ファイル: Instance.cs プロジェクト: lunactic/RayTracer
 public int GetNumberOfComponents()
 {
     return(Intersectable.GetNumberOfComponents());
 }
コード例 #12
0
ファイル: Instance.cs プロジェクト: lunactic/RayTracer
 public new Vector3 GetSamplePoint(LightSample sample)
 {
     return(Intersectable.GetSamplePoint(sample));
 }
コード例 #13
0
ファイル: Instance.cs プロジェクト: lunactic/RayTracer
 public override void BuildBoundingBox()
 {
     Intersectable.BuildBoundingBox();
 }
コード例 #14
0
ファイル: Intersection.cs プロジェクト: tincann/AGR
 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
ファイル: Intersection.cs プロジェクト: tincann/AGR
 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
ファイル: Instance.cs プロジェクト: lunactic/RayTracer
 public new float GetArea()
 {
     return(Intersectable.GetArea());
 }
コード例 #18
0
ファイル: Scene.cs プロジェクト: tincann/AGR
 public void Add(Intersectable intersectable)
 {
     _intersectables.Add(intersectable);
 }