Search code examples
delphigraphics3dfreepascalfpc

Simple Delphi 3d functions


Could anyone help me with examples of some bare-bone, old school 3d methods in Delphi? Not using openGL or firemonkey or any external library (vanilla canvas coding). What i want to do is to be able to rotate X number of points around a common origo. From what i remember from the old days, you subtract left from right (on the 3d points) so that origo is always 0,0 - then perform the calculations, and finally add the left/top pixel offset to get the actual screen positions.

What im looking for is a set of small, ad-hoc routines, ala:

  • RotateX(aValue:T3dpoint; degr:float):T3dPoint;
  • RotateY(--/--)
  • RotateZ(--/--)

Using these functions it should be fairly easy to create the old "rotating 3d cube" (8 points).

Also, are there functions for figuring out the visible "faces"? If i want a filled vector cube, then i guess i need to extract visible regions (based on distance/overlapping?) which in turn is drawn as X number of filled polygons? And these must no doubt be sorted by depth to not come out a mess.

for instance:

  • PointsToFaces(const a3dObject:T3dPointArray):TPolyFaceArray;
  • SortFaces(Const aFaces:TPolyFaceArray):TPolyFaceArray;

Any help is welcome!


Solution

  • Here are some nice good-old resource for Delphi Math from efg's Reference.
    You can find a list of graphic projects.
    2D/3D Lab Vector graphics: translation, rotation, scaling, view transform, homogeneous coordinates, clipping, projections, vectors, matrices etc...