Exemple #1
0
 private void InitialiseScene()
 {
     _Scene = new Scene(_Camera);
 }
        public FinalRender(ref Scene scene, ref Camera camera, ref PostProcess postprocess)
        {
            _Scene = scene;
            _Camera = camera;
            _Recursions = _Scene._Recursions;

            DataContext = this;
            InitializeComponent();
            _MaxValue = 1;
            _Factor = 1;
            _ToneFactor = 1.4;
            _GammaFactor = 0.7;
            _GammaContrast = 0.7;

            if (_Camera._AAEnabled)
                checkBox1.IsChecked = true;
            if (_Camera._DOFEnabled)
                checkBox2.IsChecked = true;
            if (_Scene._PathTracer)
                checkBox3.IsChecked = true;
            if (_Scene._Caustics)
                checkBox4.IsChecked = true;
            _SamplesPerPixel = _Camera._MinSamples;

            _PostProcess = postprocess;

            BuildXML();
        }
        public void RenderPreview()
        {
            _Camera = new Camera(new Vector3(0, 0.4, -0.75), new Vector3(0, 0.5, 0), 40, 0, 0);
            _Camera._AAEnabled = true;
            _Camera._DOFEnabled = false;

            string log = "", error = "";
            _BackgroundScript = new WooScript();
            _BackgroundScript._Program = "rule main {pos.y -= 1 box}";
            _BackgroundScript.Parse(ref log, ref error);
            _PreviewScript = new WooScript();
            _PreviewScript._Program = "rule main {diff=vec("+_Material._DiffuseColour.ToString()+")\r\n"
                + "spec=vec(" + _Material._SpecularColour.ToString() + ")\r\n"
                + "refl=vec(" + _Material._Reflectivity.ToString() + ")\r\n"
                + "emi=vec(" + _Material._EmissiveColour.ToString() + ")\r\n"
                + "power=" + _Material._SpecularPower.ToString() + "\r\n"
                + "gloss=" + _Material._Shininess.ToString() + "\r\n"
                + "sphere}";
            _PreviewScript.Parse(ref log, ref error);
            _LightingScript = new WooScript();
            _LightingScript._Program = "rule main {directionalLight(vec(1.0, 1.0, 1.0), vec(-0.7, 1.0, -0.6), 0.02, 1) background(vec(0.0,0.0,0.0))}";
            _LightingScript.Parse(ref log, ref error);

            _Scene = new Scene(_Camera);
            _Scene.AddRenderObject(_BackgroundScript);
            _Scene.AddRenderObject(_PreviewScript);
            _Scene.AddRenderObject(_LightingScript);
            BuildXML();
            _ImageRenderer = new ImageRenderer(image1, _XML, (int)image1.Width, (int)image1.Height, false);
            _ImageRenderer.Render();
            _ImageRenderer.SetPostProcess(new PostProcess());
            _ImageRenderer.TransferLatest(false);

        }