i
i
i
i
i
i
i
i
468 19. Building Interactive Graphics Applications
To gain an appreciation for these three important aspects of building the ap-
plication, we will complete the following steps:
• analyze interactive applications;
• understand different programming models and recognize important func-
tional components in these models;
• define the interaction of the components;
• design solution frameworks for integrating the components; and
• demonstrate example implementations based on different sets of existing
APIs.
We will use the ball shooting program as our example and begin by refining the
detailed specifications. For clarity, we avoid graphics-specific complexities in
3D space and confine our example to 2D space. Obviously, our simple program
is neither sophisticated nor representative of real applications. However, with
slightly refined specifications, this example contains all the essential components
and behavioral characteristics of more complex real-world interactive systems.
We will continue to build complexity into our simple example, adding new
concepts until we arrive at a software architecture framework that is suitable for
building general interactive graphics applications. We will examine the validity of
our results and discuss how the lessons learned from this simple example can be
applied to other familiar real-world applications (e.g., PowerPoint, Maya, etc.).
19.1 The Ball Shooting Program
Our simple program has the following elements and behaviors.
• The balls (objects). The user can left-mouse-button-click and drag-out a
new ball (circle) anywhere on the screen (see Figure 19.1). Dragging-out a
ball includes:
–(A).Initial mouse-button-click position defines the center of the cir-
cle;
–(B).Mouse button downand moving the mouse is the dragging action;
–(C).Current mouse position while dragging allows us to define the
radius and the initial velocity. The radius R (in pixel units) is the dis-
tance to the center defined in (A). The vector from the current position
to the center is the initial velocity V (in units of pixel per second).