Example #1
0
        /// <summary>
        /// Default behavior - create scene selected in the combo-box.
        /// </summary>
        public IRayScene SceneByComboBox()
        {
            DefaultRayScene sc        = new DefaultRayScene();
            string          sceneName = (string)comboScene.Items[selectedScene];

            object                 initFunction;
            InitSceneDelegate      isd  = null;
            InitSceneParamDelegate ispd = null;

            sceneRepository.TryGetValue(sceneName, out initFunction);
            isd  = initFunction as InitSceneDelegate;
            ispd = initFunction as InitSceneParamDelegate;
            if (isd == null &&
                ispd == null)
            {
                return(Scenes.DefaultScene(sc));
            }

            if (isd != null)
            {
                isd(sc);
            }
            else
            {
                ispd?.Invoke(sc, textParam.Text);
            }

            SetText($"Rendering '{sceneName}'..");
            return(sc);
        }
Example #2
0
        /// <summary>
        /// Default behavior - create scene selected in the combo-box.
        /// </summary>
        public IRayScene SceneByComboBox()
        {
            DefaultRayScene sc        = new DefaultRayScene();
            string          sceneName = (string)comboScene.Items[selectedScene];

            object                 initFunction;
            InitSceneDelegate      isd  = null;
            InitSceneParamDelegate ispd = null;

            sceneRepository.TryGetValue(sceneName, out initFunction);
            isd  = initFunction as InitSceneDelegate;
            ispd = initFunction as InitSceneParamDelegate;
            if (isd == null &&
                ispd == null)
            {
                isd = Scenes.staticRepository["Sphere on the plane"] as InitSceneDelegate;
            }

            if (isd != null)
            {
                isd(sc);
            }
            else
            {
                ispd?.Invoke(sc, textParam.Text);
            }

            return(sc);
        }
Example #3
0
        /// <summary>
        /// Default behavior - create scene selected in the combo-box.
        /// </summary>
        public IRayScene SceneByComboBox()
        {
            DefaultRayScene sc    = new DefaultRayScene();
            long            faces = sceneInitFunctions[selectedScene](sc, new string[] { objFileName });

            SetText("Faces: " + faces);
            CSGInnerNode.countFaces = faces;
            return(sc);
        }
Example #4
0
        /// <summary>
        /// Create a scene from the defined CS-script file-name.
        /// Returns null if failed.
        /// </summary>
        /// <param name="preprocessing">Invoke the script in the "preprocessing" mode?</param>
        public IRayScene SceneFromScript(
            bool preprocessing,
            out IImageFunction imf,
            out IRenderer rend,
            ref int width,
            ref int height,
            ref int superSampling,
            ref double minTime,
            ref double maxTime,
            ref double fps)
        {
            if (string.IsNullOrEmpty(sceneFileName))
            {
                imf     = null;
                rend    = null;
                tooltip = "";
                return(null);
            }

            if (preprocessing)
            {
                ctx = new ScriptContext(); // we need a new context object for each computing batch..
            }
            Scripts.ContextInit(
                ctx,
                preprocessing ? new AnimatedRayScene() : null,
                width,
                height,
                superSampling,
                minTime,
                maxTime,
                fps);

            Scripts.SceneFromObject(
                ctx,
                Path.GetFileName(sceneFileName),
                sceneFileName,
                textParam.Text,
                (sc) => AnimatedScene.Init(sc, textParam.Text),
                SetText);

            DefaultRayScene scene = Scripts.ContextMining(
                ctx,
                out imf,
                out rend,
                out tooltip,
                ref width,
                ref height,
                ref superSampling,
                ref minTime,
                ref maxTime,
                ref fps);

            return(scene);
        }