ATF Model Viewer Sample - kaisu1986/ATF GitHub Wiki
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.
- Use of Managed Extensibility Framework (MEF) to put applications together.
- Use of the application shell framework, including
CommandService,SettingsService, andControlHostService. - Use of components to handle files, such as
FileDialogService,RecentDocumentCommands, andStandardFileExitCommand. - 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
DesignControlcanvas to display a graphic model. - Render ATGI and Collada documents using OpenGL®.
To run the sample, double-click ModelViewer.exe in ATF\Samples\ModelViewer\bin\Release.
A dialog appears with an empty canvas. You can open a model file to view it in the canvas.
- 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.
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.
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.
You can toggle these rendering modes:
- Textured. Keyboard shortcut: T key.
- Lighting. Keyboard shortcut: L key.
- Backface. Keyboard shortcut: B key.
Modules perform these functions:
- Program.cs: Contains the
Main()function. It creates a MEFTypeCataloglisting the ATF and internal components used. - ModelDocument.cs: Defines the
ModelDocumentclass for a document of a model file. - ModelViewer.cs: Specifies the
ModelViewercomponent, which is the document client for aModelDocument. - RenderView.cs:
RenderViewcomponent that registers aDesignControlcontrol to display a 3D scene from a model document. - RenderCommands.cs:
RenderCommandscomponent provides user commands related to theRenderViewcomponent to change rendering mode. - RenderPrimitives.cs:
RenderPrimitivesclass DOM adapter that does the work of rendering the model, using OpenGL®. - RenderTransform.cs:
RenderTransformclass DOM adapter that applies the appropriate transform for rendering objects so they appear in the proper place in the model.
