Skip to content

ATF Model Viewer Sample

Gary edited this page Mar 17, 2015 · 3 revisions

Table of Contents

Description

ModelViewer shows how to use ATF classes to load ATGI and Collada models and to render them using OpenGL®.

For details on how this sample is programmed, see Model Viewer Programming Discussion.

ATF Features Demonstrated by ModelViewer

  • Use of Managed Extensibility Framework (MEF) to put applications together.
  • Use of the application shell framework, including CommandService, SettingsService, and ControlHostService.
  • Use of components to handle files, such as FileDialogService, RecentDocumentCommands, and StandardFileExitCommand.
  • Using resource resolvers to load model files.
  • Using a document and a client to handle documents of a certain type.
  • Using adaptation and DOM adapters to handle DOM nodes in a variety of ways.
  • Using a DesignControl canvas to display a graphic model.
  • Render ATGI and Collada documents using OpenGL®.

Run ModelViewer

To run the sample, double-click ModelViewer.exe in \bin\wws_atf\Release.

A dialog appears with an empty canvas. You can open a model file to view it in the canvas.

Menu Options

  • File
    • Open 3D Model...: Open a 3D model file.
    • Recent Files: Submenu with recent files you can open.
    • Exit: Exit ModelViewer.
  • Edit
    • Keyboard Shortcuts: Use the *Customize Keyboard Shortcuts* window to set up keyboard shortcuts.
    • Load or Save Settings: Use the *Load or Save Settings* window to save current ModelViewer application settings or load application settings from a file.
    • Preferences: Set application preferences, such as command icon size.
  • View
    • Fit: Fit the model object in the window. Keyboard shortcut: F key.
    • Smooth: View the model fully rendered.
    • Wireframe: View a wireframe of the model.
    • Outlined: View the model fully rendered with a wireframe.
    • Textured: Toggle viewing the model with textures. Keyboard shortcut: T key.
    • Lighting: Toggle viewing the model with shading. Keyboard shortcut: L key.
    • Backface: Toggle rendering backfaces in the model. Keyboard shortcut: B key.
    • CycleRenderModes: Cycle between the Smooth, Wireframe, and Outlined modes. Keyboard shortcut: space bar.
  • Window:
    • Tile Horizontal: Tile the windows horizontally; does nothing.
    • Tile Vertical: Tile the windows vertically; does nothing.
    • Tile Overlapping: Overlap the windows horizontally; does nothing.
    • List of checked menu items for windows; check to display the corresponding window.
    • Lock UI Layout: Lock the UI so that windows can't be moved.
  • Help
    • About: Display dialog with information about ModelViewer.

Tool bar

The tool buttons invoke functions also available from menu items:

  • Lock UI Layout
  • Smooth shading: Same as View > Smooth.
  • Wireframe rendering: Same as View > Wireframe.
  • Smooth shading with wireframe outline: Same as View > Outlined.
  • Textured rendering: Same as View > Textured.
  • Lighting: Same as View > Lighting.
  • Render backfaces: Same as View > Backface. This mode is only apparent in Wireframe mode.

How to Use ModelViewer

Open an ATGI (.atgi extension) or Collada (.dae) model file and it displays in the "3D View" window tab. Only one model displays at a time.

Click the tool buttons or menu items or use the keyboard shortcuts to change the manner of rendering.

You can choose only one of these renderings:

  • Smooth: View the model fully rendered.
  • Wireframe: View a wireframe of the model.
  • Outlined: View the model fully rendered with a wireframe.
Pressing the space bar cycles between these modes.

You can toggle these rendering modes:

  • Textured. Keyboard shortcut: T key.
  • Lighting. Keyboard shortcut: L key.
  • Backface. Keyboard shortcut: B key.
Rotating the mouse wheel zooms the object. Selecting View > Fit or pressing "F" changes the zoom back to fit the model in the window.

ModelViewer Modules

Modules perform these functions:

  • Program.cs: Contains the Main() function. It creates a MEF TypeCatalog listing the ATF and internal components used.
  • ModelDocument.cs: Defines the ModelDocument class for a document of a model file.
  • ModelViewer.cs: Specifies the ModelViewer component, which is the document client for a ModelDocument.
  • RenderView.cs: RenderView component that registers a DesignControl control to display a 3D scene from a model document.
  • RenderCommands.cs: RenderCommands component provides user commands related to the RenderView component to change rendering mode.
  • RenderPrimitives.cs: RenderPrimitives class DOM adapter that does the work of rendering the model, using OpenGL®.
  • RenderTransform.cs: RenderTransform class DOM adapter that applies the appropriate transform for rendering objects so they appear in the proper place in the model.

Topics in this section

Clone this wiki locally