FMX.ViewPort3DTLightTexture3D Sample

From RAD Studio Code Examples
Jump to: navigation, search

This sample shows you how to use different FireMonkey classes that interact with 3D objects.


You can find the ViewPort3DTLightTexture3D sample project at:

  • Start | Programs | Embarcadero RAD Studio Alexandria | Samples and then navigate to:
    • CPP\Multi-Device Samples\User Interface\ViewPort3DTLightTexture3D
  • 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 ViewPort3DTLightTexture3D sample demonstrates how to use the TViewport3D, TColorMaterialSource and TLightMaterialSource classes. The sample uses TColorMaterialSource to link a TColorMaterial to a 3D object and TLightMaterialSource to link a TLightMaterial to a 3D object. Moreover, the sample attaches two different TFloatAnimations to two 3D objects.


File in C++ Contains


The project itself.


The main form where the components are located.

MainForm.h, MainForm.cpp

Used to define and implement the sample.


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


When you run the application, you see two 3D objects: a sphere and a 3D rectangle. On the one hand, the sphere is linked to the TLightMaterialSource object with the Texture property set to a map of the Earth. Therefore, the sphere object looks like the Earth. On the other hand, the 3D rectangle is linked to the TColorMaterialSource with the Color property set to Blue. The link of TColorMaterialSource and TRectangle3D is made through the MaterialShaftSource property, which set the color for the shaft sides of the 3D rectangle.

Note: To set the color for the front and back sides of the 3D rectangle, use the MaterialSource and MaterialBackSource properties.

Moreover, each TFloatAnimation is attached to each 3D object. When you click on the TCheckBox, it enables both animations. The sphere is attached to the FloatAnimation1, which has the PropertyName set to RotationAngle.Y, while the 3D rectangle is attached to the FloatAnimation2, which has the PropertyName set to RotationAngle.Z. Finally, both animations have the Loop property set to True, so it repeats the animation until the TCheckBox is cleared.


See Also