FMX.AnimationDemo3D Sample

From RAD Studio Code Examples
Jump to: navigation, search

This sample illustrates how to create 3D animations using FireMonkey.

Location

You can find the AnimationDemo3D sample project at:

  • Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to:
    • CPP\Multi-Device Samples\User Interface\AnimationDemo3D
  • Subversion Repository:
    • You can find C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.

Description

The AnimationDemo3D sample animates several visual objects on a 3D form. To this end, the sample uses TPathAnimation and TFloatAnimation.

How to Use the Sample

  1. Navigate to the location given above, and open AnimationDemo3D.cbproj.
  2. Select the target platform.
  3. Press F9 or choose Run > Run.
  4. See the different animations.

Files

File in C++ Contains

AnimationDemo3D.cbproj

The project itself.

anidemofrm.fmx

The main form where the components are located.

AnimationDemo3DPCH.h, AnimationDemo3D.cpp

Used to define and implement the sample.

Classes

TfrmAniDemo is the main form that represents the main window of the sample. It is a 3D form that contains the following components:

Implementation

  • The sample uses:
    • TLayer3D to hold any 2D object in a FireMonkey 3D form.
    • TLayout to organize multiple graphical controls under the same parent.
    • TSphere to implement a 3D sphere shape that can be placed on a 3D FireMonkey form.
    • TRoundRect to define 2D rectangles with rounded corners.
    • TRoundCube to implement a 3D cube shape with rounded corners that can be placed on a 3D FireMonkey form
    • TCube to implement a 3D cube shape that can be placed on a 3D FireMonkey form.
    • TStrokeCube to implement a stroked 3D cube shape that can be placed on a 3D FireMonkey form.
    • TPlane to implement a 2D plane that can be placed on a 3D FireMonkey form
    • TText to define 2D text object.
    • TText3D to represent a 3D rendered text.
    • TTextLayer3D to implements a 3D layer that can be used to display 3D text on a 3D FireMonkey form.
    • TPath to define 2D path-type shapes representing groups of connected curves and lines.
    • TPathAnimation to move a visual object on a specified path.
    • TFloatAnimation attached to a 3D object in order to animate it.
    • TLightMaterialSource to link a TLightMaterial to a 3D object. The link is made through the MaterialSource property of the 3D object.
    • TLight to imitate the rays of light and their propagation on other 3D objects.

When you run the application, you see several animated 3D objects. The animations do the following:

  • FloatAnimation1 is attached to Sphere2. It has the PropertyName set to Opacity, which means that the animation customizes the transparency of the sphere. Moreover, the Loop property of the animation is set to True, which means that the animation is repeatedly executed.
  • FloatAnimation2 is attached to StrokeCube1. It has the folloing properties: AutoReverse, Interpolation and PropertyName set to True, Back and RotationAngle.Y, respectively. This configuration of the animation makes the cube rotate around the Y axis from the StopValue to the StartValue and then, from the StartValue to the StopValue.
  • FloatAnimation3 is attached to RoundCube1. It has the PropertyName property set to Position.Z, which means that the animation moves the cube through the Z axis. Moreover, the Interpolation property determines the path and the rate at which the StartValue of the animation is changed to the StopValue over time. As it is set to Elastic the animation follows a progressive sinusoidal geometric interpolation.
  • FloatAnimation4 is attached to Text3D1. As in FloatAnimation2, this animation has the AutoReverse and Interpolation properties set to True and Back respectively. Moreover the PropertyName property is set to RotationAngle.X. Therefore, this configuration of the animation makes the cube rotate around the X axis from the StopValue to the StartValue and then, from the StartValue to the StopValue.
  • FloatAnimation5 is attached to Sphere1. It has the PropertyName property set to Scale.X and the Trigger and TriggerInverse properties set to IsMouseOver=true and IsMouseOver=false, respectively. This means that the sphere scales throught the X axis when the mouse is on the sphere. The inverse of the animation starts when the mouse leaves the sphere.
  • PathAni is attached to RoundCube1. It makes the round cube follow the path determined by the Path1 object.

Uses

See Also

Samples