This sample demonstrates how to use TModel3D to load 3D models in FireMonkey applications at run time.
You can find the SurfSpotFinderApp sample project at:
- Start | Programs | Embarcadero RAD Studio Rio | Samples and navigate to:
Object Pascal\Multi-Device Samples\User Interface\ModelViewer
- Subversion Repository:
- You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
This application creates a 3D model viewer that provides basic functionalities: load, rotation, zoom, change of the material that the 3D model uses.
Load a 3D model from a file (*.obj, *.dae, *.ase) and change or view the material that the 3D model uses. For material you can use solid colors, textures or light materials.
You can interact with the loaded 3D model using mouse movements for rotation, the mouse wheel and key arrows for zoom, and the arrows in the upper-left corner for plane change of position.
Some models may not be visible immediately after being loaded due to the scale or Material settings of the respective model. To view the model, just use the track bar to change the scale or click 'Edit Material' and select TColorMaterialSource and appropriate color.
Also, some models may have a high level of detail, so the loading operation may take longer; watch the status bar to see when the model has been loaded.
How to Use the Sample
- Navigate to the location given above and open Model3D.dproj.
- Press F9 or choose Run > Run.
The class for the form that is displayed when the user chooses Edit Material from the editor.
The class for the main form that represents the editor itself.
- TFrameMaterialDesigner is the form from which you can select the properties of the material. It contains a TLayer3D, a TLight, and a TCube on which you can see the selected properties.
- TModel3DTest is the main form of the application. It contains components such as TViewport3D, TModel3D, TLight, TCamera, TStyleBook, used to create the basic viewer and to display an animated preview of the 3D model at a smaller scale.
- The basic viewer and the animated preview are implemented using TViewport3D to view the 3D object, TModel3D to allow manipulation for the loaded model, TCamera to define the scene perspective, and TLight to imitate the rays of light.
- A TTrackBar component is used to implement the scale of the object.
- The load from file, clear, and edit material actions are performed when the buttons with the same name are pressed.
- Using a TLabel component, the application displays the loading status of the 3D object.
- A TListBox component contains the material source properties, which are displayed into a TGroupBox.
- The application uses different TFloatAnimation objects to animate the 3D models.
- FireMonkey 3D
- Tutorial: Creating a FireMonkey 3D Application
- Tutorial: Importing 3D Models (FireMonkey)