You can find the Planets sample project at:
- Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to:
CPP\Multi-Device Samples\User Interface\Planets
- Subversion Repository:
- You can find C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
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
- Navigate to the location given above and open PlanetsCPP.cbproj.
- Select the target platform.
- Press F9 or choose Run > Run.
- See the planets rotating.
|File in C++||Contains|
The project itself.
The main form where the components are located.
Used to define and implement the sample.
TForm3D1 is the main form that represents the main window of the sample. It contains the following components:
- A TCamera object.
- A TColorMaterialSource object.
- A TLight object.
- Two TSphere objects:
- Two TTextureMaterialSource objects labeled as TextureMaterialSource1 and TexturematerialSource2.
- The sample uses TColorMaterialSource to link a TColorMaterial to a 3D object. The link is made through the MaterialSource property of the 3D object.
- The sample uses TTextureMaterialSource to link a TTextureMaterial to a 3D object. The link is made through the MaterialSource property of the 3D object.
- The sample uses TCamera to define the scene perspective and projection of the objects in the scene to the viewport.
- The sample uses TLight to imitate the rays of light and their propagation on other 3D objects.
- The sample uses TSphere to implement a 3D sphere shape that can be placed on a 3D FireMonkey form.
- The sample uses TFloatAnimation attached to a 3D object in order to animate it.
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.
- FireMonkey 3D
- Tutorial: Creating a FireMonkey 3D Application
- Tutorial: How to Use Cameras in a FireMonkey 3D Application