Experimental forum for "Technology" discussions (computers, cameras, etc).

Re: Simple (and Primitive) 3D Rendering Program

Postby Bob Kuczewski » Fri Oct 21, 2022 3:30 am

I've added the new frame_designer program to our designer page at:

      https://ushawks.org/designer/frame_designer.htm

I've also updated the original glider_designer program at:

      https://ushawks.org/designer/glider_designer.htm

The older version is still available at:

      https://ushawks.org/designer/1.0/index.htm

I'll discuss the features in subsequent posts.
Join a National Hang Gliding Organization: US Hawks at ushawks.org
View my rating at: US Hang Gliding Rating System
Every human at every point in history has an opportunity to choose courage over cowardice. Look around and you will find that opportunity in your own time.
Bob Kuczewski
User avatar
Contributor
Contributor
 
Posts: 8374
Joined: Fri Aug 13, 2010 2:40 pm
Location: San Diego, CA

Re: Simple (and Primitive) 3D Rendering Program

Postby Bob Kuczewski » Fri Oct 21, 2022 3:37 am

Before getting into details, I'd like to mention the file types and formats available.

At this point, there are basically 3 file types supported by these programs:


The first one (Glider Designer Format) is a highly structured file that describes a "typical" hang glider using a number of named fields. There are currently 2 versions (1.0 and 1.1). Here's an example:

Code: Select all
{
  'Version': 1.1,
  'KeelFrontPoint': [0,5,0],
  'KeelRearPoint': [0,-5,0],
  'WingTipPoint': [15,-3,0.2],
  'TrailingEdgePercentKeel': 80,
  'RearWirePercentKeel': 82,
  'ControlBar': {
    'Height': 3.5,
    'Width': 3.2,
    'ApexPercentKeel': 40,
    'RakeDistance': 1.0,
    },
  'CrossBar': {
    'PercentKeel': 33,
    'PercentLeadingEdge': 60,
    'HeightAboveKeel': 0.1,
    },
  'KingPost': {
    'PercentKeel': 40,
    'Height': 3,
    'RakeDistance': 0.1,
    },
  'Battens': {
    'BattenDefData': [
      0.0, 20.0, 50.0, 165.0, 125.0, 20.0, 275.0, 150.0, 685.0, 160.0, 100.0,
      20.0, 225.0, 305.0, 240.0, 295.0, 260.0, 300.0, 350.0, 315.0
    ],
    'NumPerSide': 2,
    'BattenList': [
      {
        'PercentLeadingEdge': 0,
        'Segments': 20,
        'LeadingEdge': [50.0,165.0],
        'LeadingEdgeControl': [125.0,20.0],
        'TrailingEdgeControl': [275.0,150.0],
        'TrailingEdge': [685.0,160.0]
      },
      {
        'PercentLeadingEdge': 100,
        'Segments': 20,
        'LeadingEdge': [225.0,305.0],
        'LeadingEdgeControl': [240.0,295.0],
        'TrailingEdgeControl': [260.0,300.0],
        'TrailingEdge': [350.0,315.0]
      }
    ]
  }
}


Those fields match up pretty well with the fields in the user interface shown here:

Glider_Designer_Fields.png
Glider_Designer_Fields.png (87.91 KiB) Viewed 2173 times


So the user can change the fields, and then click the "Update JSON from Model" button to convert all of those settings into the Glider Data text window so it can be copied and stored on your own computer. The file can then be copied and pasted back into the Glider Data text window and reloaded with the "Update Model from JSON" button. That gives everyone the ability to make and keep their own models.

There are now two new buttons in that row:

The first new button is the "Lines" button, and it will save every line segement from the model into the Glider Data text window using the Line Segment Format. Line Segment Format just lists two endpoints for a line along with the line thickness and color. It is the simple format used by the new Frame Designer program.

The second new button is the "Obj" button, and it will convert the model into Wavefront's ".obj" format. Unlike the other two formats, the ".obj" format is an industry standard for three dimensional graphics. You can read up on that format on Wikipedia. The nice thing about that format is that it can be imported into other 3D programs like Blender.

Note that the program will allow you to convert the model data into these two new formats, but it won't let you convert it back. That's because the specific information about the glider's design is NOT preserved in these two newly supported formats. These new formats just describe points and lines and don't have any representation for keels or downtubes.

The second file format is what I call "Line Segment Format" and it is the input to the new (and primitive) frame_designer program. The Line Segment Format is also JSON, but it's simply a series of lists (one per line to be drawn) inside of one large list. In JSON, a list of items is enclosed in a pair of square brackets ( [ ] ). Here's what that file format looks like:

