Beispiel #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);
        }
Beispiel #2
0
        public void setLightSourceSettings(ShadowScientrace.ShadowLightSource shadowLS, XElement xel)
        {
            XMLTraceModifierParser xtmp = new XMLTraceModifierParser();
            List <Scientrace.UniformTraceModifier> utms = xtmp.getModifiers(xel);

            shadowLS.arguments.Add("trace_modifiers", utms);
            double minintensity = this.X.getXDouble(xel, "MinIntensity", 0.2);     //default minimum intensity for tracing set to 1%

            shadowLS.arguments.Add("minimum_intensity_fraction", minintensity);
        }
        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;
        }
 public void setLightSourceSettings(ShadowScientrace.ShadowLightSource shadowLS, XElement xel)
 {
     XMLTraceModifierParser xtmp = new XMLTraceModifierParser();
     List<Scientrace.UniformTraceModifier> utms = xtmp.getModifiers(xel);
     shadowLS.arguments.Add("trace_modifiers", utms);
     double minintensity = this.X.getXDouble(xel, "MinIntensity", 0.2); //default minimum intensity for tracing set to 1%
     shadowLS.arguments.Add("minimum_intensity_fraction", minintensity);
 }
Beispiel #5
0
        public void parseXObject3d(XElement xel, Scientrace.Object3dCollection col, XMLObject3dParser o3dp, ShadowClassConstruct shadowConstructor)
        {
            Scientrace.Object3d createdObject3d = null;
            switch (xel.Name.ToString())
            {
            case "CircularFresnelPrism":
                createdObject3d = o3dp.parseXFresnelPrism(xel);
                break;

            case "ParabolicMirror":
                createdObject3d = o3dp.parseXParabolicMirror(xel);
                //PARSE PARAB MIRROR
                break;

            case "Prism":             //fall through
            case "TriangularPrism":
                createdObject3d = shadowConstructor.constructTriangularPrism(xel);
                //createdObject3d = o3dp.parseXTriangularPrism(xel);
                break;

            case "RectangularPrism":
                createdObject3d = o3dp.parseXRectangularPrism(xel);
                break;

            case "SquareCell":
            case "Rectangle":
                //square cell can be used for any square or rectangular surface-object
                //createdObject3d = o3dp.parseXRectangle(xel);
                createdObject3d = shadowConstructor.constructRectangle(xel);
                break;

            case "Sphere":
                createdObject3d = o3dp.parseXSphere(xel);
                break;

            case "FresnelLens":
                createdObject3d = shadowConstructor.constructFresnelLens(xel);
                break;

            case "FresnelLensRing":
                createdObject3d = shadowConstructor.constructFresnelLensRing(xel);
                break;

            case "PlanoConvexLens":
                createdObject3d = o3dp.parseXPlanoConvexLens(xel);
                break;

            case "DoubleConvexLens":
                //createdObject3d = o3dp.parseXDoubleConvexLens(xel);
                createdObject3d = shadowConstructor.constructDoubleConvexLens(xel);
                break;

            case "BorderedVolume":
                createdObject3d = o3dp.parsXBorderedVolume(xel);
                break;

            case "ToppedPyramid":
            case "TruncatedPyramid":
                createdObject3d = o3dp.parseXTruncatedPyramid(xel);
                break;

            case "CameraViewpoint":        //fallthrough
            case "CameraFrom":             //fallthrough
            case "CameraRotation":
                //Cam settings set at environment.
                break;

            case "LightSource":
                //do nothing, already parsed previously
                break;

            case "Ignore":
            case "IGNORE":
                //do nothing, IGNORE!
                break;

            default:
                if (!(xel.Name.ToString().Substring(0, 3) == "REM"))
                {
                    Console.WriteLine("WARNING: UNKNOWN OBJECT: " + xel.Name + " \n[XML code]\n" + xel.ToString() + "\n[/XML code]\n");
                }
                break;
            }
            if (createdObject3d != null)
            {
                XMLTraceModifierParser xtmp = new XMLTraceModifierParser();
                List <Scientrace.UniformTraceModifier> utms = xtmp.getModifiers(xel);
                createdObject3d.addSurfaceModifiers(utms);
            }
        }         // end parseXObject3d
 public void parseXObject3d(XElement xel, Scientrace.Object3dCollection col, XMLObject3dParser o3dp, ShadowClassConstruct shadowConstructor)
 {
     Scientrace.Object3d createdObject3d = null;
     switch (xel.Name.ToString()) {
     case "CircularFresnelPrism":
         createdObject3d = o3dp.parseXFresnelPrism(xel);
         break;
     case "ParabolicMirror":
         createdObject3d = o3dp.parseXParabolicMirror(xel);
         //PARSE PARAB MIRROR
         break;
     case "Prism": //fall through
     case "TriangularPrism":
         createdObject3d = shadowConstructor.constructTriangularPrism(xel);
         //createdObject3d = o3dp.parseXTriangularPrism(xel);
         break;
     case "RectangularPrism":
         createdObject3d = o3dp.parseXRectangularPrism(xel);
         break;
     case "SquareCell":
     case "Rectangle":
         //square cell can be used for any square or rectangular surface-object
         //createdObject3d = o3dp.parseXRectangle(xel);
         createdObject3d = shadowConstructor.constructRectangle(xel);
         break;
     case "Sphere":
         createdObject3d = o3dp.parseXSphere(xel);
         break;
     case "FresnelLens":
         createdObject3d = shadowConstructor.constructFresnelLens(xel);
         break;
     case "FresnelLensRing":
         createdObject3d = shadowConstructor.constructFresnelLensRing(xel);
         break;
     case "PlanoConvexLens":
         createdObject3d = o3dp.parseXPlanoConvexLens(xel);
         break;
     case "DoubleConvexLens":
         //createdObject3d = o3dp.parseXDoubleConvexLens(xel);
         createdObject3d = shadowConstructor.constructDoubleConvexLens(xel);
         break;
     case "BorderedVolume":
         createdObject3d = o3dp.parsXBorderedVolume(xel);
         break;
     case "ToppedPyramid":
     case "TruncatedPyramid":
         createdObject3d = o3dp.parseXTruncatedPyramid(xel);
         break;
     case "CameraViewpoint": //fallthrough
     case "CameraFrom": //fallthrough
     case "CameraRotation":
         //Cam settings set at environment.
         break;
     case "LightSource":
         //do nothing, already parsed previously
         break;
     case "Ignore":
     case "IGNORE":
         //do nothing, IGNORE!
         break;
     default:
         if (!(xel.Name.ToString().Substring(0,3)=="REM")) {
             Console.WriteLine("WARNING: UNKNOWN OBJECT: "+xel.Name+" \n[XML code]\n"+xel.ToString()+"\n[/XML code]\n");
             }
         break;
     }
     if (createdObject3d != null) {
     XMLTraceModifierParser xtmp = new XMLTraceModifierParser();
     List<Scientrace.UniformTraceModifier> utms = xtmp.getModifiers(xel);
     createdObject3d.addSurfaceModifiers(utms);
     }
 }