Ejemplo n.º 1
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..
                    Dictionary <string, string> p = Util.ParseKeyValueList(TextParam.Text);
                    double time = 0.0;
                    if (Util.TryParse(p, "time", ref time))
                    {
                        Scripts.SetScene(ctx, new AnimatedRayScene());
                    }
                }

                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());
        }