June 95 - QuickDraw 3D: A New Dimension for Macintosh Graphics
QuickDraw 3D: A New Dimension for Macintosh Graphics
Pablo Fernicola and Nick Thompson
QuickDraw 3D is a new technology that helps developers bring 3D capabilities to their
applications. It runs on all Power Macintosh computers and offers high-performance
3D rendering and other features that make working with 3D data easier. This article
gives the basics you'll need to use QuickDraw 3D in your application, whether you're a
consummate 3D developer, a classic 2D application developer, or a game developer.
QuickDraw 3D is the newest enhancement to the Macintosh graphics architecture.
Developers have been requesting a 3D library, supported at the system level, since the
Macintosh was introduced. Although a number of Macintosh developers have produced
some amazing 3D applications, 3D graphics capabilities were relegated to niche
applications due to the lack of support at the core operating system level. QuickDraw
3D, which is expected to ship in mid-1995, brings the ability to deal with 3D
graphics to all Power Macintosh applications: not only can traditional 3D applications
take advantage of it, but it provides base functionality for general-purpose
applications as well.
QuickDraw 3D is a Code Fragment Manager-based shared library, with a C-based API.
Here we'll cover some concepts you need to know to get basic QuickDraw 3D support
into your application. This issue's CD contains a prerelease version of the QuickDraw
3D shared library, the 3D Viewer shared library, programming interfaces,
preliminary Inside Macintosh: QuickDraw 3D documentation, sample code, utility
libraries, and other goodies. Two of the sample programs are discussed in this article.
The API described in the article is based on a beta version of QuickDraw
3D; although nearly final, the API may change before the final release of the
software.
In addition, we'll talk about reading and writing data in QuickDraw 3D metafile format,
which is a way of representing 3D data in a consistent, transferable manner. But first
we'll set the stage with some background information.
QUICKDRAW 3D -- SO, WHAT'S THE BIG DEAL?
As we'll explain further in this article, QuickDraw 3D provides developers with a
number of benefits:
• a rich set of high-level geometries
• built-in renderers that cover the base functionality needed by developers
• immediate and retained graphics
• a common 3D file format
• human interface guidelines and widgets
• a 3D pointing-device manager that provides support for input devices
with more than two degrees of freedom
• pointing and picking support that enables user selection of 3D data
• transparent access to graphics accelerators
• an extensible, plug-in shading and rendering architecture
• implementation advantages over other 3D libraries
We've made dealing with 3D data in applications easier with QuickDraw 3D. By
creating a standard for data interchange, with a well-rounded metafile definition,
we're enabling applications to read and write 3D data in a consistent format. The
metafile specification addresses requests from both end users (who couldn't exchange
data between applications in a common format) and developers (who had to write
special-case code to deal with several different file formats).
QuickDraw 3D comes with a set of human interface guidelines to foster the adoption of
a consistent look and feel between applications (see "The QuickDraw 3D Human
Interface"). 3D applications today are geared toward the trained 3D expert; what you
learn in one application is generally not transferable to another application. By
following the QuickDraw 3D human interface guidelines, however, developers can help
make 3D graphics an integral part of the user experience within their applications.
______________________________
THE QUICKDRAW 3D HUMAN INTERFACE
BY DAN VENOLIA
QuickDraw 3D provides human interface guidelines (in version 1.0) and a
toolkit for implementing the guidelines (to come in the second major release).
A sample application on this issue's CD illustrates our current ideas for a 3D
human interface. By getting a preview of our plans, you can start taking your
applications along the common path.
Our main goal is to provide integration into the Macintosh experience. We feel
that 3D graphics will be the next popular multimedia data type -- in the way
that 2D graphics, sound, and movies have been in the past -- and users will
want to incorporate 3D data into their documents in the same way that they can
now incorporate other multimedia data types. To do this they'll need an
interaction model built on the 2D principles that they're familiar with.
Our guidelines offer suggestions and examples of how things can be done. If
your applications are targeted for a very specific audience, and you know that
audience well, you may decide to communicate with them in a different way,
and that's perfectly OK.
One of our guidelines, about direct manipulation through the use of a widget, is
illustrated in Figure 1. Here we've appropriated the 2D grab handles that are
popular in many "draw" programs and extended them to 3D. A widget is a set of
handles for control of spatial parameters. Some widgets, such as the scale tool
shown in Figure 1, indicate selection of a shape, while others make an
invisible object, such as a light or a camera, visible.
Figure 1. A scaling widget
Figure 2 shows what a full-featured 3D application might look like. The
emphasis here is on what's the same as in 2D applications rather than on
what's unique. The illustration shows a shape selected with a rotation widget, a
material selection palette, a room metaphor, and a document containing
multiple views of a scene.
Figure 2. Conceptual sketch of a 3D application>
______________________________
QuickDraw 3D technology has been made possible in part by the dramatic performance
improvements in the Power Macintosh line of computers. The performance of
QuickDraw 3D is scalable across the Power Macintosh line; we've put in a lot of effort
to ensure that the performance on even entry-level computers is excellent. With
hardware acceleration, these computers can easily compete (and win) against
mid-range workstations costing a lot more money.
HOW QUICKDRAW 3D COMPARES WITH OTHER LIBRARIES
QuickDraw 3D offers many advantages over other 3D libraries. When using other
graphics libraries, you're on your own if, for instance, you want to change the way a
scene is rendered (say, by doing ray tracing or applying procedural shading): you have
to reimplement all of the 3D architecture. With QuickDraw 3D, you only have to write
code to deal with the specific area that you want to change. And, even better, the code
you write can be used as a plug-in by other applications.
Unlike some libraries, QuickDraw 3D will be able to take advantage of a number of 3D
hardware acceleration solutions, since acceleration was one of its design criteria.
Another important criterion was cross-platform support. For example, a renderer
could be written to take advantage of low-level 3D libraries, such as the Silicon
Graphics OpenGL graphics library.
WHAT YOU CAN DO WITH QUICKDRAW 3D
The 3D application development process can be broken down into four areas: creation
of 3D data into a set of data structures, manipulation of that data in the human
interface of the application, presentation of the data by displaying it, and
transportation of the data (saving to and reading from files). QuickDraw 3D provides
support in each of these areas. You can implement one or more of them in your
application:
• QuickDraw 3D geometries -- If you're planning to write an application
to deal with the creation of models, QuickDraw 3D lets you define the
representation of the objects to be modeled in 3D form.
• QuickDraw 3D human interface -- Maybe you want to allow users to
visualize 3D data and models in a standalone application or as part of an
existing application. QuickDraw 3D's human interface guidelines and built-in
widgets provide a consistent way of manipulating 3D objects.
• QuickDraw 3D rendering and shading -- Rendering turns the 3D
geometries into pixels; shading determines what color those pixels should be.
Realism can be added by applying textures to objects: texture mapping takes a
texture (usually from a picture source, such as a picture of a brick wall) and
wraps it around an object. For example, Figure 3 shows a dinosaur mesh
rendered with a skin texture picture as a texture map. In its second major
release, QuickDraw 3D will enable you to write plug-in renderers and
shaders and license them to other developers.
Figure 3. Dinosaur mesh mapped with a skin-like texture
The dinosaur model was supplied in QuickDraw 3D metafile format
courtesy of Viewpoint DataLabs Intl.
• QuickDraw 3D metafile format -- If you want to provide 3D clip art in
the form of models, you'll really be pleased with QuickDraw 3D's metafile
format. One of the common problems encountered by users when working with
several 3D applications is that of data interchange, where one application's
file is not readable by another due to the multitude of 3D data formats.
QuickDraw 3D addresses this problem by providing a standard for the
interchange of 3D data. This device- and platform-independent representation
of 3D data is extensible, so your custom data gets preserved. And all of the
elements for a scene can be stored in the metafile, including lighting, camera
objects, texture maps, and shaders.
ROAD MAP FOR ADOPTION
Based on our experience working with developers, we've created a road map for
adoption of QuickDraw 3D. Here we'll look at how different application developers
might begin to adopt QuickDraw 3D, in order from the least to the greatest amount of
support. These categories provide you with a general strategy for bringing QuickDraw
3D into your applications.
• Developers of general-purpose 2D applications should add support for
the metafile format, enabling users to read and save 3D data within an
application. This can be achieved by using the 3D Viewer, which allows 3D
objects derived from metafile data to be viewed and manipulated by the user.
• Developers who use other 3D libraries and may not be ready to move to
QuickDraw 3D just yet should at least add support for the metafile format and
additionally consider adopting the QuickDraw 3D human interface guidelines.
Obviously, support for the metafile format requires writing a parser to
convert metafile data to another internal representation (Apple will be
supplying parser code). Implementing the human interface guidelines will
make the application be compatible with and look consistent with other 3D
applications available on the Macintosh. Note that an application that uses a 3D
library other than QuickDraw 3D will have a harder time using the 3D
Viewer.
• Developers of existing 3D applications who want to take the first step
toward creating a QuickDraw 3D-savvy application should take advantage of
QuickDraw 3D's rendering capabilities through the use of immediate-mode