Importing a 3D Model in a FireMonkey Application

From RAD Studio
Jump to: navigation, search

Go Up to Tutorial: Importing 3D Models (FireMonkey)


This tutorial shows, step by step, how to import a 3D model.

Create a FireMonkey HD or 3D Application and Add Components

  1. Select File > New > Other > Multi-Device Application - Delphi:
    DesktopFMX.png
  2. Select either HD Multi-Device Application or 3D Multi-Device Application in the Multi-Device Application wizard.
    This tutorial uses an HD multi-device application, but you can also import a 3D model using a 3D Multi-Device Application.
    FMXHDApp.png

  3. Add a TViewport3D component to your form.
    If you are using a 3D Multi-Device Application, skip this step; your 3D form already contains a TViewport3D component.
  4. Add a TLight as a child of the TViewport3D component. Add TLight as follows:
  5. Add a TModel3D as follows:
    Types of applications for 3D importers.png

Import a 3D Model Using the Mesh Collection Editor

  1. Select the added TModel3D in the Structure View.
  2. In the Object Inspector, open the Mesh Collection Editor by clicking the ellipsis [...] in the MeshCollection field on the Properties page:
    MeshColection in Properties.png

  3. Load a 3D format file by pressing the Load button on the Mesh Collection Editor and navigating to a 3D file (.ase, .dae, .obj).
    This tutorial uses the FireMonkey.dae model, which is available in your product installation inside the Samples\Object Pascal\Multi-Device Samples\User Interface\ModelViewer\FireMonkey directory. See Samples Descriptions for more information.
    MeshColection Editor2.png

  4. After the model is loaded and displayed in the Mesh Collection Editor, you can:
    • Scale the model using the trackbar on the right side of the Mesh Collection Editor.
    • Rotate the model by clicking the model and dragging it in the opposite direction of the desired rotation.
  5. When the model is in position and is correctly scaled, click OK on the Mesh Collection Editor to display the model on the form:
    3d model in form at design time.png

  6. Run the project:
    3d model in form at run time .png

Next

See Also