Announcement

Collapse
No announcement yet.

gbPoints - 3D Graphics Laboratory

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • gbPoints - 3D Graphics Laboratory

    This thread is for discussion of the 3D image display source code I posted today. Here's the app it creates.



    I've posted two other, recent source code listings demonstrating the display of simple 3D images. This code provides more formats, more features, and is intended to be useful as a test bed for evaluating 3D source code of your own.

    The code is written to be as modular as possible, making it easier for you to modify the code or to replace it with code of your own. I'll be using it over the next few weeks to work with GDI, GDI+, OpenGl, DirectX and custom graphic libraries - all as a part of learning more about 3D graphics coding options.
    Last edited by Gary Beene; 30 Mar 2010, 03:30 PM.

  • #2
    Here's information about the supported file formats:

    Stereolithography Files
    There are both Ascii and Binary versions of the file - both are discussed here.

    TOV Files
    This is about the simplest 3D file format you can imagine. The first line is simply a header that I check (for the "gb3DModel" string) to ensure the file consists of TOV data. The second line is the number of points and triangles which make up the model.

    The point lines give the xyz coordinates of the points (floating point is allowed). The "p1" on the line can be any text string (no spaces). A simple "p" is sufficent, but I like numbering them as "p1, p2, ...". Extra embedded spaces are allowed.

    The triangle lines define which points comprise the triangles. Note that the order is important. A counter-clockwise assignment of points identifies the outside surface of the triangle. The "t1" on the line can be any text string (no spaces). A simple "t" is sufficent, but I like numbering them as "t1, t2, ...". Extra embedded spaces are allowed.

    TOV simply stands for Three-dimensional Object Viewer - terminology from an application I've used in the past.

    And here's a sample file (a cube).
    Code:
    gb3DModel - Cube
    8 12
    p1   -50  -50  -50
    p2   -50   50  -50
    p3    50   50  -50
    p4   50  -50  -50
    p5   -50  -50   50
    p6   -50   50   50
    p7    50   50   50
    p8    50  -50   50
    t1  1 4 3
    t2  1 3 2
    t3  5 1 2
    t4  5 2 6
    t5  8 5 6
    t6  8 6 7
    t7  4 8 7
    t8  4 7 3
    t9  3 7 6
    t10  3 6 2
    t11  4 1 5
    t12  4 5 8
    Last edited by Gary Beene; 30 Mar 2010, 05:32 PM.

    Comment


    • #3
      Thanks for sharing Gary,

      there is just one problem currently, as I am unable to download linked gbPoints.zip file.


      Thanks,
      Petr

      P.S. Regarding learning graphic platforms, I recommend to get headers for OpenGL/DirectX from José (part of his Windows API headers). They are most complete, and José maintains them perfectly.

      EDIT: File can be downloaded now.
      Well done! I like the overall design, very fresh look and easy to use.
      Last edited by Petr Schreiber jr; 31 Mar 2010, 11:57 AM.
      [email protected]

      Comment


      • #4
        Hi Pete,

        Glad to see you got the link working ...

        Yes - I'll be headed over to Jose's place for the headers. I just haven't gotten my fill of GDI yet. I figure I want to understand the GDI limits first, then I'll understand the benefits of OpenGl, DirectX, and GDI+ all the more.

        Comment


        • #5
          XP SP3 and Windows 7 (32-bit) report the zip is corrupted.
          http://www.garybeene.com/files/gbpoints.zip
          How long is an idea? Write it down.

          Comment


          • #6
            Downloaded gbtemplate.zip from two machines and they are also reported corrupted
            I'm using the built-in Windows zip on both machines.
            How long is an idea? Write it down.

            Comment


            • #7
              Downloaded minutes ago, unzipped and ran just fine.

              Win7-32 and Win7-64 using built in Windows unzip.


              (btw, nicely done GB)

              Comment


              • #8
                Originally posted by Mike Doty View Post
                XP SP3 and Windows 7 (32-bit) report the zip is corrupted.
                http://www.garybeene.com/files/gbpoints.zip
                Hello Gary.

                I have the same problem with unzipping the file.
                It is the same problem as I mention before with the update of gbSnippets.

                The zip is empty and reports an error.
                sigpic
                Regards,
                Hans Rietveld.

                Comment


                • #9
                  Okay, downloaded again.
                  Went to properties and unblocked.
                  Winzip and pkunzip also report corruption.



                  Solution:
                  Thank you Hans (see below!)

                  Download winrar (if you don't have it.)
                  Save file (it will have no extension.)
                  Rename file to .zip
                  Last edited by Mike Doty; 3 Oct 2010, 10:00 AM. Reason: Solution below
                  How long is an idea? Write it down.

                  Comment


                  • #10
                    I unzipped the file with WinRAR.

                    It seems to be a file without extension.
                    After renaming the extracted file to a *.zip file it was possible
                    to unzip the second one with unzip.

                    Nice project, thanks Gary.
                    sigpic
                    Regards,
                    Hans Rietveld.

                    Comment


                    • #11
                      Hi Gary

                      I downloaded this program but not able to compile it , Error 477 -- syntax error as below (using PB Win10)

                      Code:
                      Compiling "C:\Tmp\Graphic programs\gbpoints\gbpoints.bas"
                      Error 477 in C:\Tmp\Graphic programs\gbpoints\gbpoints.bas(421:025):  Syntax error
                        Line 421:    Array Sort POnly(1), Using CustomPointSort          'sort POnly

                      the error occurred at the ARRAY SORT line
                      Code:
                      SUB SortPointsByZDepth
                         LOCAL i AS LONG
                         FOR i = 1 TO UBOUND(P) : POnly(i) = P(i) : NEXT i
                         ARRAY SORT POnly(1), USING CustomPointSort          'sort POnly
                      END SUB

                      Comment


                      • #12
                        Hi Tim!

                        ... change "USING" to "CALL"

                        Comment


                        • #13
                          Thanks Gary, got it compiled it is fantastic -- award winner!

                          The question now is how to enter coordinates point x, y, z values into your gbpoints program to plot out the mesh or grid lines joining these points?

                          Comment


                          • #14
                            Sorry, Tim, I missed your post. Did you get it figured out?

                            Comment


                            • #15
                              No , not yet?


                              For example , I have the following ground points levels

                              Code:
                              Ground Level
                              
                              X =           0           10        20         30
                              
                              Dist Y  
                              30           192.51    193.71    193.21    193.47
                              20          193.04      193.14    192.92    193.01
                              10           192.61    192.56    192.63    192.67
                              0            192.56     192.68    192.67    192.57

                              When X = 0 ft , Y= 0 ft then Z = 192.56 ft
                              X= 10 ft , Y = 0 ft then Z= 192.68 ft
                              .....
                              ......
                              X= 0 ft , Y = 10 ft then Z= 192.61 ft

                              and so on

                              Comment


                              • #16
                                Gary, what I need is to draw straight lines joining these points and plot these on a 3D graphics.
                                These are just surveying points with random spot heights and not part of a curve

                                Comment


                                • #17
                                  Hi, Tim!

                                  I'm about to step away for a bit. Will look at it when I return.

                                  But, I'm guessing that you'll need to add add function that reads the data and puts it in the P() array. I'll check that out when I get back.

                                  Comment


                                  • #18
                                    Yes Gary, as your GBPoints program reads in stla files ( which is in a format I have never heard of ), how do you format this data file ?

                                    For example, here is part of the data file from bottle.stla

                                    Code:
                                     solid FLIRIS  
                                    facet normal  0.955654E-01 -0.966960E+00  0.236339E+00
                                     outer loop
                                      vertex  0.000000E+00  0.800000E+01  0.000000E+00
                                      vertex -0.675880E+01  0.442610E+01 -0.118893E+02
                                      vertex -0.335710E+01  0.442610E+01 -0.132648E+02
                                     endloop
                                    endfacet
                                    facet normal -0.350878E+00  0.349503E+00 -0.868753E+00
                                     outer loop
                                      vertex -0.675880E+01  0.442610E+01 -0.118893E+02
                                      vertex -0.634850E+01  0.666400E+01 -0.111547E+02
                                      vertex -0.315330E+01  0.666400E+01 -0.124452E+02
                                     endloop
                                    endfacet
                                    facet normal -0.351159E+00  0.350063E+00 -0.868414E+00
                                     outer loop
                                      vertex -0.315330E+01  0.666400E+01 -0.124451E+02
                                      vertex -0.335710E+01  0.442610E+01 -0.132648E+02
                                      vertex -0.675880E+01  0.442600E+01 -0.118893E+02
                                     endloop
                                    endfacet

                                    not sure what are facet normal , vertex ?

                                    Comment


                                    • #19
                                      Hi Tim!

                                      The STLA is a format used in the stereolithography world. A Google search will find lots of sources for the file format, such as these ...

                                      https://people.sc.fsu.edu/~jburkardt...stla/stla.html

                                      https://www.loc.gov/preservation/dig...dd000506.shtml

                                      There are two such formats ... stla (a for ascii) and stlb (b for binary) that you will run across.

                                      Comment


                                      • #20
                                        Thanks Gary

                                        I'm still not able to convert the following ground points coordinates to stla format

                                        Code:
                                            X        Y         Z
                                            0        0      192.56
                                            10       0      192.68
                                            20       0      192.67
                                            30       0      192.57
                                        
                                            0        10      192.61
                                            10       10      192.56
                                            20       10      192.63
                                            30       10      192.67 
                                        
                                            0        20      193.04
                                            10       20      193.14
                                            20       20      192.92
                                            30       20       193.01
                                        
                                            0        30      192.51
                                            10       30      193.71
                                            20       30      193.21
                                            30       30      193.47
                                        Can you please show me how to do this ?

                                        Comment

                                        Working...
                                        X