FMX.Planets Sample

From RAD Studio Code Examples
Jump to: navigation, search

This sample demonstrates how to use some of the different FireMonkey classes that interact with 3D objects. For example: TCamera, TTextureMaterialSource or TFloatAnimation.

Location

You can find the Planets sample project at:

Description

The Planets sample uses different FireMonkey classes in order to demonstrate how to interact with 3D objects. The sample uses TSphere as the 3D objects. TCamera and TLight are used to define the scene perspective and the propagation of the rays of light on the 3D objects. Moreover, TColorMaterialSource and TTextureMaterialSource are used to define the color and the texture of the 3D objects. Finally, TFloatAnimation is used to attach animations to the 3D objects.

How to Use the Sample

  1. Navigate to the location given above and open PlanetsCPP.cbproj.
  2. Select the target platform.
  3. Press F9 or choose Run > Run.
  4. See the planets rotating.

Files

File in C++ Contains

PlanetsCPP.cbproj

The project itself.

Unit1.fmx

The main form where the components are located.

PlanetsCPPPCH.h, Unit1.cpp

Used to define and implement the sample.

Classes

TForm3D1 is the main form that represents the main window of the sample. It contains the following components:

Implementation

When you run the application, you see two spheres. Each sphere is linked to each TTextureMaterialSource object. The Texture property of both TTextureMaterialSource objects is set to a map of a planet. Therefore, both sphere objects looks like planets. Moreover, the Position property of both the TCamera and the TLight objects is set so that you have a frontal view of the planets when you run the application. Finally, both animations have the PropertyName set to RotationAngle.Y and the Enabled and Loop properties set to True. Therefore, when you run the application the spheres rotate until you close the application.

Uses

See Also

Samples