Code: Select all
[
[0,5,0, 0,-5,0, 3, "ddddee"],
[15,-3,0.2, 0,5,0, 3, "ddddee"],
[15,-3,0.2, 0,5,0, 3, "ddddee"],
[0,5,0, -15,-3,0.2, 3, "ddddee"],
[0,1.7,0.1, 9,0.2,0.12, 5, "ddddee"],
[0,1.7,0.1, -9,0.2,0.12, 5, "ddddee"],
[0,1,0, -1.6,2,-3.5, 2, "ddddee"],
[0,1,0, 1.6,2,-3.5, 2, "ddddee"],
[-1.6,2,-3.5, 1.6,2,-3.5, 2, "ddddee"],
[0,1,0, 0,0.9,3, 2, "ddddee"],
[9,0.2,0.12, 1.6,2,-3.5, 1, "444444"],
[-9,0.2,0.12, -1.6,2,-3.5, 1, "444444"],
[0,5,0, 1.6,2,-3.5, 1, "444444"],
[0,5,0, -1.6,2,-3.5, 1, "444444"],
[0,-3.2,0, 1.6,2,-3.5, 1, "444444"],
[0,-3.2,0, -1.6,2,-3.5, 1, "444444"],
[0,0.9,3, 0,5,0, 1, "444444"],
[0,0.9,3, 0,-3.2,0, 1, "444444"],
[9,0.2,0.12, 0,0.9,3, 1, "444444"],
[-9,0.2,0.12, 0,0.9,3, 1, "444444"],
[0,5,0, 0,4.742251094905008,0.38784533177372765, 2, "55aadd"],
[0,4.742251094905008,0.38784533177372765, 0,4.3313012963985855,0.7054862490370097, 2, "55aadd"],
[0,4.3313012963985855,0.7054862490370097, 0,3.92756536483687,0.8289233064920131, 2, "55aadd"],
[0,3.92756536483687,0.8289233064920131, 0,3.5240241803386994,0.8571567913108474, 2, "55aadd"],
[0,3.5240241803386994,0.8571567913108474, 0,3.1080189480812677,0.8328670263763542, 2, "55aadd"],
[0,3.1080189480812677,0.8328670263763542, 0,2.7047256205562284,0.7812364607657823, 2, "55aadd"],
[0,2.7047256205562284,0.7812364607657823, 0,2.301512107115242,0.7151862127941968, 2, "55aadd"],
[0,2.301512107115242,0.7151862127941968, 0,1.8857640759430736,0.6402046139726949, 2, "55aadd"],
[0,1.8857640759430736,0.6402046139726949, 0,1.4826660020431564,0.5657876623429037, 2, "55aadd"],
[0,1.4826660020431564,0.5657876623429037, 0,1.0670147092582307,0.49055649796862477, 2, "55aadd"],
[0,1.0670147092582307,0.49055649796862477, 0,0.663994233245397,0.4210937523211147, 2, "55aadd"],
[0,0.663994233245397,0.4210937523211147, 0,0.26100322083377225,0.3563617930410688, 2, "55aadd"],
[0,0.26100322083377225,0.3563617930410688, 0,-0.15455479813431428,0.29543723376866626, 2, "55aadd"],
[0,-0.15455479813431428,0.29543723376866626, 0,-0.5574979164168168,0.24255106342287217, 2, "55aadd"],
[0,-0.5574979164168168,0.24255106342287217, 0,-0.9604218941228142,0.19608358827337133, 2, "55aadd"],
[0,-0.9604218941228142,0.19608358827337133, 0,-1.3759195735480265,0.15507191238808557, 2, "55aadd"],
[0,-1.3759195735480265,0.15507191238808557, 0,-1.7788111989713098,0.12207956898895782, 2, "55aadd"],
[0,-1.7788111989713098,0.12207956898895782, 0,-2.1816894381282523,0.09576619748221092, 2, "55aadd"],
[0,-2.1816894381282523,0.09576619748221092, 0,-2.5971450207303732,0.0755810592751398, 2, "55aadd"],
[0,-2.5971450207303732,0.0755810592751398, 0,-3,0.06266937871188018, 2, "55aadd"],
[-15,-3,0.2, -15,-3.0636178135161876,0.23393152861059405, 2, "55aadd"],
[-15,-3.0636178135161876,0.23393152861059405, -15,-3.1530663735951063,0.2580943204191667, 2, "55aadd"],
[-15,-3.1530663735951063,0.2580943204191667, -15,-3.229698501577891,0.2649576882534699, 2, "55aadd"],
[-15,-3.229698501577891,0.2649576882534699, -15,-3.306191414042995,0.26453564500890303, 2, "55aadd"],
[-15,-3.306191414042995,0.26453564500890303, -15,-3.3952622761771747,0.25864466475071884, 2, "55aadd"],
[-15,-3.3952622761771747,0.25864466475071884, -15,-3.471487629862323,0.25077224579630997, 2, "55aadd"],
[-15,-3.471487629862323,0.25077224579630997, -15,-3.5476237428982706,0.24125126275755834, 2, "55aadd"],
[-15,-3.5476237428982706,0.24125126275755834, -15,-3.623687710001141,0.23062826705155573, 2, "55aadd"],
[-15,-3.623687710001141,0.23062826705155573, -15,-3.712355320519258,0.21730479801726252, 2, "55aadd"],
[-15,-3.712355320519258,0.21730479801726252, -15,-3.7883044294889654,0.20534868753328653, 2, "55aadd"],
[-15,-3.7883044294889654,0.20534868753328653, -15,-3.864213956826103,0.19306134772288217, 2, "55aadd"],
[-15,-3.864213956826103,0.19306134772288217, -15,-3.952732991027377,0.17844951363284392, 2, "55aadd"],
[-15,-3.952732991027377,0.17844951363284392, -15,-4.028575767537186,0.165774822590392, 2, "55aadd"],
[-15,-4.028575767537186,0.165774822590392, -15,-4.104394208388233,0.15301954350661795, 2, "55aadd"],
[-15,-4.104394208388233,0.15301954350661795, -15,-4.192822354090225,0.1380899217998602, 2, "55aadd"],
[-15,-4.192822354090225,0.1380899217998602, -15,-4.268597876666099,0.12528564449015475, 2, "55aadd"],
[-15,-4.268597876666099,0.12528564449015475, -15,-4.344357098215104,0.11249809127215026, 2, "55aadd"],
[-15,-4.344357098215104,0.11249809127215026, -15,-4.420101756654016,0.099744135179592, 2, "55aadd"],
[-15,-4.420101756654016,0.099744135179592, -15,-4.508454080827354,0.0849240545638455, 2, "55aadd"],
[-15,-4.508454080827354,0.0849240545638455, -15,-4.584171983987645,0.072283256030478, 2, "55aadd"],
[15,-3,0.2, 15,-3.0636178135161876,0.23393152861059405, 2, "55aadd"],
[15,-3.0636178135161876,0.23393152861059405, 15,-3.1530663735951063,0.2580943204191667, 2, "55aadd"],
[15,-3.1530663735951063,0.2580943204191667, 15,-3.229698501577891,0.2649576882534699, 2, "55aadd"],
[15,-3.229698501577891,0.2649576882534699, 15,-3.306191414042995,0.26453564500890303, 2, "55aadd"],
[15,-3.306191414042995,0.26453564500890303, 15,-3.3952622761771747,0.25864466475071884, 2, "55aadd"],
[15,-3.3952622761771747,0.25864466475071884, 15,-3.471487629862323,0.25077224579630997, 2, "55aadd"],
[15,-3.471487629862323,0.25077224579630997, 15,-3.5476237428982706,0.24125126275755834, 2, "55aadd"],
[15,-3.5476237428982706,0.24125126275755834, 15,-3.623687710001141,0.23062826705155573, 2, "55aadd"],
[15,-3.623687710001141,0.23062826705155573, 15,-3.712355320519258,0.21730479801726252, 2, "55aadd"],
[15,-3.712355320519258,0.21730479801726252, 15,-3.7883044294889654,0.20534868753328653, 2, "55aadd"],
[15,-3.7883044294889654,0.20534868753328653, 15,-3.864213956826103,0.19306134772288217, 2, "55aadd"],
[15,-3.864213956826103,0.19306134772288217, 15,-3.952732991027377,0.17844951363284392, 2, "55aadd"],
[15,-3.952732991027377,0.17844951363284392, 15,-4.028575767537186,0.165774822590392, 2, "55aadd"],
[15,-4.028575767537186,0.165774822590392, 15,-4.104394208388233,0.15301954350661795, 2, "55aadd"],
[15,-4.104394208388233,0.15301954350661795, 15,-4.192822354090225,0.1380899217998602, 2, "55aadd"],
[15,-4.192822354090225,0.1380899217998602, 15,-4.268597876666099,0.12528564449015475, 2, "55aadd"],
[15,-4.268597876666099,0.12528564449015475, 15,-4.344357098215104,0.11249809127215026, 2, "55aadd"],
[15,-4.344357098215104,0.11249809127215026, 15,-4.420101756654016,0.099744135179592, 2, "55aadd"],
[15,-4.420101756654016,0.099744135179592, 15,-4.508454080827354,0.0849240545638455, 2, "55aadd"],
[15,-4.508454080827354,0.0849240545638455, 15,-4.584171983987645,0.072283256030478, 2, "55aadd"],
[-15,-3,0.2, 0,5,0, 1, "000077"],
[0,5,0, 15,-3,0.2, 1, "000077"],
[-15,-3.0636178135161876,0.23393152861059405, 0,4.742251094905008,0.38784533177372765, 1, "000077"],
[0,4.742251094905008,0.38784533177372765, 15,-3.0636178135161876,0.23393152861059405, 1, "000077"],
[-15,-3.1530663735951063,0.2580943204191667, 0,4.3313012963985855,0.7054862490370097, 1, "000077"],
[0,4.3313012963985855,0.7054862490370097, 15,-3.1530663735951063,0.2580943204191667, 1, "000077"],
[-15,-3.229698501577891,0.2649576882534699, 0,3.92756536483687,0.8289233064920131, 1, "000077"],
[0,3.92756536483687,0.8289233064920131, 15,-3.229698501577891,0.2649576882534699, 1, "000077"],
[-15,-3.306191414042995,0.26453564500890303, 0,3.5240241803386994,0.8571567913108474, 1, "000077"],
[0,3.5240241803386994,0.8571567913108474, 15,-3.306191414042995,0.26453564500890303, 1, "000077"],
[-15,-3.3952622761771747,0.25864466475071884, 0,3.1080189480812677,0.8328670263763542, 1, "000077"],
[0,3.1080189480812677,0.8328670263763542, 15,-3.3952622761771747,0.25864466475071884, 1, "000077"],
[-15,-3.471487629862323,0.25077224579630997, 0,2.7047256205562284,0.7812364607657823, 1, "000077"],
[0,2.7047256205562284,0.7812364607657823, 15,-3.471487629862323,0.25077224579630997, 1, "000077"],
[-15,-3.5476237428982706,0.24125126275755834, 0,2.301512107115242,0.7151862127941968, 1, "000077"],
[0,2.301512107115242,0.7151862127941968, 15,-3.5476237428982706,0.24125126275755834, 1, "000077"],
[-15,-3.623687710001141,0.23062826705155573, 0,1.8857640759430736,0.6402046139726949, 1, "000077"],
[0,1.8857640759430736,0.6402046139726949, 15,-3.623687710001141,0.23062826705155573, 1, "000077"],
[-15,-3.712355320519258,0.21730479801726252, 0,1.4826660020431564,0.5657876623429037, 1, "000077"],
[0,1.4826660020431564,0.5657876623429037, 15,-3.712355320519258,0.21730479801726252, 1, "000077"],
[-15,-3.7883044294889654,0.20534868753328653, 0,1.0670147092582307,0.49055649796862477, 1, "000077"],
[0,1.0670147092582307,0.49055649796862477, 15,-3.7883044294889654,0.20534868753328653, 1, "000077"],
[-15,-3.864213956826103,0.19306134772288217, 0,0.663994233245397,0.4210937523211147, 1, "000077"],
[0,0.663994233245397,0.4210937523211147, 15,-3.864213956826103,0.19306134772288217, 1, "000077"],
[-15,-3.952732991027377,0.17844951363284392, 0,0.26100322083377225,0.3563617930410688, 1, "000077"],
[0,0.26100322083377225,0.3563617930410688, 15,-3.952732991027377,0.17844951363284392, 1, "000077"],
[-15,-4.028575767537186,0.165774822590392, 0,-0.15455479813431428,0.29543723376866626, 1, "000077"],
[0,-0.15455479813431428,0.29543723376866626, 15,-4.028575767537186,0.165774822590392, 1, "000077"],
[-15,-4.104394208388233,0.15301954350661795, 0,-0.5574979164168168,0.24255106342287217, 1, "000077"],
[0,-0.5574979164168168,0.24255106342287217, 15,-4.104394208388233,0.15301954350661795, 1, "000077"],
[-15,-4.192822354090225,0.1380899217998602, 0,-0.9604218941228142,0.19608358827337133, 1, "000077"],
[0,-0.9604218941228142,0.19608358827337133, 15,-4.192822354090225,0.1380899217998602, 1, "000077"],
[-15,-4.268597876666099,0.12528564449015475, 0,-1.3759195735480265,0.15507191238808557, 1, "000077"],
[0,-1.3759195735480265,0.15507191238808557, 15,-4.268597876666099,0.12528564449015475, 1, "000077"],
[-15,-4.344357098215104,0.11249809127215026, 0,-1.7788111989713098,0.12207956898895782, 1, "000077"],
[0,-1.7788111989713098,0.12207956898895782, 15,-4.344357098215104,0.11249809127215026, 1, "000077"],
[-15,-4.420101756654016,0.099744135179592, 0,-2.1816894381282523,0.09576619748221092, 1, "000077"],
[0,-2.1816894381282523,0.09576619748221092, 15,-4.420101756654016,0.099744135179592, 1, "000077"],
[-15,-4.508454080827354,0.0849240545638455, 0,-2.5971450207303732,0.0755810592751398, 1, "000077"],
[0,-2.5971450207303732,0.0755810592751398, 15,-4.508454080827354,0.0849240545638455, 1, "000077"],
[-15,-4.584171983987645,0.072283256030478, 0,-3,0.06266937871188018, 1, "000077"],
[0,-3,0.06266937871188018, 15,-4.584171983987645,0.072283256030478, 1, "000077"],
]


