/// <summary> /// This function is used to parse a .poule file. /// </summary> private void ParsePoule(Scene scene, string filename) { string[] lines = File.ReadAllLines(filename); foreach (string str in lines) { if (_pointLightReg.Match(str).Success) { string[] array = str.Split(' '); scene.Lights.Add(new PointLight(Transformation.Translation( float.Parse(array[1], CultureInfo.InvariantCulture.NumberFormat), float.Parse(array[2], CultureInfo.InvariantCulture.NumberFormat), float.Parse(array[3], CultureInfo.InvariantCulture.NumberFormat)), SampledSpectrum.White())); } else if (_diskLightReg.Match(str).Success) { string[] array = str.Split(' '); scene.Lights.Add(new PointLight(Transformation.Translation( float.Parse(array[1], CultureInfo.InvariantCulture.NumberFormat), float.Parse(array[2], CultureInfo.InvariantCulture.NumberFormat), float.Parse(array[3], CultureInfo.InvariantCulture.NumberFormat)), SampledSpectrum.White())); } else if (_cameraReg.Match(str).Success) { string[] array = str.Split(' '); _camera = new SimpleCamera(_screen, Transformation.Compose( Transformation.Translation( Convert.ToInt32(array[1]), Convert.ToInt32(array[2]), Convert.ToInt32(array[3]) ), Transformation.RotateX(float.Parse(array[4], CultureInfo.InvariantCulture.NumberFormat)), Transformation.RotateY(float.Parse(array[5], CultureInfo.InvariantCulture.NumberFormat)), Transformation.RotateZ(float.Parse(array[6], CultureInfo.InvariantCulture.NumberFormat)) )); } else if (_objReg.Match(str).Success == true) { string[] array = str.Split(' '); try { string path = array[1].Replace(@"\\", @"\"); ParsingObj parser = new ParsingObj(path); parser.AddToScene(scene); } catch (Exception e) { FileName.Text = e.Message; } } } }
/// <summary> /// Create a light from a transformation /// </summary> /// <param name="objectToWorld">the light-to-world transformation</param> /// <param name="spectrum">the spectrum of the light</param> /// <param name="nsamples">the number of samples to take from the light</param> protected Light(Transformation objectToWorld = null, SampledSpectrum spectrum = null, uint nsamples = 1) { ObjectToWorld = objectToWorld ?? Transformation.Identity; Spectrum = spectrum ?? SampledSpectrum.White(); NSamples = Math.Max(1, nsamples); }
private void InitNewScene() { _scene = new Scene(); var screen = new raytracer.core.Screen(1024, 768); _film = new MyFilm(screen, NSamples); Camera camera = new SimpleCamera(screen, Transformation.Translation((float)PositionX.Value, (float)PositionY.Value, (float)PositionZ.Value) * Transformation.RotateX((float)(RotationX.Value % 360)) * Transformation.RotateY((float)(RotationY.Value % 360)) * Transformation.RotateZ((float)(RotationZ.Value % 360))); _renderer = new Renderer(_scene, new GridSampler(screen), camera, _film, new WhittedIntegrator()); _scene.Lights.Add(new PointLight(Transformation.Translation(100, 650, -500), SampledSpectrum.White() * 2000000)); _scene.Lights.Add(new PointLight(Transformation.Translation(0, 0, -1000), SampledSpectrum.Random() * 200000)); SimpleObjParser(_scene, _file); }