/// <summary> /// Clone all the time-dependent components, share the others. /// </summary> /// <returns></returns> public virtual object Clone() { AnimatedRayScene sc = new AnimatedRayScene(); ITimeDependent intersectable = Intersectable as ITimeDependent; sc.Intersectable = (intersectable == null) ? Intersectable : (IIntersectable)intersectable.Clone(); sc.BackgroundColor = (double[])BackgroundColor.Clone(); ITimeDependent camera = Camera as ITimeDependent; sc.Camera = (camera == null) ? Camera : (ICamera)camera.Clone(); ILightSource[] tmp = new ILightSource[Sources.Count]; Sources.CopyTo(tmp, 0); for (int i = 0; i < tmp.Length; i++) { ITimeDependent source = tmp[i] as ITimeDependent; if (source != null) { tmp[i] = (ILightSource)source.Clone(); } } sc.Sources = new LinkedList <ILightSource>(tmp); sc.Start = Start; sc.End = End; sc.setTime(Time); // propagates the current time to all time-dependent components.. return(sc); }
public void ShareCloneChildren(DefaultSceneNode n) { foreach (var child in children) { ITimeDependent cha = child as ITimeDependent; n.InsertChild((cha == null) ? child : (ISceneNode)cha.Clone(), child.ToParent); } }
/// <summary> /// Clone all the time-dependent components, share the others. /// </summary> /// <returns></returns> public virtual object Clone() { ITimeDependent datatd = data as ITimeDependent; Animation c = new Animation(param, (datatd == null) ? data : datatd.Clone()); c.Start = Start; c.End = End; c.Time = Time; c.Width = width; c.Height = height; c.bg = bg; c.fg = fg; c.setSlant(slant); return(c); }
/// <summary> /// Worker thread (picks up individual frames and renders them one by one). /// </summary> protected void RenderWorker() { // thread-specific data: ITimeDependent datatd = data as ITimeDependent; object myData = (datatd == null) ? data : datatd.Clone(); MT.InitThreadData(); IImageFunction imf = FormSupport.getImageFunction(textParam.Text, myData); imf.Width = width; imf.Height = height; ITimeDependent imftd = imf as ITimeDependent; IRenderer rend = FormSupport.getRenderer(textParam.Text, imf); rend.Width = width; rend.Height = height; rend.Adaptive = 0; // turn off adaptive bitmap synthesis completely (interactive preview not needed) rend.ProgressData = progress; // worker loop: while (true) { double myTime; int myFrameNumber; lock ( progress ) { if (!progress.Continue || time > end) { sem.Release(); // chance for the main animation thread to give up as well.. return; } // got a frame to compute: myTime = time; time += dt; myFrameNumber = frameNumber++; } // set up the new result record: Result r = new Result(); r.image = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); r.frameNumber = myFrameNumber; // set specific time to my image function: if (imftd != null) { imftd.Time = myTime; } // render the whole frame: rend.RenderRectangle(r.image, 0, 0, width, height); // ... and put the result into the output queue: lock ( queue ) { queue.Enqueue(r); } sem.Release(); // notify the main animation thread } }