You can copy that text and save it on your local computer. You can also paste it into the frame_designer program here:

      https://ushawks.org/designer/frame_designer.htm

The output from both glider_designer and frame_designer will be pretty much identical:

Glider_Designer_Image.png
Glider_Designer_Image.png (35.92 KiB) Viewed 2173 times


The difference is that the "frame_designer" program is highly unconstrained as to what you can do with it. You can modify or add segments of any color and size wherever you like. For example, if you change the first line of the default Line Segment file from containing an initial 5, a width of 3, and a color of "ddddee":

      [0,5,0, 0,-5,0, 3, "ddddee"],

to containing an initial 10, a width of 5, and a color of "ff8888":

      [0,10,0, 0,-5,0, 5, "ff8888"],

you'll get this extended keel or "bow sprit" version with the specified new thickness and color:

Pink_thick_extended_Keel.png
Pink_thick_extended_Keel.png (31.27 KiB) Viewed 2172 times

The new program can also generate a ".obj" format for either saving or importing into other tools. Just click the "Make .obj" button, and you'll get a pop-up box containing the glider's description in ".obj" format. Then select it all, copy it to the clipboard, and paste it into another program or a text editor to save. Here's what that ".obj" file looks like:

Code: Select all
o Glider
v 0 0 -10
v 0 0 5
v -15 0.2 3
v 0 0 -5
v 15 0.2 3
v 0 0.1 -1.7000000000000002
v -9 0.12 -0.20000000000000018
v 9 0.12 -0.20000000000000018
v 0 0 -1
v 1.6 -3.5 -2
v -1.6 -3.5 -2
v 0 3 -0.9
v 0 0 3.1999999999999993
v 0 0.38784533177372765 -4.742251094905008
v 0 0.7054862490370097 -4.3313012963985855
v 0 0.8289233064920131 -3.92756536483687
v 0 0.8571567913108474 -3.5240241803386994
v 0 0.8328670263763542 -3.1080189480812677
v 0 0.7812364607657823 -2.7047256205562284
v 0 0.7151862127941968 -2.301512107115242
v 0 0.6402046139726949 -1.8857640759430736
v 0 0.5657876623429037 -1.4826660020431564
v 0 0.49055649796862477 -1.0670147092582307
v 0 0.4210937523211147 -0.663994233245397
v 0 0.3563617930410688 -0.26100322083377225
v 0 0.29543723376866626 0.15455479813431428
v 0 0.24255106342287217 0.5574979164168168
v 0 0.19608358827337133 0.9604218941228142
v 0 0.15507191238808557 1.3759195735480265
v 0 0.12207956898895782 1.7788111989713098
v 0 0.09576619748221092 2.1816894381282523
v 0 0.0755810592751398 2.5971450207303732
v 0 0.06266937871188018 3
v 15 0.23393152861059405 3.0636178135161876
v 15 0.2580943204191667 3.1530663735951063
v 15 0.2649576882534699 3.229698501577891
v 15 0.26453564500890303 3.306191414042995
v 15 0.25864466475071884 3.3952622761771747
v 15 0.25077224579630997 3.471487629862323
v 15 0.24125126275755834 3.5476237428982706
v 15 0.23062826705155573 3.623687710001141
v 15 0.21730479801726252 3.712355320519258
v 15 0.20534868753328653 3.7883044294889654
v 15 0.19306134772288217 3.864213956826103
v 15 0.17844951363284392 3.952732991027377
v 15 0.165774822590392 4.028575767537186
v 15 0.15301954350661795 4.104394208388233
v 15 0.1380899217998602 4.192822354090225
v 15 0.12528564449015475 4.268597876666099
v 15 0.11249809127215026 4.344357098215104
v 15 0.099744135179592 4.420101756654016
v 15 0.0849240545638455 4.508454080827354
v 15 0.072283256030478 4.584171983987645
v -15 0.23393152861059405 3.0636178135161876
v -15 0.2580943204191667 3.1530663735951063
v -15 0.2649576882534699 3.229698501577891
v -15 0.26453564500890303 3.306191414042995
v -15 0.25864466475071884 3.3952622761771747
v -15 0.25077224579630997 3.471487629862323
v -15 0.24125126275755834 3.5476237428982706
v -15 0.23062826705155573 3.623687710001141
v -15 0.21730479801726252 3.712355320519258
v -15 0.20534868753328653 3.7883044294889654
v -15 0.19306134772288217 3.864213956826103
v -15 0.17844951363284392 3.952732991027377
v -15 0.165774822590392 4.028575767537186
v -15 0.15301954350661795 4.104394208388233
v -15 0.1380899217998602 4.192822354090225
v -15 0.12528564449015475 4.268597876666099
v -15 0.11249809127215026 4.344357098215104
v -15 0.099744135179592 4.420101756654016
v -15 0.0849240545638455 4.508454080827354
v -15 0.072283256030478 4.584171983987645
l 1 2
l 3 4
l 3 4
l 4 5
l 6 7
l 6 8
l 9 10
l 9 11
l 10 11
l 9 12
l 7 11
l 8 10
l 4 11
l 4 10
l 13 11
l 13 10
l 12 4
l 12 13
l 7 12
l 8 12
l 4 14
l 14 15
l 15 16
l 16 17
l 17 18
l 18 19
l 19 20
l 20 21
l 21 22
l 22 23
l 23 24
l 24 25
l 25 26
l 26 27
l 27 28
l 28 29
l 29 30
l 30 31
l 31 32
l 32 33
l 5 34
l 34 35
l 35 36
l 36 37
l 37 38
l 38 39
l 39 40
l 40 41
l 41 42
l 42 43
l 43 44
l 44 45
l 45 46
l 46 47
l 47 48
l 48 49
l 49 50
l 50 51
l 51 52
l 52 53
l 3 54
l 54 55
l 55 56
l 56 57
l 57 58
l 58 59
l 59 60
l 60 61
l 61 62
l 62 63
l 63 64
l 64 65
l 65 66
l 66 67
l 67 68
l 68 69
l 69 70
l 70 71
l 71 72
l 72 73
l 5 4
l 4 3
l 34 14
l 14 54
l 35 15
l 15 55
l 36 16
l 16 56
l 37 17
l 17 57
l 38 18
l 18 58
l 39 19
l 19 59
l 40 20
l 20 60
l 41 21
l 21 61
l 42 22
l 22 62
l 43 23
l 23 63
l 44 24
l 24 64
l 45 25
l 25 65
l 46 26
l 26 66
l 47 27
l 27 67
l 48 28
l 28 68
l 49 29
l 29 69
l 50 30
l 30 70
l 51 31
l 31 71
l 52 32
l 32 72
l 53 33
l 33 73


Note that this method of building a glider FIRST in glider_designer and then passing it on to frame_designer for customization can save a lot of work. The glider_designer program has great tools for laying out the basics of most "normal" gliders. But once exported as a series of lines, those lines can be modified any way that you need in frame_designer. So you generally want to make as many changes as glider_designer will allow, and then make the final changes in frame_designer.

I hope that helps!
Join a National Hang Gliding Organization: US Hawks at ushawks.org
View my rating at: US Hang Gliding Rating System
Every human at every point in history has an opportunity to choose courage over cowardice. Look around and you will find that opportunity in your own time.
Bob Kuczewski
User avatar
Contributor
Contributor
 
Posts: 8374
Joined: Fri Aug 13, 2010 2:40 pm
Location: San Diego, CA

Re: Simple (and Primitive) 3D Rendering Program

Postby JoeF » Fri Oct 21, 2022 1:35 pm

Started playing with US Hawks Glider Designer:
USHawksGliderDesigner.jpg


-----
Also, I started on some tutorial for Blender.

Thanks. Thanks. :salute: :salute:
Join a National Hang Gliding Organization: US Hawks at ushawks.org

View pilots' hang gliding rating at: US Hang Gliding Rating System
JoeF
User avatar
Contributor
Contributor
 
Posts: 4565
Joined: Sat Aug 14, 2010 3:41 pm

Re: Simple (and Primitive) 3D Rendering Program

Postby Bob Kuczewski » Sat Nov 05, 2022 2:27 am

Hi Joe, here's a version with a High Hat just for you:

High_Hat_001.gif
High_Hat_001.gif (862.21 KiB) Viewed 2000 times


And here's a dodecahedron (just for fun):

Dodecahedron.gif
Dodecahedron.gif (328.3 KiB) Viewed 1994 times
Join a National Hang Gliding Organization: US Hawks at ushawks.org
View my rating at: US Hang Gliding Rating System
Every human at every point in history has an opportunity to choose courage over cowardice. Look around and you will find that opportunity in your own time.
Bob Kuczewski
User avatar
Contributor
Contributor
 
Posts: 8374
Joined: Fri Aug 13, 2010 2:40 pm
Location: San Diego, CA

Re: Simple (and Primitive) 3D Rendering Program

Postby JoeF » Sat Nov 05, 2022 3:52 pm

Fun! Please post the codes for those two creations. TIA. Or maybe you installed them in the program; I will go look.
Join a National Hang Gliding Organization: US Hawks at ushawks.org

View pilots' hang gliding rating at: US Hang Gliding Rating System
JoeF
User avatar
Contributor
Contributor
 
Posts: 4565
Joined: Sat Aug 14, 2010 3:41 pm

Re: Simple (and Primitive) 3D Rendering Program

