/// <summary> /// Manages a scene to be rendered and updated. /// </summary> /// <param name="camera">Camera of the scene</param> /// <param name="canvas">Canvas that this scene binds to.</param> /// <param name="objects">Objects to be rendered</param> public Scene(ICamera camera, ICanvas canvas, params SceneObject[] objects) { if (camera == null || canvas == null) { throw new ArgumentNullException(); } this.Canvas = canvas; { this.rootUI = new SceneRootUI(); } { var rootObject = new SceneRootObject(this); rootObject.Children.AddRange(objects); this.rootObject = rootObject; } { var rootViewPort = new SceneRootViewPort( AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Top, new Padding(0, 0, 0, 0), canvas.Size); rootViewPort.Children.Add(new ViewPort(camera, AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom, new Padding(0, 0, 0, 0), canvas.Size)); this.rootViewPort = rootViewPort; } //var cursor = UICursor.CreateDefault(); //cursor.Enabled = false; //this.rootCursor.Children.Add(cursor); //this.Cursor = cursor; }
/// <summary> /// Manages a scene to be rendered and updated. /// </summary> /// <param name="camera">Camera of the scene</param> /// <param name="canvas">Canvas that this scene binds to.</param> /// <param name="objects">Objects to be rendered</param> public Scene(ICamera camera, ICanvas canvas, params SceneObject[] objects) { if (camera == null || canvas == null) { throw new ArgumentNullException(); } { this.FirstCamera = camera; this.Canvas = canvas; this.canvasLastSize = canvas.Size; } { this.rootUI = new SceneRootUI(); } { var rootObject = new SceneRootObject(this); rootObject.Children.AddRange(objects); this.rootObject = rootObject; } //var cursor = UICursor.CreateDefault(); //cursor.Enabled = false; //this.rootCursor.Children.Add(cursor); //this.Cursor = cursor; }
private void Tick(object sender, System.Timers.ElapsedEventArgs e) { if (this.maxCycle <= 0 ||// endless this.currentCycle < this.maxCycle) // not reached last cycle yet { this.currentCycle++; SceneRootObject rootObj = this.rootObject; UpdateObject(rootObj, interval); } else { this.Stop(); } }
/// <summary> /// Manages a scene to be rendered and updated. /// </summary> /// <param name="camera">Camera of the scene</param> /// <param name="canvas">Canvas that this scene binds to.</param> /// <param name="objects">Objects to be rendered</param> public Scene(Camera camera, ICanvas canvas, params SceneObject[] objects) { if (camera == null) { throw new ArgumentNullException(); } if (canvas == null) { throw new ArgumentNullException(); } this.Camera = camera; this.Canvas = canvas; var rootObject = new SceneRootObject(this); rootObject.Children.AddRange(objects); this.rootObject = rootObject; this.Cursor = UICursor.CreateDefault(); this.cursorRoot.Children.Add(this.Cursor); }
/// <summary> /// /// </summary> /// <param name="renderMode"></param> /// <param name="clientRectangle"></param> /// <param name="mousePosition">mouse position in window coordinate system.</param> public void Render(RenderModes renderMode, Rectangle clientRectangle, Point mousePosition) { var arg = new RenderEventArgs(renderMode, clientRectangle, this.Camera); // render objects. { SceneRootObject rootObject = this.RootObject; this.RenderObject(rootObject, arg); } // render regular UI. this.UIRoot.Render(arg); // render cursor. UICursor cursor = this.Cursor; if (cursor.Enabled) { cursor.UpdatePosition(mousePosition); this.cursorRoot.Render(arg); } }