Custom Wireframe component
The source code of FireMonkey is very helpful in understanding how the library works, but we can also use it as a template to build our own custom components. Rendering a cube is not a lot of code but using a similar approach, we could create a custom wireframe component that is similar to TStrokeCube
. We can just implement the Render
method differently and paint arbitrary lines, the coordinates of which are stored internally within our component.
Create a new Delphi multi-device application and select 3D Application
as the application type. Save the main form unit as uFormWireframe
and the whole project as WireframeTest
. Rename the form as FormWireframe
. Save all.
Add a new unit to the project and save it as uWireframe
. Here we are going to implement a custom component called TWireframe
that, similarly to TStrokeCube
, inherits from the TControl3D
class and renders an arbitrary wireframe by drawing lines.
Drawing a wireframe is based on just two data structures. We...