/// <summary> /// Draw this SceneGraphObject. /// </summary> /// <param name="ctx"> /// The <see cref="GraphicsContext"/> used for drawing. /// </param> public void Draw(GraphicsContext ctx) { CheckCurrentContext(ctx); using (SceneGraphContext ctxScene = new SceneGraphContext(this, _CurrentView)) { // Override model-view-projection matrices if a camera is defined if (_CurrentView != null) { LocalProjection = _CurrentView.ProjectionMatrix; LocalModel = _CurrentView.LocalModel.GetInverseMatrix(); } // Update base.Update(ctx, ctxScene); // Base implementation base.Draw(ctx, ctxScene); } }
/// <summary> /// Update this SceneGraphObject hierarchy. /// </summary> /// <param name="ctx"> /// The <see cref="GraphicsContext"/> used for drawing. /// </param> /// <param name="ctxScene"> /// The <see cref="SceneGraphContext"/> used for drawing. /// </param> /// <exception cref="ArgumentNullException"> /// Exception thrown if <paramref name="ctx"/> is null. /// </exception> /// <exception cref="ArgumentNullException"> /// Exception thrown if <paramref name="ctx"/> is not current on the calling thread. /// </exception> /// <exception cref="ArgumentNullException"> /// Exception thrown if <paramref name="ctxScene"/>. /// </exception> protected internal virtual void Update(GraphicsContext ctx, SceneGraphContext ctxScene) { CheckCurrentContext(ctx); if (ctxScene == null) { throw new ArgumentNullException("ctxScene"); } // Update this object UpdateThis(ctx, ctxScene); // Update all children foreach (SceneGraphObject sceneGraphObject in _Children) { sceneGraphObject.Update(ctx, ctxScene); } }
/// <summary> /// Draw this SceneGraphObject hierarchy. /// </summary> /// <param name="ctx"> /// The <see cref="GraphicsContext"/> used for drawing. /// </param> /// <param name="ctxScene"> /// The <see cref="SceneGraphContext"/> used for drawing. /// </param> protected internal override void Draw(GraphicsContext ctx, SceneGraphContext ctxScene) { if (ctxScene == null) { throw new ArgumentNullException("ctxScene"); } CheckCurrentContext(ctx); // Push and merge the graphics state ctxScene.GraphicsStateStack.Push(_ObjectState); try { // Draw all children foreach (SceneGraphObject sceneGraphObject in _Children) { sceneGraphObject.Draw(ctx, ctxScene); } } finally { ctxScene.GraphicsStateStack.Pop(); } }
/// <summary> /// Draw this SceneGraphObject instance. /// </summary> /// <param name="ctx"> /// The <see cref="GraphicsContext"/> used for drawing. /// </param> /// <param name="ctxScene"> /// The <see cref="SceneGraphContext"/> used for drawing. /// </param> protected virtual void DrawThis(GraphicsContext ctx, SceneGraphContext ctxScene) { }
/// <summary> /// Update this SceneGraphObject instance. /// </summary> /// <param name="ctx"> /// The <see cref="GraphicsContext"/> used for drawing. /// </param> /// <param name="ctxScene"> /// The <see cref="SceneGraphContext"/> used for drawing. /// </param> protected virtual void UpdateThis(GraphicsContext ctx, SceneGraphContext ctxScene) { }