Exemplo n.º 1
0
        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);

        }
Exemplo n.º 2
0
        public void Save(string filename, Camera camera, WootracerOptions wootracerOptions)
        {
            _WootracerOptions = wootracerOptions;
            using (StreamWriter sw = new StreamWriter(filename))
            {
                try
                {
                    _CameraFrom = camera._Position;
                    _CameraTo = camera._Target;
                    _FOV = camera._FOV;
                    _ApertureSize = camera._ApertureSize;
                    _Spherical = camera._Spherical;
                    _Stereographic = camera._Stereographic;

                    XmlSerializer xmls = new XmlSerializer(typeof(AppSettings));
                    xmls.Serialize(sw, this);
                    sw.Close();
                }
                catch (Exception /*e*/)
                {
                    // lets not get overexcited...
                }
            }
        }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
 public Scene(Camera camera)
 {
     _Camera = camera;
 }
Exemplo n.º 5
0
 private void InitialiseCamera()
 {
     _Camera = new Camera(_AppSettings._CameraFrom, _AppSettings._CameraTo, _AppSettings._FOV, _AppSettings._Spherical, _AppSettings._Stereographic);
     _WootracerOptions._FocusDistance = (_Camera._Target - _Camera._Position).Magnitude();
     _WootracerOptions._ApertureSize = _AppSettings._ApertureSize;
     _WootracerOptions._FieldOfView = _AppSettings._FOV;
     _WootracerOptions._Spherical = _AppSettings._Spherical;
     _WootracerOptions._Stereographic = _AppSettings._Stereographic;
 }
Exemplo n.º 6
0
        private string BuildXML(bool preview)
        {
            bool pt = _Scene._PathTracer;

            _Scene._PathTracer = false;

            string XML = @"
<VIEWPORT width=" + image1.Width + @" height=" + image1.Height + @"/>";

            Camera previewCamera = new Camera(_Camera._Position, _Camera._Target, _Camera._FOV, _Camera._Spherical, _Camera._Stereographic);
            previewCamera._AAEnabled = true;// false;
            previewCamera._DOFEnabled = false;

            XML += previewCamera.CreateElement().ToString();
            XML += _Scene.CreateElement(preview, false).ToString();

            _Scene._PathTracer = pt;

            _CameraDirty = false;

            return XML;
        }