/// <summary> /// Clone all the time-dependent components, share the others. /// </summary> /// <returns></returns> public virtual object Clone() { AnimatedCamera c = new AnimatedCamera(lookAt, center0, MathHelper.RadiansToDegrees((float)hAngle)); c.Start = Start; c.End = End; c.Time = Time; return(c); }
/// <summary> /// Creates default ray-rendering scene. /// </summary> public RayScene() { // !!!{{ TODO: put your scene and camera setup code here Scenes.FiveBalls(this); AnimatedCamera cam = new AnimatedCamera(new Vector3d(0.0, 0.0, 1.0), new Vector3d(0.0, 0.0, -9.0), 60.0); //Scenes.Bezier( this ); //AnimatedCamera cam = new AnimatedCamera( new Vector3d( 0.7, -1.0, 3.0 ), // new Vector3d( 0.7, 0.5, -5.0 ), // 55.0 ); Camera = cam; cam.End = 5.0; // one complete turn takes 5.0 seconds End = 5.0; // !!!}} }
/// <summary> /// Creates default ray-rendering scene. /// </summary> public static IRayScene Init(IRayScene sc, string param) { // !!!{{ TODO: .. and use your time-dependent objects to construct the scene // This code is based on Scenes.TwoSpheres(): // CSG scene: CSGInnerNode root = new CSGInnerNode(SetOperation.Union); root.SetAttribute(PropertyName.REFLECTANCE_MODEL, new PhongModel()); root.SetAttribute(PropertyName.MATERIAL, new PhongMaterial(new double[] { 1.0, 0.8, 0.1 }, 0.1, 0.6, 0.4, 128)); sc.Intersectable = root; // Background color: sc.BackgroundColor = new double[] { 0.0, 0.05, 0.07 }; // Camera: AnimatedCamera cam = new AnimatedCamera(new Vector3d(0.7, -0.4, 0.0), new Vector3d(0.7, 0.8, -6.0), 50.0); cam.End = 20.0; // one complete turn takes 20.0 seconds AnimatedRayScene asc = sc as AnimatedRayScene; if (asc != null) { asc.End = 20.0; } sc.Camera = cam; //sc.Camera = new StaticCamera( new Vector3d( 0.7, 0.5, -5.0 ), // new Vector3d( 0.0, -0.18, 1.0 ), // 50.0 ); // Light sources: sc.Sources = new LinkedList <ILightSource>(); sc.Sources.Add(new AmbientLightSource(0.8)); sc.Sources.Add(new PointLightSource(new Vector3d(-5.0, 4.0, -3.0), 1.2)); // --- NODE DEFINITIONS ---------------------------------------------------- // Params dictionary: Dictionary <string, string> p = Util.ParseKeyValueList(param); // n = <index-of-refraction> double n = 1.6; Util.TryParse(p, "n", ref n); // Transparent sphere: Sphere s; s = new Sphere(); PhongMaterial pm = new PhongMaterial(new double[] { 0.0, 0.2, 0.1 }, 0.03, 0.03, 0.08, 128); pm.n = n; pm.Kt = 0.9; s.SetAttribute(PropertyName.MATERIAL, pm); root.InsertChild(s, Matrix4d.Identity); // Opaque sphere: s = new Sphere(); root.InsertChild(s, Matrix4d.Scale(1.2) * Matrix4d.CreateTranslation(1.5, 0.2, 2.4)); // Infinite plane with checker: Plane pl = new Plane(); pl.SetAttribute(PropertyName.COLOR, new double[] { 0.3, 0.0, 0.0 }); pl.SetAttribute(PropertyName.TEXTURE, new CheckerTexture(0.6, 0.6, new double[] { 1.0, 1.0, 1.0 })); root.InsertChild(pl, Matrix4d.RotateX(-MathHelper.PiOver2) * Matrix4d.CreateTranslation(0.0, -1.0, 0.0)); // !!!}} return(sc); }