This sample demonstrates how to animate a 3D object.
You can find the FirstApp3D sample project at:
- Start | Programs | Embarcadero RAD Studio Rio | Samples and then navigate to:
CPP\Multi-Device Samples\User Interface\FirstApp3D
- Subversion Repository:
The FirstApp3D sample demonstrates how to use the TFloatAnimation class to animate a 3D object. The sample attaches a TFloatAnimation to a TRectangle3D object. Moreover, this sample also demonstrates how to specify a 3D object as the target that is being watched by the TCamera.
How to Use the Sample
- Navigate to the location given above and open CppFMX3DFirstApp.cbproj.
- Select the target platform.
- Press F9 or choose Run > Run.
- Interact with the sample:
- Left-click on the 3D rectangle to rotate it.
- Left-click on the 3D rectangle to stop the rotation.
|File in C++||Contains|
The project itself.
The main form where the components are located.
Used to define and implement the sample.
TForm3D4 is the main form that represents the main window of the sample. It contains the following components:
- A TCamera object.
- Three TColorMaterialSource objects.
- A TCube object
- A TCylinder object.
- A TRectangle3D object that contains a TFloatAnimation object.
- A TSphere object.
- The sample uses TColorMaterialSource to change the color of 3D objects.
- The sample uses TCube to implement a 3D cube shape that can be placed on a 3D FireMonkey form.
- The sample uses TCylinder to implement a 3D cylinder shape that can be placed on a 3D FireMonkey form.
- The sample uses TRectangle3D to implement a 3D shape under the form of a 3D rectangle that can be placed on a 3D FireMonkey form.
- The sample uses TSphere to implement a 3D sphere shape that can be placed on a 3D FireMonkey form.
- The sample uses TCamera to define the scene perspective and projection of the objects in the scene to the viewport.
- The sample uses TFloatAnimation attached to a 3D object in order to animate it.
When you run the application, your FireMonkey form is focused on the 3D Rectangle. This is because the Target property of the TCamera is set to
Rectangle3D. Moreover, If you click on the 3D rectangle, a OnClick event occurs. The OnClick event enables the TFloatAnimation attached to it. The TFloatAnimation has the PropertyName and Loop properties set to
True, respectively. Therefore, when you click on the 3D rectangle, it begins to rotate until you make another click on it.
- FireMonkey 3D
- Tutorial: Creating a FireMonkey 3D Application
- Tutorial: How to Use Cameras in a FireMonkey 3D Application