/// <summary> /// Draws the node. /// </summary> /// <param name="time">Time snapshot</param> /// <param name="renderer">The renderer that draws the node.</param> internal void DoDraw(GameTime time, SceneRenderer renderer) { foreach (var comp in this.Components) { if (comp.Enabled) { comp.PreRender(time, renderer); } } foreach (var comp in this.Components) { if (comp.Enabled) { comp.Render(time, renderer); } } // Pass the draw call to all children. foreach (var child in this.Children) { child.DoDraw(time, renderer); } foreach (var comp in this.Components) { if (comp.Enabled) { comp.PostRender(time, renderer); } } }
internal void PostRender(GameTime time, SceneRenderer renderer) { if (!this.Enabled) { return; } this.OnPostRender(time, renderer); }
/// <summary> /// Renders the scene node. /// </summary> /// <param name="time">Time snapshot</param> /// <param name="renderer">The renderer that is used for drawing.</param> protected override void OnRender(GameTime time, SceneRenderer renderer) { if (this.Model == null) { return; } renderer.Draw(this.Model, this.Node.Transform.WorldTransform, this.Node.Material); }
/// <summary> /// Draws the sky. /// </summary> /// <param name="renderer"></param> /// <param name="camera"></param> public override void Draw(SceneRenderer renderer, Camera camera) { GL.ClearColor( this.Color.R, this.Color.G, this.Color.B, this.Color.A); GL.Clear(ClearBufferMask.ColorBufferBit); }
/// <summary> /// Draws the whole scene. /// </summary> /// <param name="camera">The camera setting for the scene.</param> /// <param name="renderer">The renderer that draws the the scene.</param> /// <param name="time">Time snapshot</param> public void Draw(Camera camera, SceneRenderer renderer, GameTime time) { if (camera == null) { throw new ArgumentNullException("camera"); } if (renderer == null) { throw new ArgumentNullException("renderer"); } renderer.Begin(); this.root.DoDraw(time, renderer); renderer.End(this, camera); }
/// <summary> /// Instantiates a new scene. /// </summary> /// <param name="flags">Specifies the behaviour of the world.</param> public Scene(SceneCreationFlags flags) { this.root = SceneNode.CreateRoot(this); this.defaultRenderer = new SimpleRenderer(); if (flags.HasFlag(SceneCreationFlags.EnablePhysics)) { this.CollisionConfiguration = new DefaultCollisionConfiguration(); this.Dispatcher = new CollisionDispatcher(this.CollisionConfiguration); this.Broadphase = new DbvtBroadphase(); this.Broadphase.OverlappingPairCache.SetInternalGhostPairCallback(new GhostPairCallback()); this.world = new DiscreteDynamicsWorld(this.Dispatcher, this.Broadphase, null, this.CollisionConfiguration); // Register physics handler Game.Current.UpdateNonScene += this.UpdatePhysics; } Game.Current.Disposing += this.Dispose; }
/// <summary> /// Draws the sky. /// </summary> /// <param name="renderer">The renderer that is drawing the sky.</param> /// <param name="camera">The camera that shows the sky.</param> public abstract void Draw(SceneRenderer renderer, Camera camera);
/// <summary> /// Postprocesses rendering of the scene node. /// </summary> /// <param name="time">Time snapshot</param> /// <param name="renderer">The renderer that is used for drawing.</param> protected virtual void OnPostRender(GameTime time, SceneRenderer renderer) { }
/// <summary> /// Renders the scene node. /// </summary> /// <param name="time">Time snapshot</param> /// <param name="renderer">The renderer that is used for drawing.</param> protected override void OnRender(GameTime time, SceneRenderer renderer) { renderer.Light(this.Node.Transform.WorldPosition, this); }
internal SceneNodeDrawEventArgs(GameTime time, SceneRenderer renderer) { this.time = time; this.renderer = renderer; }