Пример #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);
        }
Пример #2
0
        /// <summary>
        /// Default behavior - create scene selected in the combo-box.
        /// Can handle InitSceneDelegate, InitSceneParamDelegate or CSscript file-name
        /// </summary>
        public IRayScene SceneByComboBox(
            out IImageFunction imf,
            out IRenderer rend,
            ref int width,
            ref int height,
            ref int superSampling)
        {
            string sceneName = (string)ComboScene.Items[selectedScene];

            if (sceneRepository.TryGetValue(sceneName, out object definition))
            {
                // Try the CS-script file.
                if (ctx == null)
                {
                    ctx = new ScriptContext(); // we need a new context object for each computing batch..
                }
                if (Scripts.ContextInit(
                        ctx,
                        sceneName,
                        width,
                        height,
                        superSampling))
                {
                    // Script needs to be called.

                    Scripts.SceneFromObject(
                        ctx,
                        definition,
                        TextParam.Text,
                        (sc) => Scenes.DefaultScene(sc),
                        SetText);
                }

                double minTime = 0.0;
                double maxTime = 10.0;
                double fps     = 25.0;

                return(Scripts.ContextMining(
                           ctx,
                           out imf,
                           out rend,
                           out tooltip,
                           ref width,
                           ref height,
                           ref superSampling,
                           ref minTime,
                           ref maxTime,
                           ref fps));
            }

            // Fallback to a default scene.
            imf  = null;
            rend = null;
            return(Scenes.DefaultScene());
        }
Пример #3
0
        /// <summary>
        /// Default behavior - create scene selected in the combo-box.
        /// Can handle InitSceneDelegate, InitSceneParamDelegate or CSscript file-name
        /// </summary>
        public IRayScene SceneByComboBox()
        {
            string sceneName = (string)ComboScene.Items[selectedScene];

            if (sceneRepository.TryGetValue(sceneName, out object definition))
            {
                return(Scripts.SceneFromObject(new DefaultRayScene(), sceneName, definition, TextParam.Text,
                                               (sc) => Scenes.DefaultScene(sc), SetText));
            }

            // fallback to a default scene;
            return(Scenes.DefaultScene());
        }