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.
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 section requires radius, length, and angle
Model Flag = S, Rod Radius, Section Length, Angle in Degrees
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 Section requires rod radius, bend radius, bend angle
Model Flag=B, Rod Radius, Bend Radius (To Centre) , Bend Angle in Degrees
A bend aligns itself to the angle of the previous section and applies the angle from that reference.
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.
If you are interested in looking at this component, using it or even extending it then download it here.
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.
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.
INNOVA Solutions Pty Ltd - ACN
081 449 836