FMX.Arrows3D Sample

From Appmethod Code Examples
Jump to: navigation, search

This sample demonstrates how to use the TViewport3D class to view and interact with 3D objects.

Location

You can find the Arrows3D sample project at:

Description

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

  1. Navigate to the location given above and open FMArrows3dCPP.cbproj.
  2. Select the target platform.
  3. Press F9 or choose Run > Run.
  4. 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.

Files

File in C++ Contains

FMArrows3dCPP.cbproj

The project itself.

FormArrows.fmx

The main form where the components are located.

FMArrows3dCPPPCH.h, FormArrows.cpp

Used to define and implement the sample.

Classes

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

Implementation

  • 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.

Uses

See Also

Samples

Personal tools