Postby Craig Muhonen » Sat Nov 05, 2022 5:54 pm

Amazing Bob, you have seemed to draw 2 dodecahedron's in the same picture, one spinning clockwise and the same one spinning counter-clockwise, and vice versa. Pure genius. I guess that you really can be it two places at the same time. My eyes went crazy trying to see both spins at the same time. Oh I see, it starts and stops at 180 degrees, you programmer you.
Here's a puzzle;
PG seems to have it's own, sorta' AI, that includes HG.
Couldn't HG have it's own AI that doesn't include PG?
Sometimes you gotta' push the stick forward while you're lookn' at the ground
Craig Muhonen
User avatar
Contributor
Contributor
 
Posts: 934
Joined: Tue Nov 05, 2019 9:58 pm
Location: The Canyons of the Ancients

Re: Simple (and Primitive) 3D Rendering Program

Postby Bob Kuczewski » Sat Nov 05, 2022 8:43 pm

Craig Muhonen wrote:Amazing Bob, you have seemed to draw 2 dodecahedron's in the same picture, one spinning clockwise and the same one spinning counter-clockwise, and vice versa. Pure genius. I guess that you really can be it two places at the same time. My eyes went crazy trying to see both spins at the same time.


Your eyes (and mostly your brain) are telling you that something's not natural about that picture. Something's wrong. There are actually 2 things that are wrong and both of them lead to the ambiguity that you experience through your visual system.

1. The current progam has no provision for "hidden line removal". In other words, the lines are drawn on the screen in some order that causes some lines to be drawn over other lines when they should actually be behind those other lines.

2. The current program has no provision for perspective. Everything is drawn in what's known as an "orthographic" view. So things that are further away don't appear reduced in size as they normally should be.


There are much better programs that can draw scenes with both hidden line removal and perspective. But for this case, I just wanted something small and simple without any external dependencies.

JoeF wrote:Fun! Please post the codes for those two creations. TIA. Or maybe you installed them in the program; I will go look.


Sure Joe.

Here's the code for the glider with the High Hat:

