View
Submitted by Zachary Booth Simpson
on 12/5/2000

© 2000 - Zachary Booth Simpson. Copied with permission from http://www.mine-control.com/zack. If you find any of this work useful, please sign Zack's guest book: http://www.mine-control.com/cgi/gbook-zbs.cgi.

Intent

Render the visible Models given a P.O.V.

Problem

Renderers are often the most custom part of any game; they often define the game''s technology and determine the envelope of design. Thus, not surprisingly, extreme optimizations are common often at the expense of organization or maintainability.

Solution

The View reads the Model Database via a Spatial Index but does not modify either. Thus, typically:
  • Model is read-only by View.
  • Spatial Index is read-only by View.
  • View is invisible to Model and Spatial Index.
  • The communication between a Spatial Index and a View is often the determining factor in game performance and deserves great attention. Not uncommonly, the spatial index and the view are so intimately related that the index is considered View code. However, one may argue that a spatial index more properly belongs in the model domain due to its read-write status. (See Spatial Index – Implementation.)

    Most View implementations translate a model "state" into an "appearance". For example, a model instance "orc1" is de-referenced and is found to be type==ORC_TYPE and frame==10. The View then finds an artwork pointer via type and frame and draws.

    The translation from "state" to "appearance" often has exceptions which clot the render code. (See Render Delegation and Appearance Map.)

    There are frequently more than one View implementation per game. For example, there may be a custom rear-view mirror in a driving game, or an overhead-view mini-map in a strategy game. However, there is usually one View implementation which predominates.

    Structure

    None at this time.

    Examples

    None at this time.

    Issues and Risks

    None at this time.

    Related Patterns

    Views renders Models that it looked-up in the Model Database via a Spatial Index.

    Views often derive artwork pointers from a Type Database.

    Views may choose to defer customized drawing via Render Delegation.

    Views may translate a model''s state to its appearance via an Appearance Map.

    Discuss this article in the forums


    Date this article was posted to GameDev.net: 6/19/2001
    (Note that this date does not necessarily correspond to the date the article was written)

    See Also:
    Design Patterns

    © 1999-2011 Gamedev.net. All rights reserved. Terms of Use Privacy Policy
    Comments? Questions? Feedback? Click here!