This sample demonstrates how to use the TViewport3D class to view and interact with 3D objects.
You can find the Arrows3D sample project at:
- Start | Programs | Embarcadero RAD Studio Alexandria | Samples and then navigate to:
CPP\Multi-Device Samples\User Interface\Arrows3D
- 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 Arrows3D sample demonstrates how to use the TViewport3D class to view and interact with 3D objects. The TViewport3D class implements the interface for viewing 3D objects. This sample uses 3D controls such as TCamera or TLight and 3D objects such as TDummy, TCylinder or TCone.
How to Use the Sample
- Navigate to the location given above and open FMArrows3dCPP.cbproj.
- Select the target platform.
- Press F9 or choose Run > Run.
- Interact with the sample:
- Left-click on the form and hold it pressed while moving the mouse to rotate the arrows.
- Move the mouse wheel to zoom the scene perspective of the 3D arrows.
|File in C++||Contains|
The project itself.
The main form where the components are located.
Used to define and implement the sample.
TFormArrows3d is the main form that represents the main window of the sample. It contains the following components:
- Three TLightMaterialSource objects called: LightMaterialSourceX, LightMaterialSourceY and LightMaterialSourceZ.
- A TViewport3D object containing two TDummy objects.
- The first TDummy object contains:
- The second TDummy object contains:
- The sample uses TDummy to group 3D controls so that they can be moved and rotated together.
- The sample uses TCylinder to implement a 3D cylinder shape that can be placed on a 3D FireMonkey form.
- The sample uses TCone to implement a 3D cone 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 TLight to imitate the rays of light and their propagation on the 3D object.
- The sample uses TLightMaterialSource to link a TLightMaterial to 3D objects. The link is made through MaterialSource property of the 3D object.
- The sample uses TViewport3D to describe how a 3D object is seen.
When you run the application, you see three 3D arrows forming a cartesian coordinate system. Each arrow is composed of a TCylinder and a TCone. When you click the mouse, an OnMouseDown event occurs. The OnMouseDown event uses TPointF to define a position on your FireMonkey form. Then, if you move the mouse while holding press the left button of the mouse, an OnMouseMove event occurs. The OnMouseMove event uses the position denoted by TPointF to rotate the 3D arrows. Moreover, if you move the mouse wheel, an OnMouseWheel event occurs. The OnMouseWheel event uses the value of the
WheelDelta property to change the position property of TCamera in order to zoom the scene perspective of the 3D arrows.
- FireMonkey 3D
- Tutorial: Creating a FireMonkey 3D Application
- Tutorial: How to Use Cameras in a FireMonkey 3D Application