INNOVA Solutions



A Rod for FireMonkey


A Component to Show an Asymmetric 3D Rod in Firemonkey Applications


Early Days.

Introduction

I wanted to explore creating FireMonkey three dimensional objects in code. A rod with bends was the initial aim. The problem was simplified considerably by keeping the bends in the XY plain and once you have the object FireMonkey makes rotating it easy. This was a proof of concept only, there are still issues but I think the results are useful.

TThreeDRod Component

The TThreeDRod is a derivative of TCustomMesh. The mesh data is constructed of straight or bent sections of rod. The sections used are specified by a list of strings with each line representing a segment. By editing ConstructionText and following simple rules it is possible to build complex rods.

A Straight Segment

A straight section requires radius, length, and angle
Model Flag = S, Rod Radius, Section Length, Angle in Degrees
Example 'S,0.2,0.1,90.0'
To get a contiguous rod the angle and radius must match the final angle of the previous segment. Each segment commences from where the last one ends.

Straight sections that either start or finish a sequence will have that end filled in.

A Bend Segment

A Bend Section requires rod radius, bend radius, bend angle
Model Flag=B, Rod Radius, Bend Radius (To Centre) , Bend Angle in Degrees
Example 'B,0.2,0.5,-90.0'
A bend aligns itself to the angle of the previous section and applies the angle from that reference.

Outstanding Issues

The current code does slightly rotate the ends from the YZ plane. I assume it is because the MovePath method is too simplistic but I do not yet understand why. For my purposes it is acceptable but it becomes problematic as the rod radius and the offset increases.

DownLoad

If you are interested in looking at this component, using it or even extending it then download it here.

  1. TThreeDRodXE2.zip - Zip of Code XE2 Version
  2. TThreeDRodXE3.zip - Zip of Code XE3 Version

The files each include the package BPL and demo source code.

ThreeD components in Firemonkey changed considerably between XE2 and XE3 especially with the introduction of the TMaterialSource. This seems to be a positive development as a number of components can have their color controled from a single object but it does make for a complex logic when porting between versions. On some projects the TMaterialSources were created by Delphi but on this demo it broke down.

Other Delphi Stuff

Roger has been an active member of active member of the Australian Delphi Users Group and tries to make a useful contribution to the Delphi community in Australia.

The company accepts no liability for any alleged or actual damage arising from the use of any of these products or this information.



Home           Australian Delphi Users Group

INNOVA Solutions Pty Ltd - ACN 081 449 836