User:Alexandrab/Creating a FireMonkey 3D application and adding animation to a 3D object without writing any code

From RAD Studio
Jump to: navigation, search

Go Up to Tutorial: Creating a FireMonkey 3D Application

This tutorial demonstrates how to create a FireMonkey 3D application and how to add an animation to a 3D object without writing any code.

Creating a FireMonkey 3D Application

  1. Select File > New > FireMonkey Desktop Application - Delphi > From the FireMonkey Desktop Application wizard, choose 3D FireMonkey Application and press the OK button.
  2. The FireMonkey Form Designer appears, displaying a FMX.Forms.TForm3D.

Adding Components

From the Tool Palette, add the following FireMonkey 3D components (by entering the component name in the Search field):

3D Cube.jpg

Adjusting Components

  1. In the FireMonkey Form Designer, adjust the position and size of the FireMonkey 3D component to suit your needs:
    • To move an object, simply drag and drop.
    • To rotate a 3D component, use the three blue handles that appear when you click the component. Each handle rotates the component in the associated plane in space (that is, the x, y, or z vertex). When you click a handle, it becomes red to indicate that it is the active handle. Note: You can also use the RotationAngle properties in the Object Inspector (x, y, and z).
    • To resize a component, use the resizer control, which is a small blue cube located on one corner of the component. The resizer works in one dimension at a time; the resizer is red on the side of the cube that is the selected (active) dimension. Note: You can also use the properties in the Object Inspector (for TCube, the size-related properties are Depth, Width, and Height).
  2. To change the material of the cube:
    • To specify the color and texture of the material, use the TLightMaterialSource properties.
      • In the Object Inspector, with the TLightMaterialSource in focus:
      • Adjust the Texture property by clicking ellipsis […] >Edit. The Bitmap Editor wizard opens. Click the Load button on the Bitmap Editor to load the wanted texture. After loading the texture, click the OK button on the Bitmap Editor.
      • Ambient, Diffuse, Emissive, and Specular can be set like in the following image.
        TLightMaterial.jpg
  3. To add animation effects to the cube:
  4. Click F9 to compile, build, and run the application.
1 2 3 4
Run1.jpg Run2.jpg Run3.jpg Run4.jpg

See Also