Ejemplo n.º 1
0
        public Scientrace.LightSource parseXLight(XElement xlight, Scientrace.Object3dEnvironment env)
        {
            Scientrace.LightSource retlight = null;
            string lightclass;

            try {
                lightclass = xlight.Attribute("Class").Value;
            } catch {
                throw new XMLException("Light class type not specified");
            }

//		XMLTraceModifierParser xtmp = new XMLTraceModifierParser(xlight, this.X);
            XMLTraceModifierParser     xtmp = new XMLTraceModifierParser();
            ShadowLightSourceConstruct slsc = new ShadowLightSourceConstruct();

            switch (lightclass)
            {
            case "SingleRay":
                List <Scientrace.UniformTraceModifier> utms = xtmp.getModifiers(xlight);
                retlight = this.setSingleRayFromXData(xlight, utms, env);
                break;

            //case "CustomTraces":
            //retlight = this.setCustomTracesLightFromXData(xlight, env);
            //break;
            case "TestLight":
                //Console.WriteLine("TESTLightsource");
                retlight = this.setTestLightFromXData(xlight, env);
                break;

            case "RandomCylinder":
                Console.WriteLine("Random Cylinder Lightsource");
                retlight = this.setRandomCylinderLightFromXData(xlight, env);
                break;

//		    case "Spiral":
//			case "RandomSquare":
            default:
                // No old style LightSource parsing class found? Good, let's hope there's a prettier ShadowClass constructor to do this.
                if (slsc.getClass(lightclass) != null)
                {
                    retlight = slsc.constructLightSource(xlight, env);
                    break;
                }
                else                 //damnit, there wasn't a ShadowClass constructor either.
                {
                    throw new XMLException("unknown light class type");
                }
            }
            this.addLightSourceTag(retlight, xlight);
            /* Generic (not lightsource-subclass specific) behaviour */
            retlight.max_interactions = this.X.getXInt(xlight.Attribute("MaxInteractions"), 15);
            //this.lightsource.minimum_intensity = this.X.getXDouble(xlight.Attribute("MinIntensity"), 0.10);
            //line above fails for sources with < 1 intensities.
            return(retlight);
        }
Ejemplo n.º 2
0
        public Scientrace.LightSource parseXLight(XElement xlight, Scientrace.Object3dEnvironment env)
        {
            Scientrace.LightSource retlight = null;
            string lightclass;
            try {
            lightclass = xlight.Attribute("Class").Value;
            } catch {
            throw new XMLException("Light class type not specified");
            }

            //		XMLTraceModifierParser xtmp = new XMLTraceModifierParser(xlight, this.X);
            XMLTraceModifierParser xtmp = new XMLTraceModifierParser();
            ShadowLightSourceConstruct slsc = new ShadowLightSourceConstruct();

            switch (lightclass) {
            case "SingleRay":
                List<Scientrace.UniformTraceModifier> utms = xtmp.getModifiers(xlight);
                retlight = this.setSingleRayFromXData(xlight, utms, env);
                break;
            //case "CustomTraces":
                //retlight = this.setCustomTracesLightFromXData(xlight, env);
                //break;
            case "TestLight":
                //Console.WriteLine("TESTLightsource");
                retlight = this.setTestLightFromXData(xlight, env);
                break;
            case "RandomCylinder":
                Console.WriteLine("Random Cylinder Lightsource");
                retlight = this.setRandomCylinderLightFromXData(xlight, env);
                break;
            //		    case "Spiral":
            //			case "RandomSquare":
            default:
                // No old style LightSource parsing class found? Good, let's hope there's a prettier ShadowClass constructor to do this.
                if (slsc.getClass(lightclass)!=null)  {
                    retlight = slsc.constructLightSource(xlight, env);
                    break;
                    }
                else //damnit, there wasn't a ShadowClass constructor either.
                    throw new XMLException("unknown light class type");
            }
            this.addLightSourceTag(retlight, xlight);
            /* Generic (not lightsource-subclass specific) behaviour */
            retlight.max_interactions = this.X.getXInt(xlight.Attribute("MaxInteractions"), 15);
            //this.lightsource.minimum_intensity = this.X.getXDouble(xlight.Attribute("MinIntensity"), 0.10);
            //line above fails for sources with < 1 intensities.
            return retlight;
        }