سؤال

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!

هل كانت مفيدة؟

المحلول

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...

نصائح أخرى

I did write a simple 3D rendering 'engine' a few years ago, using only naïve linear algebra. Might not be the most efficient one, though. A few thousand of points is the limit if you want to be able to move reasonably smooth. Sample EXE. You can get the code if you like, but it might not be that pretty.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top