/// <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); } }