Export (0) Print
Expand All
Dazzling Graphics: Top Ten UI Development Breakthroughs In Windows Presentation Foundation
Distributed .NET: Learn The ABCs Of Programming Windows Communication Foundation
A First Look at InfoCard
Talking Windows: Exploring New Speech Recognition And Synthesis APIs In Windows Vista
Windows Workflow Foundation
Windows Workflow Foundation, Part 2
WinFX Workflow: Simplify Development With The Declarative Model Of Windows Workflow Foundation
XPS Documents: A First Look at APIs For Creating XML Paper Specification Documents
Expand Minimize

The Avalon Team Introduces 3-D Features

 

Kerry Hammil
Microsoft Avalon Team

July 2004

Applies to:
   Longhorn Community Technical Preview, WinHEC 2004 Build (Build 4074)

Summary: The WinHEC 2004 build of Avalon contains new features that enable you to easily add three-dimensional (3-D) content to your Avalon applications. This article introduces you to the 3-D functionality currently available and how it may evolve in the future. Finally, this article addresses the differences between Avalon and DirectX and discusses which technology may be best for your application. (4 printed pages)

Download the 3Dsample that accompanies this article.


Contents

What Is Avalon 3-D?
What 3-D Features Does Avalon Support?
When Should I Use Avalon 3-D and When Should I Use DirectX?
   Do I want my 3-D content to seamlessly coexist with other Avalon features?
   How much direct access to the graphics card do I require?
   How complex is the 3-D scene that I want to render?
   How can I use Avalon 3-D and DirectX together?
For More Information

What Is Avalon 3-D?

"Avalon," the code name for the presentation subsystem in Longhorn, contains a set of APIs that provide 3-D functionality to application developers. This portion of the Avalon API set is known as "Avalon 3-D." The goal of Avalon 3-D is to make it easy for Avalon developers to integrate 3-D content into their 2-D applications. The initial investment of time and expertise required to program 3-D is very high in today's world. Avalon 3-D's mission is to make 3-D functionality much more accessible to developers whose core competencies are not necessarily related to computer graphics.

There are many ways in which business, productivity, and entertainment applications can benefit from the availability of 3-D functionality. For example:

  • A commercial data visualization tool can create graphs that utilize three dimensions to clearly illustrate the relationships between several variables.
  • A Solitaire card game can add interesting visual effects, such as cards that appear to move through 3-D space as they are dealt from the deck.
  • The author of an Avalon control can create depth and visual richness by rendering some portions of that control in 3-D, using lighting and visual surface to produce more realistic output.

These scenarios epitomize the uses for which Avalon 3-D has been designed. It is focused on enabling 2-D applications to incorporate some elements three-dimensional design. As such, Avalon 3-D does not "replace" DirectX. Rather, Avalon 3-D complements DirectX by making 3-D functionality available to a broader set of developers.

What 3-D Features Does Avalon Support?

Like Avalon's 2-D features, Avalon 3-D is implemented on top of DirectX. Therefore, Avalon is able to expose a broad range of 3-D rendering features in its API. However, in order to preserve the API's ease of use, Avalon does not expose every DirectX feature.

Avalon 3-D features in the WinHEC 2004 build of Longhorn include:

  • Create a 3-D scene.
  • Incorporate your 3-D scene into an Avalon element tree by building a Viewport3D element that includes the scene and a Camera that specifies a vantage point onto the scene.
  • Add a light to your 3-D scene. Avalon 3-D supports ambient, directional, point, and spot lights.
  • Apply materials to your 3-D meshes. In the WinHEC 2004 build of Avalon 3-D, you can create a Material from a SolidColorBrush. In future builds of Avalon 3-D, you will be able to construct a Material out of any Avalon brush. You will be able to specify separate ambient, diffuse, and specular materials for each 3-D mesh.
  • Scale, rotate, or translate one or more 3-D meshes, or apply an arbitrary 4x4 transformation to them
  • Create a very rich, deep, and seamless integration between the 2-D and 3-D portions of Avalon.
  • Display your 3-D content on a multimonitor system without any extra work.

We are investigating other features for future builds of Avalon 3-D. Here are some directions we are thinking of taking Avalon's 3-D support:

  • Add interactivity to your Avalon 3-D app by making objects in your scene active to mouse input
  • Add interactive 2-D content to your 3-D scene. Any interactive Avalon object can be placed on a 3-D mesh, and your user will be able to continue interacting with the 2-D content.
  • Printing and Remote Desktop will work for Avalon 3-D content in the same way as they do for the rest of Avalon's functionality.
  • Build standard Avalon controls that use 3-D for their display functionality, and can be used interchangeably with 2-D controls. Similarly, you will be able to "style" 2-D controls with 3-D content.
  • Use Avalon's powerful animation framework to animate your 3-D objects. You can animate the position of your camera, and you can also animate the transforms and materials you've applied to 3-D meshes.

