Exercise with 3D rotation

Discussion in 'Share Your Creations' started by derez, Feb 20, 2009.

  1. derez

    derez Expert Licensed User

    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.

    Attached Files:

    Last edited: Feb 22, 2009
  2. Erel

    Erel Administrator Staff Member Licensed User

    Great work derez!

    The problem you get is from extra spaces in some of the numeric values.
    You can fix it by removing those spaces:
    st = StrReplace(FileRead(c3)," ",""'line 405
  3. derez

    derez Expert Licensed 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.
  4. derez

    derez Expert Licensed 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: Feb 22, 2009
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice