Ejemplo n.º 1
0
        /* Classes supporthing the creation of the lightsource */
        public Scientrace.LightSource setRandomCylinderLightFromXData(XElement xlight,
                                                                      Scientrace.Object3dEnvironment env)
        {
            //Reading LightSource parameters from XML-element

            /* "RandomCylinder"
             * d class.radius, d distance, i beamcount, i maxinteractions, d minintensity
             * str spectrum, vec location, vec direction */
            double radius = this.X.getXDouble(xlight.Attribute("Radius"));

            if (radius <= 0)
            {
                throw new ArgumentOutOfRangeException("Radius " + radius + " out of range");
            }
            double distance  = this.X.getXDouble(xlight.Attribute("Distance"), 0);
            int    beamcount = this.X.getXInt(xlight.Attribute("RayCount"), this.X.getXInt(xlight.Attribute("BeamCount")));
            //int maxinteractions = this.X.getXInt(xlight.Attribute("MaxInteractions"), 8); //default value max_interactions -> 8
            double minintensity = this.X.getXDouble(xlight.Attribute("MinIntensity"), 0.01);             //default minimum intensity for tracing set to 1%

            Scientrace.Vector   light_direction = this.X.getXVector(xlight.Element("Direction"));
            Scientrace.Location centerloc       = this.X.getXVector(xlight.Element("Location")).toLocation();
            Scientrace.Location locoffset       = (light_direction.negative() * distance).toLocation();     //distance cm above surface
            Scientrace.Location loc             = locoffset + centerloc;
            XMLSpectrumParser   xsp             = new XMLSpectrumParser();

            Scientrace.LightSpectrum spectrum = xsp.parseLightSpectrum(xlight.Element("Spectrum"));

            Scientrace.LightSource retlight = new Scientrace.RandomCircleLightSource(env,
                                                                                     loc, light_direction.tryToUnitVector(),
                                                                                     new Scientrace.Plane(new Scientrace.Location(0, 0, 0), new Scientrace.NonzeroVector(1, 0, 0), new Scientrace.NonzeroVector(0, 0, 1)),
                                                                                     radius, beamcount, spectrum);
            //retlight.max_interactions = maxinteractions;
            retlight.minimum_intensity_fraction = minintensity;
            return(retlight);
        }
Ejemplo n.º 2
0
        /* Classes supporthing the creation of the lightsource */
        public Scientrace.LightSource setRandomCylinderLightFromXData(XElement xlight, 
												Scientrace.Object3dEnvironment env)
        {
            //Reading LightSource parameters from XML-element

            /* "RandomCylinder"
             * d class.radius, d distance, i beamcount, i maxinteractions, d minintensity
             * str spectrum, vec location, vec direction */
            double radius = this.X.getXDouble(xlight.Attribute("Radius"));
                if (radius <= 0) {throw new ArgumentOutOfRangeException("Radius "+radius+" out of range");}
            double distance = this.X.getXDouble(xlight.Attribute("Distance"), 0);
            int beamcount = this.X.getXInt(xlight.Attribute("RayCount"), this.X.getXInt(xlight.Attribute("BeamCount")));
            //int maxinteractions = this.X.getXInt(xlight.Attribute("MaxInteractions"), 8); //default value max_interactions -> 8
            double minintensity = this.X.getXDouble(xlight.Attribute("MinIntensity"), 0.01); //default minimum intensity for tracing set to 1%

            Scientrace.Vector light_direction = this.X.getXVector(xlight.Element("Direction"));
            Scientrace.Location centerloc = this.X.getXVector(xlight.Element("Location")).toLocation();
            Scientrace.Location locoffset = (light_direction.negative()*distance).toLocation(); //distance cm above surface
            Scientrace.Location loc = locoffset + centerloc;
                XMLSpectrumParser xsp = new XMLSpectrumParser();
            Scientrace.LightSpectrum spectrum = xsp.parseLightSpectrum(xlight.Element("Spectrum"));

            Scientrace.LightSource retlight = new Scientrace.RandomCircleLightSource(env,
                loc, light_direction.tryToUnitVector(),
                new Scientrace.Plane(new Scientrace.Location(0,0,0),new Scientrace.NonzeroVector(1, 0, 0), new Scientrace.NonzeroVector(0,0,1)),
                radius, beamcount, spectrum);
            //retlight.max_interactions = maxinteractions;
            retlight.minimum_intensity_fraction = minintensity;
            return retlight;
        }