示例#1
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);
        }