Glider with High Hat:
Code: Select all
[

 [    0,   5,    0,      0,  -5,    0,   3, "ddddee" ],
 [   15,  -3,  0.2,      0,   5,    0,   3, "ddddee" ],
 [   15,  -3,  0.2,      0,   5,    0,   3, "ddddee" ],
 [    0,   5,    0,    -15,  -3,  0.2,   3, "ddddee" ],
 [    0, 1.7,  0.1,      9, 0.2, 0.12,   5, "ddddee" ],
 [    0, 1.7,  0.1,     -9, 0.2, 0.12,   5, "ddddee" ],
 [    0,   1,    0,   -1.6,   2, -3.5,   2, "ddddee" ],
 [    0,   1,    0,    1.6,   2, -3.5,   2, "ddddee" ],
 [ -1.6,   2, -3.5,    1.6,   2, -3.5,   2, "ddddee" ],

 // High Hat

 [    0,   1,    0,   -0.9, 0.9,    3,   2, "ddddee" ],
 [  0.9, 0.9,    3,   -0.9, 0.9,    3,   2, "ddddee" ],

 [  9,  0.2, 0.12,    1.6,    2, -3.5,   1, "444444" ],
 [ -9,  0.2, 0.12,   -1.6,    2, -3.5,   1, "444444" ],
 [  0,    5,    0,    1.6,    2, -3.5,   1, "444444" ],
 [  0,    5,    0,   -1.6,    2, -3.5,   1, "444444" ],
 [  0, -3.2,    0,    1.6,    2, -3.5,   1, "444444" ],
 [  0, -3.2,    0,   -1.6,    2, -3.5,   1, "444444" ],

 [  0.9,  0.9,  3,      0,    5,    0,   1, "444444" ], // Top front wire
 [  0.9,  0.9,  3,      0, -3.2,    0,   1, "444444" ], // Top rear wire

 [  0.9,  0.9,  3,      9,  0.2, 0.12,   1, "444444" ], // Top side wire
 [ -0.9,  0.9,  3,     -9,  0.2, 0.12,   1, "444444" ], // Top side wire

 [ 0, 5, 0, 0, 4.742251094905008, 0.38784533177372765, 2, "55aadd" ],
 [ 0, 4.742251094905008, 0.38784533177372765, 0, 4.3313012963985855, 0.7054862490370097, 2, "55aadd" ],
 [ 0, 4.3313012963985855, 0.7054862490370097, 0, 3.92756536483687, 0.8289233064920131, 2, "55aadd" ],
 [ 0, 3.92756536483687, 0.8289233064920131, 0, 3.5240241803386994, 0.8571567913108474, 2, "55aadd" ],
 [ 0, 3.5240241803386994, 0.8571567913108474, 0, 3.1080189480812677, 0.8328670263763542, 2, "55aadd" ],
 [ 0, 3.1080189480812677, 0.8328670263763542, 0, 2.7047256205562284, 0.7812364607657823, 2, "55aadd" ],
 [ 0, 2.7047256205562284, 0.7812364607657823, 0, 2.301512107115242, 0.7151862127941968, 2, "55aadd" ],
 [ 0, 2.301512107115242, 0.7151862127941968, 0, 1.8857640759430736, 0.6402046139726949, 2, "55aadd" ],
 [ 0, 1.8857640759430736, 0.6402046139726949, 0, 1.4826660020431564, 0.5657876623429037, 2, "55aadd" ],
 [ 0, 1.4826660020431564, 0.5657876623429037, 0, 1.0670147092582307, 0.49055649796862477, 2, "55aadd" ],
 [ 0, 1.0670147092582307, 0.49055649796862477, 0, 0.663994233245397, 0.4210937523211147, 2, "55aadd" ],
 [ 0, 0.663994233245397, 0.4210937523211147, 0, 0.26100322083377225, 0.3563617930410688, 2, "55aadd" ],
 [ 0, 0.26100322083377225, 0.3563617930410688, 0, -0.15455479813431428, 0.29543723376866626, 2, "55aadd" ],
 [ 0, -0.15455479813431428, 0.29543723376866626, 0, -0.5574979164168168, 0.24255106342287217, 2, "55aadd" ],
 [ 0, -0.5574979164168168, 0.24255106342287217, 0, -0.9604218941228142, 0.19608358827337133, 2, "55aadd" ],
 [ 0, -0.9604218941228142, 0.19608358827337133, 0, -1.3759195735480265, 0.15507191238808557, 2, "55aadd" ],
 [ 0, -1.3759195735480265, 0.15507191238808557, 0, -1.7788111989713098, 0.12207956898895782, 2, "55aadd" ],
 [ 0, -1.7788111989713098, 0.12207956898895782, 0, -2.1816894381282523, 0.09576619748221092, 2, "55aadd" ],
 [ 0, -2.1816894381282523, 0.09576619748221092, 0, -2.5971450207303732, 0.0755810592751398, 2, "55aadd" ],
 [ 0, -2.5971450207303732, 0.0755810592751398, 0, -3, 0.06266937871188018, 2, "55aadd" ],
 [ -15, -3, 0.2, -15, -3.0636178135161876, 0.23393152861059405, 2, "55aadd" ],
 [ -15, -3.0636178135161876, 0.23393152861059405, -15, -3.1530663735951063, 0.2580943204191667, 2, "55aadd" ],
 [ -15, -3.1530663735951063, 0.2580943204191667, -15, -3.229698501577891, 0.2649576882534699, 2, "55aadd" ],
 [ -15, -3.229698501577891, 0.2649576882534699, -15, -3.306191414042995, 0.26453564500890303, 2, "55aadd" ],
 [ -15, -3.306191414042995, 0.26453564500890303, -15, -3.3952622761771747, 0.25864466475071884, 2, "55aadd" ],
 [ -15, -3.3952622761771747, 0.25864466475071884, -15, -3.471487629862323, 0.25077224579630997, 2, "55aadd" ],
 [ -15, -3.471487629862323, 0.25077224579630997, -15, -3.5476237428982706, 0.24125126275755834, 2, "55aadd" ],
 [ -15, -3.5476237428982706, 0.24125126275755834, -15, -3.623687710001141, 0.23062826705155573, 2, "55aadd" ],
 [ -15, -3.623687710001141, 0.23062826705155573, -15, -3.712355320519258, 0.21730479801726252, 2, "55aadd" ],
 [ -15, -3.712355320519258, 0.21730479801726252, -15, -3.7883044294889654, 0.20534868753328653, 2, "55aadd" ],
 [ -15, -3.7883044294889654, 0.20534868753328653, -15, -3.864213956826103, 0.19306134772288217, 2, "55aadd" ],
 [ -15, -3.864213956826103, 0.19306134772288217, -15, -3.952732991027377, 0.17844951363284392, 2, "55aadd" ],
 [ -15, -3.952732991027377, 0.17844951363284392, -15, -4.028575767537186, 0.165774822590392, 2, "55aadd" ],
 [ -15, -4.028575767537186, 0.165774822590392, -15, -4.104394208388233, 0.15301954350661795, 2, "55aadd" ],
 [ -15, -4.104394208388233, 0.15301954350661795, -15, -4.192822354090225, 0.1380899217998602, 2, "55aadd" ],
 [ -15, -4.192822354090225, 0.1380899217998602, -15, -4.268597876666099, 0.12528564449015475, 2, "55aadd" ],
 [ -15, -4.268597876666099, 0.12528564449015475, -15, -4.344357098215104, 0.11249809127215026, 2, "55aadd" ],
 [ -15, -4.344357098215104, 0.11249809127215026, -15, -4.420101756654016, 0.099744135179592, 2, "55aadd" ],
 [ -15, -4.420101756654016, 0.099744135179592, -15, -4.508454080827354, 0.0849240545638455, 2, "55aadd" ],
 [ -15, -4.508454080827354, 0.0849240545638455, -15, -4.584171983987645, 0.072283256030478, 2, "55aadd" ],
 [ 15, -3, 0.2, 15, -3.0636178135161876, 0.23393152861059405, 2, "55aadd" ],
 [ 15, -3.0636178135161876, 0.23393152861059405, 15, -3.1530663735951063, 0.2580943204191667, 2, "55aadd" ],
 [ 15, -3.1530663735951063, 0.2580943204191667, 15, -3.229698501577891, 0.2649576882534699, 2, "55aadd" ],
 [ 15, -3.229698501577891, 0.2649576882534699, 15, -3.306191414042995, 0.26453564500890303, 2, "55aadd" ],
 [ 15, -3.306191414042995, 0.26453564500890303, 15, -3.3952622761771747, 0.25864466475071884, 2, "55aadd" ],
 [ 15, -3.3952622761771747, 0.25864466475071884, 15, -3.471487629862323, 0.25077224579630997, 2, "55aadd" ],
 [ 15, -3.471487629862323, 0.25077224579630997, 15, -3.5476237428982706, 0.24125126275755834, 2, "55aadd" ],
 [ 15, -3.5476237428982706, 0.24125126275755834, 15, -3.623687710001141, 0.23062826705155573, 2, "55aadd" ],
 [ 15, -3.623687710001141, 0.23062826705155573, 15, -3.712355320519258, 0.21730479801726252, 2, "55aadd" ],
 [ 15, -3.712355320519258, 0.21730479801726252, 15, -3.7883044294889654, 0.20534868753328653, 2, "55aadd" ],
 [ 15, -3.7883044294889654, 0.20534868753328653, 15, -3.864213956826103, 0.19306134772288217, 2, "55aadd" ],
 [ 15, -3.864213956826103, 0.19306134772288217, 15, -3.952732991027377, 0.17844951363284392, 2, "55aadd" ],
 [ 15, -3.952732991027377, 0.17844951363284392, 15, -4.028575767537186, 0.165774822590392, 2, "55aadd" ],
 [ 15, -4.028575767537186, 0.165774822590392, 15, -4.104394208388233, 0.15301954350661795, 2, "55aadd" ],
 [ 15, -4.104394208388233, 0.15301954350661795, 15, -4.192822354090225, 0.1380899217998602, 2, "55aadd" ],
 [ 15, -4.192822354090225, 0.1380899217998602, 15, -4.268597876666099, 0.12528564449015475, 2, "55aadd" ],
 [ 15, -4.268597876666099, 0.12528564449015475, 15, -4.344357098215104, 0.11249809127215026, 2, "55aadd" ],
 [ 15, -4.344357098215104, 0.11249809127215026, 15, -4.420101756654016, 0.099744135179592, 2, "55aadd" ],
 [ 15, -4.420101756654016, 0.099744135179592, 15, -4.508454080827354, 0.0849240545638455, 2, "55aadd" ],
 [ 15, -4.508454080827354, 0.0849240545638455, 15, -4.584171983987645, 0.072283256030478, 2, "55aadd" ],
 [ -15, -3, 0.2, 0, 5, 0, 1, "000077" ],
 [ 0, 5, 0, 15, -3, 0.2, 1, "000077" ],
 [ -15, -3.0636178135161876, 0.23393152861059405, 0, 4.742251094905008, 0.38784533177372765, 1, "000077" ],
 [ 0, 4.742251094905008, 0.38784533177372765, 15, -3.0636178135161876, 0.23393152861059405, 1, "000077" ],
 [ -15, -3.1530663735951063, 0.2580943204191667, 0, 4.3313012963985855, 0.7054862490370097, 1, "000077" ],
 [ 0, 4.3313012963985855, 0.7054862490370097, 15, -3.1530663735951063, 0.2580943204191667, 1, "000077" ],
 [ -15, -3.229698501577891, 0.2649576882534699, 0, 3.92756536483687, 0.8289233064920131, 1, "000077" ],
 [ 0, 3.92756536483687, 0.8289233064920131, 15, -3.229698501577891, 0.2649576882534699, 1, "000077" ],
 [ -15, -3.306191414042995, 0.26453564500890303, 0, 3.5240241803386994, 0.8571567913108474, 1, "000077" ],
 [ 0, 3.5240241803386994, 0.8571567913108474, 15, -3.306191414042995, 0.26453564500890303, 1, "000077" ],
 [ -15, -3.3952622761771747, 0.25864466475071884, 0, 3.1080189480812677, 0.8328670263763542, 1, "000077" ],
 [ 0, 3.1080189480812677, 0.8328670263763542, 15, -3.3952622761771747, 0.25864466475071884, 1, "000077" ],
 [ -15, -3.471487629862323, 0.25077224579630997, 0, 2.7047256205562284, 0.7812364607657823, 1, "000077" ],
 [ 0, 2.7047256205562284, 0.7812364607657823, 15, -3.471487629862323, 0.25077224579630997, 1, "000077" ],
 [ -15, -3.5476237428982706, 0.24125126275755834, 0, 2.301512107115242, 0.7151862127941968, 1, "000077" ],
 [ 0, 2.301512107115242, 0.7151862127941968, 15, -3.5476237428982706, 0.24125126275755834, 1, "000077" ],
 [ -15, -3.623687710001141, 0.23062826705155573, 0, 1.8857640759430736, 0.6402046139726949, 1, "000077" ],
 [ 0, 1.8857640759430736, 0.6402046139726949, 15, -3.623687710001141, 0.23062826705155573, 1, "000077" ],
 [ -15, -3.712355320519258, 0.21730479801726252, 0, 1.4826660020431564, 0.5657876623429037, 1, "000077" ],
 [ 0, 1.4826660020431564, 0.5657876623429037, 15, -3.712355320519258, 0.21730479801726252, 1, "000077" ],
 [ -15, -3.7883044294889654, 0.20534868753328653, 0, 1.0670147092582307, 0.49055649796862477, 1, "000077" ],
 [ 0, 1.0670147092582307, 0.49055649796862477, 15, -3.7883044294889654, 0.20534868753328653, 1, "000077" ],
 [ -15, -3.864213956826103, 0.19306134772288217, 0, 0.663994233245397, 0.4210937523211147, 1, "000077" ],
 [ 0, 0.663994233245397, 0.4210937523211147, 15, -3.864213956826103, 0.19306134772288217, 1, "000077" ],
 [ -15, -3.952732991027377, 0.17844951363284392, 0, 0.26100322083377225, 0.3563617930410688, 1, "000077" ],
 [ 0, 0.26100322083377225, 0.3563617930410688, 15, -3.952732991027377, 0.17844951363284392, 1, "000077" ],
 [ -15, -4.028575767537186, 0.165774822590392, 0, -0.15455479813431428, 0.29543723376866626, 1, "000077" ],
 [ 0, -0.15455479813431428, 0.29543723376866626, 15, -4.028575767537186, 0.165774822590392, 1, "000077" ],
 [ -15, -4.104394208388233, 0.15301954350661795, 0, -0.5574979164168168, 0.24255106342287217, 1, "000077" ],
 [ 0, -0.5574979164168168, 0.24255106342287217, 15, -4.104394208388233, 0.15301954350661795, 1, "000077" ],
 [ -15, -4.192822354090225, 0.1380899217998602, 0, -0.9604218941228142, 0.19608358827337133, 1, "000077" ],
 [ 0, -0.9604218941228142, 0.19608358827337133, 15, -4.192822354090225, 0.1380899217998602, 1, "000077" ],
 [ -15, -4.268597876666099, 0.12528564449015475, 0, -1.3759195735480265, 0.15507191238808557, 1, "000077" ],
 [ 0, -1.3759195735480265, 0.15507191238808557, 15, -4.268597876666099, 0.12528564449015475, 1, "000077" ],
 [ -15, -4.344357098215104, 0.11249809127215026, 0, -1.7788111989713098, 0.12207956898895782, 1, "000077" ],
 [ 0, -1.7788111989713098, 0.12207956898895782, 15, -4.344357098215104, 0.11249809127215026, 1, "000077" ],
 [ -15, -4.420101756654016, 0.099744135179592, 0, -2.1816894381282523, 0.09576619748221092, 1, "000077" ],
 [ 0, -2.1816894381282523, 0.09576619748221092, 15, -4.420101756654016, 0.099744135179592, 1, "000077" ],
 [ -15, -4.508454080827354, 0.0849240545638455, 0, -2.5971450207303732, 0.0755810592751398, 1, "000077" ],
 [ 0, -2.5971450207303732, 0.0755810592751398, 15, -4.508454080827354, 0.0849240545638455, 1, "000077" ],
 [ -15, -4.584171983987645, 0.072283256030478, 0, -3, 0.06266937871188018, 1, "000077" ],
 [ 0, -3, 0.06266937871188018, 15, -4.584171983987645, 0.072283256030478, 1, "000077" ],
]


Here's the code for the dodecahedron:

