Announcement

Collapse
No announcement yet.

gbPoints - 3D Graphics Laboratory

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

  • Theo Gottwald
    replied
    Hallo Garry, in case you want see the advanced version of your programm for Inspiration, check my new video here:
    https://youtu.be/MIy9layc2KA

    Leave a comment:


  • Gary Beene
    replied
    Howdy, Chris!

    Yep, there's no doubt that OpenGL is a more powerful tool. But for a simple task such as Tim is pursuing, the learning curve of OpenGL is excessive and unnecessary. The simple 3D point plotting routine I gave him ought to be adequate for his needs.

    However, Tim,
    If you think you might want a more feature-laden solution, certainly you should consider Chris' suggestion.

    Leave a comment:


  • Chris Boss
    replied
    Gary,

    I would go with OpenGL. If you stick with OpenGL 1.0 or 2.0 it is a flat API and much easier to work with. Drawing STL files using OpenGL is pretty straightforward. I added STL file format support (both ascii and binary) to EZGUI 5.0 using OpenGL and the performance is amazing.

    Click image for larger version

Name:	EZ3Dview.png
Views:	85
Size:	154.1 KB
ID:	787459
    It can load and display a STL file with 2 million polygons (triangles) in just a couple of seconds on a typical mass market PC (no need for bleeding edge PC).

    Converting STL files triangle list to something you can draw using OpenGL is not that difficult. Search the forums for some OpenGL examples.
    Attached Files

    Leave a comment:


  • Tim Lakinir
    replied
    Thank you Gary, not bad

    Leave a comment:


  • Gary Beene
    replied
    Hey Tim!
    Here's a simple example of using ONLY points to create a 3D image. It does not use Z to color the points nor does it connect points with lines, but you should be able to add those.

    I just wanted to give a stand alone example of a 3D plot of points, which is rotatable. If the example had a hundred points it would look more impressive, but even with just 4 points it should show the kind of results you want without having to deal with triangles, which are required for STL objects.

    Code:
    'Compilable Example:
    #Compile Exe
    #Dim All
    #Include "Win32API.inc"
    
    Type PointX : X As Single : Y As Single : Z As Single : End Type
    
    %IDC_Graphic = 500 : %IDC_Timer = 501
    
    Global hDlg As Dword, P() As PointX
    
    Function PBMain()
       Dialog New Pixels, 0, "3D Objects",,,200,200, %WS_SysMenu Or %WS_ClipChildren, To hDlg
       Control Add Graphic, hDlg, %IDC_Graphic, "", 10,10,180,180
       Graphic Attach hDlg, %IDC_Graphic, ReDraw
       Graphic Color %Black, %rgb_Wheat
       Dialog Show Modal hDlg Call DlgProc
    End Function
    
    CallBack Function DlgProc() As Long
       Select Case Cb.Msg
          Case %WM_InitDialog
             LoadObject
             SetTimer(hDlg, %IDC_Timer, 40, %NULL)    'sends %WM_Timer to dialog callback
          Case %WM_Timer
             Graphic Clear : RotateXYZ : DrawObject : Graphic ReDraw
       End Select
    End Function
    
    Sub RotateXYZ
       Local i As Long, NewX As Single, NewY As Single, NewZ As Single, Angle As Single
       Angle = 0.05
       For i = 1 To UBound(P)
          NewY = P(i).Y * Cos(Angle) - P(i).Z * Sin(Angle)    'X rotation
          NewZ = P(i).Y * Sin(Angle) + P(i).Z * Cos(Angle)    'X rotation
          P(i).Y = NewY : P(i).Z = NewZ
          NewX = P(i).Z * Sin(Angle) + P(i).X * Cos(Angle)    'Y rotation
          NewZ = P(i).Z * Cos(Angle) - P(i).X * Sin(Angle)    'Y rotation
          P(i).X = NewX : P(i).Z = NewZ
          NewX = P(i).X * Cos(Angle) - P(i).Y * Sin(Angle)    'Z rotation
          NewY = P(i).X * Sin(Angle) + P(i).Y * Cos(Angle)    'Z rotation
          P(i).X = NewX : P(i).Y = NewY
       Next i
    End Sub
    
    Sub DrawObject()
       Local i As Long, x1,x2,y1,y2, OffsetY, OffsetX As Long
       OffsetX = 90 : OffsetY = 90
       For i = 1 To UBound(P)
          Graphic Ellipse (p(i).x-5+OffsetX,p(i).y-5+OffSetY)-(p(i).x+5+OffsetX,p(i).y+5+OffsetY),, %Red, %Red
       Next i
    End Sub
    
    Sub LoadObject
       ReDim P(4)
       P(1).x = -30 : P(1).y = -30  : P(1).z = -30
       P(2).x = 30  : P(2).y = -30  : P(2).z = -30
       P(3).x = 0   : P(3).y = -30  : P(3).z = 30
       P(4).x = 0   : P(4).y = 0    : P(4).z = 30
    End Sub
    
    'gbs_00560
    'Date: 03-10-2012

    Leave a comment:


  • Gary Beene
    replied
    Hi Tim!

    You're stretching my memory here! It's been some time since I worked with STL.

    The STL format is to define a set of points, then to define triangles, using 3 points each. Then draw the triangles in 3D.

    So from your list of 16 points you also have to define the actual triangles, each triangle being defined by 3 points.

    I'll try to make an example to see it it meets your goal.

    Leave a comment:


  • Gary Beene
    replied
    Hi Tim!

    Ok, let me take a try at it. I'm out most of the morning but will see what I can do after lunch.

    Leave a comment:


  • Tim Lakinir
    replied
    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 ?

    Leave a comment:


  • Gary Beene
    replied
    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.

    Leave a comment:


  • Tim Lakinir
    replied
    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 ?

    Leave a comment:


  • Gary Beene
    replied
    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.

    Leave a comment:


  • Tim Lakinir
    replied
    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

    Leave a comment:


  • Tim Lakinir
    replied
    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

    Leave a comment:


  • Gary Beene
    replied
    Sorry, Tim, I missed your post. Did you get it figured out?

    Leave a comment:


  • Tim Lakinir
    replied
    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?

    Leave a comment:


  • Gary Beene
    replied
    Hi Tim!

    ... change "USING" to "CALL"

    Leave a comment:


  • Tim Lakinir
    replied
    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

    Leave a comment:


  • Hans Rietveld
    replied
    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.

    Leave a comment:


  • Mike Doty
    replied
    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

    Leave a comment:


  • Hans Rietveld
    replied
    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.

    Leave a comment:

Working...
X