Exercise with 3D rotation

derez

Expert
Licensed User
Longtime User
Hi
I played with rotation of bodies and created this program just to understand how it works.
I started with drawing on the Forelayer of form1 but the Erase function doesn't look good (like a flash of white over the screen), so I draw on form2 and copy the image to part of form1.

There is an important trick for drawing the poligons - you have to arrange the points of all poligons in the same order (clockwise or counter-clockwise), so the check for visibility of the poligons will be successful.

In the program you can see the complete body or just its points. This helps in the definition of poligons and the order of points.

There are five bodies included and more can be created by moving some points and saving the points file, to be used as a new body.

The attachment include source and programs for Desktop and Device, the dodecahedron text file and some images. You need ImagelibEx library.

Have fun ! :)

A bug ? : When running from the IDE and selecting the Dodecahedron, trying to roll X or Z creates an error of format (??), this does not happen after compilation. I'll be glad if Erel looks it up, I had similar problems before.
The bug was fixed by Erel's advise.
Added version 4 which enables also rotation by mouse movement.
Version 5 includes control of the perspective effect.
 
Last edited by a moderator:

derez

Expert
Licensed User
Longtime User
Thanks Erel, it is fixed now :)

I added version 4 (to the first post) which enables rotation by movement of the mouse :
horizontal left to right - rotates around Y axis
vertical - rotates around X axis
45 degrees - rotates around Z axis.
 

derez

Expert
Licensed User
Longtime User
I found some unfinished changes in the device version 4 and corrected them in the attached V4 above.
Version 5 includes control of the perspective effect.
 
Last edited:
Top