Dodecahedron:
Code: Select all
// Lines
[
 [        5,       -5,        5,    3.09017,        0,  8.09017,   1, "ff5555" ],
 [        0,  8.09017,  3.09017,          5,        5,        5,   1, "55ff55" ],
 [       -5,        5,        5,   -3.09017,        0,  8.09017,   1, "5555ff" ],
 [       -5,        5,        5,          0,  8.09017,  3.09017,   1, "ffff00" ],
 [  3.09017,        0,  8.09017,          5,        5,        5,   1, "ff00ff" ],
 [  3.09017,        0,  8.09017,   -3.09017,        0,  8.09017,   1, "55ffff" ],
 [        0,  8.09017,  3.09017,          0,  8.09017, -3.09017,   1, "ff5555" ],
 [ -3.09017,        0,  8.09017,         -5,       -5,        5,   1, "55ff55" ],
 [        5,        5,        5,    8.09017,  3.09017,        0,   1, "5555ff" ],
 [       -5,        5,        5,   -8.09017,  3.09017,        0,   1, "ff00ff" ],
 [        0, -8.09017,  3.09017,         -5,       -5,        5,   1, "5555ff" ],
 [       -5,       -5,        5,   -8.09017, -3.09017,        0,   1, "ffff00" ],
 [        0, -8.09017,  3.09017,          5,       -5,        5,   1, "ffff00" ],
 [        0, -8.09017, -3.09017,          0, -8.09017,  3.09017,   1, "ff00ff" ],
 [        5,       -5,        5,    8.09017, -3.09017,        0,   1, "55ff55" ],
 [  8.09017, -3.09017,        0,    8.09017,  3.09017,        0,   1, "55ffff" ],
 [  8.09017, -3.09017,        0,    8.09017,  3.09017,        0,   1, "ffff00" ],
 [  8.09017,  3.09017,        0,          5,        5,       -5,   1, "ff00ff" ],
 [        0,  8.09017, -3.09017,          5,        5,       -5,   1, "55ffff" ],
 [        5,        5,       -5,    3.09017,        0, -8.09017,   1, "ff5555" ],
 [  8.09017, -3.09017,        0,          5,       -5,       -5,   1, "5555ff" ],
 [ -8.09017, -3.09017,        0,   -8.09017,  3.09017,        0,   1, "ff5555" ],
 [ -8.09017,  3.09017,        0,         -5,        5,       -5,   1, "55ff55" ],
 [       -5,        5,       -5,          0,  8.09017, -3.09017,   1, "5555ff" ],
 [        5,       -5,       -5,          0, -8.09017, -3.09017,   1, "ff5555" ],
 [       -5,       -5,       -5,   -8.09017, -3.09017,        0,   1, "55ffff" ],
 [       -5,       -5,       -5,   -8.09017, -3.09017,        0,   1, "55ffff" ],
 [       -5,        5,       -5,   -3.09017,        0, -8.09017,   1, "ffff00" ],
 [        5,       -5,       -5,    3.09017,        0, -8.09017,   1, "55ff55" ],
 [        0, -8.09017, -3.09017,         -5,       -5,       -5,   1, "5555ff" ],
 [  3.09017,        0, -8.09017,   -3.09017,        0, -8.09017,   1, "ff00ff" ],
 [ -3.09017,        0, -8.09017,         -5,       -5,       -5,   1, "ff5555" ],
]