When Should I Use Avalon 3-D and When Should I Use DirectX?

Both Avalon 3-D and DirectX offer you the ability to render 3-D graphics, but each API has distinct strengths that will help you choose which one is most appropriate for your task.

Avalon3-D is a fully integrated component of the Avalon API set, so its programming model is consistent with the rest of Avalon. This is a great advantage if you want to add some 3-D content to your Avalon application. Avalon3-D is also a good choice if you want to mix 3-D and other media types, such as 2-D graphics, digital images, or video using a single, consistent set of APIs.

Finally, Avalon's 3-D API set makes 3-D programming more accessible to programmers who are not familiar with the complexities of graphics hardware. However, in order to provide this ease of use, Avalon3-D abstracts some details of the graphics hardware away from the programmer, which is a consideration if your application requires such low-level control.

In contrast, DirectX offers low-level access to the graphics hardware and maximum control over how the hardware behaves. DirectX allows you more complete control over how your 3-D scene is stored in memory, which is important for applications like CAD design tools that build highly optimized representations of a 3-D scene.

However, the DirectX API set does not interoperate at the surface level with Avalon, which means that you cannot render DirectX content into the same window as Avalon content. Also, writing an effective application in DirectX requires that you possess deep knowledge of 3-D graphics and of the features and functionality of the graphics hardware.

There are several questions you can ask yourself in order to help determine whether you would find DirectX or Avalon 3-D most appropriate for your application.

Do I want my 3-D content to seamlessly coexist with other Avalon features?

Tight integration of 3-D content with the rest of Avalon is a very important feature of the Avalon 3-D API set . With Avalon 3-D, you can add 3-D content to any Avalon application using an object model that is consistent with the rest of Avalon's APIs. The Viewport3D object is a container in which you place your 3-D content, and Viewport3D can be added directly to any Avalon element tree. That makes managing and laying out 2-D and 3-D elements in relation to one another very straightforward.

How much direct access to the graphics card do I require?

If you want direct access to the graphics hardware and to the full range of Graphics Processing Unit (GPU) features, DirectX will give you the functionality that you need. If you would prefer not to be involved with all the details of the graphics hardware, such as the differences between the various graphics cards on the market today, then Avalon 3-D provides a layer of abstraction between the graphics hardware and the API you call to render 3-D content.

How complex is the 3-D scene that I want to render?

You can build and manage 3-D scene descriptions in both Avalon 3-D and DirectX. However, DirectX will give you more direct control over how your scene is managed in memory. Avalon 3-D automatically does some of this management for you, which will save you time if you do not have special performance or memory management requirements that require you to do this work yourself.

For instance, you could easily write a card game in Avalon 3-D because that style of game does not require extremely complex 3-D scenes. However, if you wanted to write a first-person shooter with millions of polygons in each scene and stringent requirements for performance, you would likely choose DirectX instead.

How can I use Avalon 3-D and DirectX together?

Sometimes you will want to use both Avalon 3-D and DirectX in the same application because you want to utilize the strengths of both APIs. For instance, if you are writing a CAD tool, you may want to implement your main rendering engine using DirectX but you may also want to use Avalon's 2-D and 3-D capabilities to implement controls such as a material designer.

While Avalon 3-D and DirectX cannot draw to the same surface, Avalon does provide a mechanism by which you can host DirectX content as a subwindow inside an Avalon application.

Additionally, you will be able display Avalon content inside a natively Direct3D application, either by embedding the Avalon content in a subwindow or by rendering your Avalon content to a texture that is then applied to a 3-D object in Direct3D. This functionality will be available in a future build of Longhorn.

For More Information

  • For a sample of 3-D support in Avalon, you should refer to the sample code that accompanies this article. The sample is a very basic Avalon 3-D application that shows you how to create a Viewport3D object and add it to your Avalon application. It will also show you how to add 3-D models and lights to your 3-D scene.
  • If you have any questions about 3-D support in Avalon or other Avalon-related issues, don't hesitate to post them to the Avalon newsgroup.
  • Read the Avalon documentation in the Longhorn SDK.

 

About the author

Kerry Hammil is a Program Manager on the Avalon team working on Avalon's 2-D and 3-D graphics technologies.

Show:
© 2014 Microsoft