Beispiel #1
0
        public bool intersect(Ray r, double tmax)
        {
            int   nhits = 0;
            Isect temp  = new Isect();

            temp.t     = 1e9;
            this.inter = temp;
            int i = 0;

            while (i < this.prim.Length)
            {
                Isect tp = this.prim[i].intersect(r);
                bool  sw = (tp != null);
                if (sw)
                {
                    Isect isect = new Isect();
                    isect.t     = tp.t;
                    isect.prim  = tp.prim;
                    isect.surf  = tp.surf;
                    isect.enter = tp.enter;
                    this.inter  = isect;
                    nhits       = nhits + 1;
                }
                i = i + 1;
            }
            return(nhits > 0 ? true : false);
        }
Beispiel #2
0
        public override Isect intersect(Ray ry)
        {
            Vec p = ry.P;
            Vec d = ry.D;

            v.sub2(c, p);
            double b     = Vec.dot(v, d);
            double dotVV = Vec.dot(v, v);
            double disc  = b * b - dotVV + r2;

            if (disc < 0.0)
            {
                return(null);
            }
            disc = Math.Sqrt(disc);
            double t = (b - disc < 1e-6) ? b + disc : b - disc;

            if (t < 1e-6)
            {
                return(null);
            }
            Isect ip = new Isect();

            ip.t     = t;
            ip.enter = dotVV > r2 + 1e-6 ? 1.0 : 0.0;
            ip.prim  = this;
            ip.surf  = this.surf;
            return(ip);
        }
        public var intersect(var r, var tmax)
        {
            var nhits = 0;
            var temp  = new Isect();

            temp.t     = 1e9;
            this.inter = temp;
            int i = 0;

            while (i < this.prim.Length)
            {
                var  tp = this.prim[i].intersect(r);
                bool sw = (tp != null);
                if (sw)
                {
                    var isect = new Isect();
                    isect.t     = tp.t;
                    isect.prim  = tp.prim;
                    isect.surf  = tp.surf;
                    isect.enter = tp.enter;
                    this.inter  = isect;
                    nhits       = nhits + 1;
                }
                i = i + 1;
            }
            return(nhits > 0 ? true : false);
        }
Beispiel #4
0
 public void JGFtidyup()
 {
     scene  = new Scene();
     lights = new Light[0];
     prim   = new Primitive[0];
     tRay   = new Ray();
     inter  = new Isect();
 }
Beispiel #5
0
 public RayTracer()
 {
     datasizes         = new int[3];
     datasizes[0]      = 5;
     datasizes[1]      = 25;
     datasizes[2]      = 125;
     RayTracer.alpha   = 255 << 24;
     tRay              = new Ray();
     RayTracer.voidVec = new Vec();
     L        = new Vec();
     inter    = new Isect();
     checksum = 0;
 }