They should both run in what I am currently calling the "frame_designer" program. Just select all the code in either box (for some reason the "SELECT ALL" button doesn't work ... another thing on my "to do" list). Copy the code and paste it into the "JSON Line Segments" box in the frame designer page. Click the "Load from JSON" button and you should see the (almost) 3D image in the window.

I constructed the dodecahedron from the formula listed for the points at Wikipedia:

      https://en.wikipedia.org/wiki/Regular_dodecahedron

(±1, ±1, ±1)
(0, ±ϕ, ±1/ϕ)
(±1/ϕ, 0, ±ϕ)
(±ϕ, ±1/ϕ, 0)

where ϕ = (1 + √5)/2 is the golden ratio (also written τ) ≈ 1.618


But that just gave me the points. I still needed to connect line segments between the proper pairs of points to draw the figure. I originally did that by hand using the drawing tool, but it was very laborious. I drew small line segments at each point (so they could be seen), and I gave them different colors. Then, by hand, I made lines between those neighbors where it was needed. I used color to help me see which ones I was working on.

Tonight, I decided to write a program to do it automatically. I chose Python because it's easier to use from the command line than JavaScript. My program assumes that it's dealing with a regular polyhedron, so the lines will be drawn between the shortest distances between points. The algorithm proceeds as follows:

  1. Find the shortest non-zero distance between any pair of points.
  2. Set the threshold just above that shortest distance (to allow for digital misrepresentations).
  3. Define a line segment between any pair of points closer than that threshold.

Here's the Python code:

Code: Select all
# Generate coordinates for a dodecahedron
# https://en.wikipedia.org/wiki/Regular_dodecahedron

import math

s = 5
p = ( 1 + math.sqrt(5) ) / 2

# Build the list of points from the Wikipedia definitions

pt_list = []

for i in range(2):
  x = -1
  if i > 0: x = 1
  for j in range(2):
    y = -1
    if j > 0: y = 1
    for k in range(2):
      z = -1
      if k > 0: z = 1
      pt_list.append ( [x,y,z] )

for i in range(2):
  y = -p
  if i > 0: y = p
  for j in range(2):
    z = -(1/p)
    if j > 0: z = 1/p
    pt_list.append ( [0,y,z] )

for i in range(2):
  x = -(1/p)
  if i > 0: x = 1/p
  for j in range(2):
    z = -p
    if j > 0: z = p
    pt_list.append ( [x,0,z] )

for i in range(2):
  x = -p
  if i > 0: x = p
  for j in range(2):
    y = -(1/p)
    if j > 0: y = 1/p
    pt_list.append ( [x,y,0] )

# Get the maximum distance between all pairs of points
max_dist = 0.0
for i1 in range(len(pt_list)):
  p1 = pt_list[i1]
  for i2 in range(len(pt_list)):
    p2 = pt_list[i2]
    dx = p2[0] - p1[0]
    dy = p2[1] - p1[1]
    dz = p2[2] - p1[2]
    dist = math.sqrt((dx*dx)+(dy*dy)+(dz*dz))
    if dist > max_dist:
      max_dist = dist

# Get the minimum distance between all pairs of points
min_dist = max_dist
for i1 in range(len(pt_list)):
  for i2 in range(len(pt_list)):
    if i1 != i2:
      p1 = pt_list[i1]
      p2 = pt_list[i2]
      dx = p2[0] - p1[0]
      dy = p2[1] - p1[1]
      dz = p2[2] - p1[2]
      dist = math.sqrt((dx*dx)+(dy*dy)+(dz*dz))
      if dist < min_dist:
        min_dist = dist

# Set a threshold for neighbors (to allow for floating point inaccuracy)
t_dist = min_dist * 1.01

# Build an empty connection matrix
m = []
for i1 in range(len(pt_list)):
  n = []
  for i2 in range(len(pt_list)):
    n.append ( 0 )
  m.append ( n )

# Fill the matrix with connections under the threshold
tot = 0
for i1 in range(len(pt_list)):
  for i2 in range(len(pt_list)):
    if i1 != i2:
      p1 = pt_list[i1]
      p2 = pt_list[i2]
      dx = p2[0] - p1[0]
      dy = p2[1] - p1[1]
      dz = p2[2] - p1[2]
      dist = math.sqrt((dx*dx)+(dy*dy)+(dz*dz))
      if dist < t_dist:
        m[i1][i2] += 1
        tot += 1

# Print the lines from the upper triangular portion of the matrix
print ( "[" )
for i1 in range(len(pt_list)):
  for i2 in range(len(pt_list)):
    if i2 > i1:
      if m[i1][i2] > 0:
        pls = "["
        p = pt_list[i1]
        for c in range(len(p)):
          pls += str((s*p[c])) + ","
        p = pt_list[i2]
        for c in range(len(p)):
          pls += str((s*p[c])) + ","
        pls = ' ' + pls + '1,"00ff00"],'
        # pls = ' ' + pls[0:-1] + "]"
        print ( pls )
print ( "]" )

# Uncomment this to drop into a debugging shell
# __import__('code').interact(local={k: v for ns in (globals(), locals()) for k, v in ns.items()})


If you run that program from the command line, it will print out the JSON needed to draw the figure in the terminal window. I just selected that JSON from the terminal window and copied and pasted it into the frame designer program. This program produces all green output ("00ff00"), but you can change the colors by hand. And speaking of colors, one thing that I've found is that monochrome diagrams don't suffer from the lack of hidden line removal because you can't tell which line is behind the other anyway (all lines are the same color). And if you do use color, then using thinner lines makes it harder to perceive that the wrong line may be hidden. Here's an all green version:

Dodecahedron_Green_Spinning.gif
Dodecahedron_Green_Spinning.gif (561.61 KiB) Viewed 1979 times


Here's an icosahedron (constructed similarly):

Icosahedron_Green_Spinning.gif
Icosahedron_Green_Spinning.gif (793.24 KiB) Viewed 1978 times


Here's the formula listed for the icosahedron points at Wikipedia:

      https://en.wikipedia.org/wiki/Regular_icosahedron

(0, ±1, ±ϕ)
(±1, ±ϕ, 0)
(±ϕ, 0, ±1)

where ϕ = (1 + √5)/2 is the golden ratio (also written τ) ≈ 1.618


For completeness, here are the codes for all five of the platonic solids (tetrahedron, cube, octahedron, dodecahedron, and icosahedron):

Tetrahedron:
Code: Select all
[
 [-5,0,-3.53553390593,5,0,-3.53553390593,3,"00ff00"],
 [-5,0,-3.53553390593,0,-5,3.53553390593,3,"00ff00"],
 [-5,0,-3.53553390593,0,5,3.53553390593,3,"00ff00"],
 [5,0,-3.53553390593,0,-5,3.53553390593,3,"00ff00"],
 [5,0,-3.53553390593,0,5,3.53553390593,3,"00ff00"],
 [0,-5,3.53553390593,0,5,3.53553390593,3,"00ff00"],
]


Cube:
Code: Select all
[
 [-5,-5,-5,-5,-5,5,3,"00ff00"],
 [-5,-5,-5,-5,5,-5,3,"00ff00"],
 [-5,-5,-5,5,-5,-5,3,"00ff00"],
 [-5,-5,5,-5,5,5,3,"00ff00"],
 [-5,-5,5,5,-5,5,3,"00ff00"],
 [-5,5,-5,-5,5,5,3,"00ff00"],
 [-5,5,-5,5,5,-5,3,"00ff00"],
 [-5,5,5,5,5,5,3,"00ff00"],
 [5,-5,-5,5,-5,5,3,"00ff00"],
 [5,-5,-5,5,5,-5,3,"00ff00"],
 [5,-5,5,5,5,5,3,"00ff00"],
 [5,5,-5,5,5,5,3,"00ff00"],
]


Octahedron:
Code: Select all
[
 [-5,0,0,0,-5,0,3,"00ff00"],
 [-5,0,0,0,5,0,3,"00ff00"],
 [-5,0,0,0,0,-5,3,"00ff00"],
 [-5,0,0,0,0,5,3,"00ff00"],
 [5,0,0,0,-5,0,3,"00ff00"],
 [5,0,0,0,5,0,3,"00ff00"],
 [5,0,0,0,0,-5,3,"00ff00"],
 [5,0,0,0,0,5,3,"00ff00"],
 [0,-5,0,0,0,-5,3,"00ff00"],
 [0,-5,0,0,0,5,3,"00ff00"],
 [0,5,0,0,0,-5,3,"00ff00"],
 [0,5,0,0,0,5,3,"00ff00"],
]


Dodecahedron:
Code: Select all
[
 [        5,       -5,        5,    3.09017,        0,  8.09017,   1, "ff5555" ],
 [        0,  8.09017,  3.09017,          5,        5,        5,   1, "55ff55" ],
 [       -5,        5,        5,   -3.09017,        0,  8.09017,   1, "5555ff" ],
 [       -5,        5,        5,          0,  8.09017,  3.09017,   1, "ffff00" ],
 [  3.09017,        0,  8.09017,          5,        5,        5,   1, "ff00ff" ],
 [  3.09017,        0,  8.09017,   -3.09017,        0,  8.09017,   1, "55ffff" ],
 [        0,  8.09017,  3.09017,          0,  8.09017, -3.09017,   1, "ff5555" ],
 [ -3.09017,        0,  8.09017,         -5,       -5,        5,   1, "55ff55" ],
 [        5,        5,        5,    8.09017,  3.09017,        0,   1, "5555ff" ],
 [       -5,        5,        5,   -8.09017,  3.09017,        0,   1, "ff00ff" ],
 [        0, -8.09017,  3.09017,         -5,       -5,        5,   1, "5555ff" ],
 [       -5,       -5,        5,   -8.09017, -3.09017,        0,   1, "ffff00" ],
 [        0, -8.09017,  3.09017,          5,       -5,        5,   1, "ffff00" ],
 [        0, -8.09017, -3.09017,          0, -8.09017,  3.09017,   1, "ff00ff" ],
 [        5,       -5,        5,    8.09017, -3.09017,        0,   1, "55ff55" ],
 [  8.09017, -3.09017,        0,    8.09017,  3.09017,        0,   1, "55ffff" ],
 [  8.09017, -3.09017,        0,    8.09017,  3.09017,        0,   1, "ffff00" ],
 [  8.09017,  3.09017,        0,          5,        5,       -5,   1, "ff00ff" ],
 [        0,  8.09017, -3.09017,          5,        5,       -5,   1, "55ffff" ],
 [        5,        5,       -5,    3.09017,        0, -8.09017,   1, "ff5555" ],
 [  8.09017, -3.09017,        0,          5,       -5,       -5,   1, "5555ff" ],
 [ -8.09017, -3.09017,        0,   -8.09017,  3.09017,        0,   1, "ff5555" ],
 [ -8.09017,  3.09017,        0,         -5,        5,       -5,   1, "55ff55" ],
 [       -5,        5,       -5,          0,  8.09017, -3.09017,   1, "5555ff" ],
 [        5,       -5,       -5,          0, -8.09017, -3.09017,   1, "ff5555" ],
 [       -5,       -5,       -5,   -8.09017, -3.09017,        0,   1, "55ffff" ],
 [       -5,       -5,       -5,   -8.09017, -3.09017,        0,   1, "55ffff" ],
 [       -5,        5,       -5,   -3.09017,        0, -8.09017,   1, "ffff00" ],
 [        5,       -5,       -5,    3.09017,        0, -8.09017,   1, "55ff55" ],
 [        0, -8.09017, -3.09017,         -5,       -5,       -5,   1, "5555ff" ],
 [  3.09017,        0, -8.09017,   -3.09017,        0, -8.09017,   1, "ff00ff" ],
 [ -3.09017,        0, -8.09017,         -5,       -5,       -5,   1, "ff5555" ],
]


Icosahedron:
Code: Select all
[
 [0,-5,-8.09016994375,0,5,-8.09016994375,3,"00ff00"],
 [0,-5,-8.09016994375,-5,-8.09016994375,0,3,"00ff00"],
 [0,-5,-8.09016994375,5,-8.09016994375,0,3,"00ff00"],
 [0,-5,-8.09016994375,-8.09016994375,0,-5,3,"00ff00"],
 [0,-5,-8.09016994375,8.09016994375,0,-5,3,"00ff00"],
 [0,-5,8.09016994375,0,5,8.09016994375,3,"00ff00"],
 [0,-5,8.09016994375,-5,-8.09016994375,0,3,"00ff00"],
 [0,-5,8.09016994375,5,-8.09016994375,0,3,"00ff00"],
 [0,-5,8.09016994375,-8.09016994375,0,5,3,"00ff00"],
 [0,-5,8.09016994375,8.09016994375,0,5,3,"00ff00"],
 [0,5,-8.09016994375,-5,8.09016994375,0,3,"00ff00"],
 [0,5,-8.09016994375,5,8.09016994375,0,3,"00ff00"],
 [0,5,-8.09016994375,-8.09016994375,0,-5,3,"00ff00"],
 [0,5,-8.09016994375,8.09016994375,0,-5,3,"00ff00"],
 [0,5,8.09016994375,-5,8.09016994375,0,3,"00ff00"],
 [0,5,8.09016994375,5,8.09016994375,0,3,"00ff00"],
 [0,5,8.09016994375,-8.09016994375,0,5,3,"00ff00"],
 [0,5,8.09016994375,8.09016994375,0,5,3,"00ff00"],
 [-5,-8.09016994375,0,5,-8.09016994375,0,3,"00ff00"],
 [-5,-8.09016994375,0,-8.09016994375,0,-5,3,"00ff00"],
 [-5,-8.09016994375,0,-8.09016994375,0,5,3,"00ff00"],
 [-5,8.09016994375,0,5,8.09016994375,0,3,"00ff00"],
 [-5,8.09016994375,0,-8.09016994375,0,-5,3,"00ff00"],
 [-5,8.09016994375,0,-8.09016994375,0,5,3,"00ff00"],
 [5,-8.09016994375,0,8.09016994375,0,-5,3,"00ff00"],
 [5,-8.09016994375,0,8.09016994375,0,5,3,"00ff00"],
 [5,8.09016994375,0,8.09016994375,0,-5,3,"00ff00"],
 [5,8.09016994375,0,8.09016994375,0,5,3,"00ff00"],
 [-8.09016994375,0,-5,-8.09016994375,0,5,3,"00ff00"],
 [8.09016994375,0,-5,8.09016994375,0,5,3,"00ff00"],
]
Join a National Hang Gliding Organization: US Hawks at ushawks.org
View my rating at: US Hang Gliding Rating System
Every human at every point in history has an opportunity to choose courage over cowardice. Look around and you will find that opportunity in your own time.
Bob Kuczewski
User avatar
Contributor
Contributor
 
Posts: 8374
Joined: Fri Aug 13, 2010 2:40 pm
Location: San Diego, CA

Re: Simple (and Primitive) 3D Rendering Program

Postby Bob Kuczewski » Wed May 22, 2024 11:13 pm

I came across this topic while looking at the 3D Predator Model that we've been building with Chris.

The simple and primitive JavaScript 3-D rendering program of this topic works pretty well ... for rendering. But it's not easy to generate the points needed to actually build a model. It dawned on me tonight that it might not be too hard to provide a graphical interface to make that much easier. The phrase "not too hard" might mean several days of dedicated programming time (which I don't have right now), but I hope I can find the time somewhere in the near future.

The basic idea would borrow from Blender's "3D Cursor". The 3D Cursor is just a point in 3D space that you can see and adjust from any angle. The simple interface could implement 2 separate 3D cursors used to define lines. This could make it much easier to draw in 3D.

When you are looking at the 3D Cursor (from any angle) on a 2D screen, you are seeing a projection of that cursor into a 2D plane. You cannot really see the "depth" of the 3D Cursor, but it still has a "depth" in that view that will be preserved. In other words, your mouse clicks will only change the 3D Cursor's location in the plane that you are viewing. The depth (which is perpendicular to the viewing angle) will be the same wherever you click to move the Cursor. To change the "depth" of the 3D Cursor requires a different perspective where the former "depth" axis is now parallel to the 2D plane.

This is most easily imagined if there are only 3 orthogonal viewing angles: looking down the Z axis at the X-Y plane, looking down the Y axis at the X-Z plane, and looking down the X axis at the Y-Z plane. If the 3D Cursor starts at (0,0,0), and you're looking down the Z axis, then any clicks will change the cursor's location in the X-Y plane. It's Z coordinate will remain at 0. But if you then view from the Y axis, you will be looking at the X-Z plane. So moving the 3D Cursor in that view might change the Z coordinate and/or the X coordinate.

This is really just the standard orthogonal viewing system that has been around in drafting for centuries. It's in almost all 3D design programs. So there's nothing new here. But it does seem to be a way to program a 3D interface in Javascript that might not be too hard to actually build.
Join a National Hang Gliding Organization: US Hawks at ushawks.org
View my rating at: US Hang Gliding Rating System
Every human at every point in history has an opportunity to choose courage over cowardice. Look around and you will find that opportunity in your own time.
Bob Kuczewski
User avatar
Contributor
Contributor
 
Posts: 8374
Joined: Fri Aug 13, 2010 2:40 pm
Location: San Diego, CA

Re: Simple (and Primitive) 3D Rendering Program

Postby Bob Kuczewski » Sun Jun 30, 2024 7:51 pm

As mentioned in the previous post, I decided to write a program (translation: modify an existing program) to make it a little easier to enter models (at least not needing to type them in!). You can find my first attempt at:

      https://ushawks.org/designer/object_builder.htm

That program has a lot of "clunkiness" (and probably a few bugs), but it mostly works, and it might help anyone looking for a quick way to sketch something in 3D without downloading anything or even learning too much. Here's what it basically looks like:

3D_Object_Builder_67pct.png
3D_Object_Builder_67pct.png (105.74 KiB) Viewed 475 times


General Description

There are 4 viewing panels at the top. The upper left shows a view from the front (looking at the x-z plane along the y axis). The upper right shows a view from the right side (looking at the y-z plane along the x axis). The lower left shows a view from the top (looking down at the x-y plane along the z axis). And finally, the lower right shows the 3D view which can be rotated to any angle (using a pitch/yaw interaction). The model can be edited by adding, moving, and removing points and lines in the first 3 viewing panels (x-y, x-z, y-z). No editing can be done in the 3D window, and it is only for viewing.

There are currently 6 modes of operation: View Only, Add Points, Add Lines, Move Points, Delete Points, and Delete Lines. These are all selected by the drop down box that starts out as "View Only" (light green).

The basic idea is that you start by adding points, then connect the points to make the line segments that define the drawing (essentially a mesh of points and line segments). Once the line segments are connected to points, moving the points will move the line segments.

As you create each line segment, ("Add Line"), the new line will be drawn with the color and size specified by the "Color" and "Size" boxes. The color is the typical red, green, blue specified in hex. Each hex digit can go from 0 to F, and each color has 2 digits. So full red would be FF0000. The two "F" values specify the red. The next two zeros are the green, and the last two are the blue. The size value is somewhat relative. In most cases, a small value (less than 1) is best, and you can experiment with it to see what looks best. While you can easily move the lines by moving the points, you cannot easily change any other line attributes (like color or thickness). To change color or thickness, you will have to delete the line segment, change the color and thickness values, and then recreate the line. You can also change these (and any other values) by manually editing the segments file described below.

To the right of the Size box are 3 viewing settings to show Points, show Axes, and show with X Mirrored. The "Show Points" just shows or hides the little round circles at each point. The "Show Axes" shows or hides the small set of axes at the origin (red=x, green=y, and blue=z). The "Mirror X" is handy for making symmetrical objects because you only have to add points and lines on one half of the model, and the program will duplicate them on the opposite side of the y-z plane (along the x axis). This is especially handy for making hang gliders!

The second row of buttons and fields control the viewing. There are buttons to view from the Front, Top, and Side. There are also Az, El, and Zoom fields that can be entered for a specific view. There's also a Line thickness field which will increase or decrease the line thickness for all lines in the view.

The third row of buttons are related to the segment definitions that make up the model. The segments are shown in the text box below that row of buttons. The segments represent the model, and if you want to save a model, just copy that text and paste it into any application that lets you save and open it again.

The segment file format is very simple. Each segment line consists of two points where each point has an x, y, and z value. So 2 points is 6 values. Each line also has its own "thickness" (value 7) and color (value 8). There's a quick reminder of this format below the text entry box for the segments. All values are separated by commas. Each line segment specification is enclosed in a pair square brackets ( [ ] ), and the whole list of line segments is also enclosed in a pair or square brackets ( [ ] ). There must also be a comma after the closing square bracket of each segment. This is compliant with the common "JSON" format used in many other aspects of computer programming.

Modes of Operation

Here are the details of each mode of operation:

  • View Only - As implied, this mode doesn't let you do any screen editing. You can move the view in the 3D window by clicking and dragging. You can also change the model through the buttons, but not by clicking in the view panels. It's a good idea to be in this mode to keep from accidentally clicking and adding or deleting lines and points. There is no "undo" capability in this program!
     
  • Add Points - This mode enables adding points by clicking in any of the 3 fixed windows (x-y, x-z, or y-z). Points cannot be added to the 3D view. When you click, a new point will be added and it will be visible in all 4 views.
     
  • Add Lines - This mode enables adding lines by clicking on a start point and end point for each line. The points must already exist, and the program will choose the two points closest to where you clicked. There is no reminder of whether you've clicked or not, so it's easy to get confused. Be careful, and be sure to make 2 clicks (start and end) for each line segment. If you click twice and don't see any lines, check on the visibility (width and color) to be sure that the line will be thick and bright enough to see.
     
  • Move Points - This mode enables moving existing points by clicking and dragging. As with all other editing modes, this does not work in the 3D viewing window, but the results can be seen in the 3D view. Just click each point, and drag it to a different location. All of the attached lines will follow.
     
  • Delete Points - This mode enables deleting points by clicking on them. This will delete the nearest point to the location that was clicked - even if it is very far away. This makes it pretty easy to delete a lot of points by just rapidly clicking anywhere in the window. Any lines attached will also be deleted, so be careful.
     
  • Delete Lines - This mode enables deleting lines without deleting points. Deleting a single line requires two mouse clicks - one on each end of the line. As with deleting points, the program will find the nearest points to each click - even if they are far away. So be careful.

Saving and Loading

There is no "cloud storage" associated with this program. You have to save your own work by hand. This is done with the "Make Segment File" button that will copy all of your points and lines into a text box that you can use to copy into other storage locations (typically a text file on your computer). When you click the "Make Segment File" button, it will generate the segment file data in the text box. Similarly, you can restore the data to the drawing panels by clicking the "Load Segment File" button. It will read the text in the box and decode it into a drawing. Note that this can be used to temporarily store and restore your work. It's not quite as good as an "undo" button, but it's close. When you have something you like, just click the "Make Segment File" button, and it will hold a copy of that version. You can easily restore it with the "Load Segment File" button. But if you've done a lot of work, it's best to keep a copy somewhere else as well.

In addition to the "Make Segment File" and "Load Segment File" buttons, there are also "Align" and "lines.obj" buttons. The "Align" button simply aligns the columns in the list of segments to make them easier to read. The "lines.obj" button creates a pop-up dialog box with all of the points and lines represented in "OBJ" format. This is a fairly standard 3D drawing format, and it will allow you to import your work into other 3D drawing programs. However, the color and thickness of your lines is not stored in the .OBJ format, so don't use that as your only storage mechanism.

Examples

The last part of the page is for examples. These are best loaded by using the drop down selector and the "Load Selected Example" button. That procedure ensures that any additional viewing settings (scaling scaling and mirroring) are consistent with the example being loaded. Examples can also be loaded into the text area with the "Load" button beside each example. But the "Load" buttons may use the wrong display settings, so it's better to use the "Load Selected Example" button in most cases.

Sharing

One of the nice features of this program is that you can easily share models just by copying the text and pasting it into a post here on U.S. Hawks or anywhere else. Just give a link to the program (https://ushawks.org/designer/object_builder.htm) so people can find it and paste in your design. The format is actually a bit redundant (points are repeated), but it's easy to write without keeping track of indexes between points and lines as needed in other formats (like .OBJ). For example, here's a dodecahedron rendered in this program from the code in an earlier post to this topic:

dodecahedron.png
dodecahedron.png (17.19 KiB) Viewed 475 times


Working Off-Line

While this program is conveniently available on-line, note that it can also be used off-line by downloading the page to your local computer. Most browsers have a way to save a page (usually named something like "Save Page As..."). Then you can open it and use it whether you're connected to the Internet or not.
Join a National Hang Gliding Organization: US Hawks at ushawks.org
View my rating at: US Hang Gliding Rating System
Every human at every point in history has an opportunity to choose courage over cowardice. Look around and you will find that opportunity in your own time.
Bob Kuczewski
User avatar
Contributor
Contributor
 
Posts: 8374
Joined: Fri Aug 13, 2010 2:40 pm
Location: San Diego, CA

Previous
Forum Statistics

Who is online

Users browsing this forum: No registered users and 8 guests

Options

Return to Technology Forum