LDraw.org Discussion Forums
LDraw Torus Generator - Printable Version

+- LDraw.org Discussion Forums (https://forums.ldraw.org)
+-- Forum: LDraw Programs (https://forums.ldraw.org/forum-7.html)
+--- Forum: Parts Author Tools (https://forums.ldraw.org/forum-24.html)
+--- Thread: LDraw Torus Generator (/thread-22187.html)

Pages: 1 2 3 4


LDraw Torus Generator - Kevin - 2017-06-06

UPDATE:  To save scrolling all the way through this thread, here is the latest version of my LDraw Torus Generator, converted to a web page and hosted on the Google Cloud Platform:  http://ldtorgen.appspot.com/

-----

I've been using 3D arrows for a while in the instructions I create, assembling the components from LDraw primitives.  Recently I've wanted to create curved arrows, but I've found there aren't enough existing LDraw torus primitives to give me the fine control over the major and minor radii that I need.  And there are even fewer high-definition torus primitives--necessary to create smoothly-curved arrows when rendering with POV-Ray. 

I built a simple spreadsheet to generate the specific torus sections I needed, then generalized it to make it more useful.  I've uploaded the spreadsheet to Google Docs so that anyone can use it.  It generates the quadrilaterals and all conditional lines for each section.  

LDraw Torus Generator


Simply enter the number of sections in a full torus (LDraw uses 16 for low-def and 48 for high-def), the major radius (the radius of the full torus), and the minor radius (radius of a cross-section) in the green cells.  The spreadsheet generates a complete .dat file with a file name consistent with the LDraw torus naming standard.  Then copy the blue cells to a file in your LDraw directory or a new model in your MPD file.

The torus segments are generated with 16-sided cross sections aligned for compatibility with existing disc and edge primitives.  This has provided sufficient resolution for my purposes, even with POV-Ray rendering.  I may expand to include 48-sided cross sections in the next iteration.

To generate a complete arrow, you will need to copy and rotate the torus segment to build the desired arc, then add a cone, two discs, and three circles of edges.  

   

I'd appreciate any feedback or recommendations for improvements.

Thank you.


Kevin


RE: LDraw Torus Generator - Magnus Forsberg - 2017-06-06

How is this different from ToriCalc and PrimGen2 ?


RE: LDraw Torus Generator - Kevin - 2017-06-06

(2017-06-06, 16:19)Magnus Forsberg Wrote: How is this different from ToriCalc and PrimGen2 ?

Aside from being more limited in scope, apparently not much.  :-)

I could have saved myself a couple hours of work if I'd known about those beforehand.


RE: LDraw Torus Generator - Magnus Forsberg - 2017-06-06

Sorry, didn't mean to spoil the fun....

But, I think it could be useful to have anyway. It creates a mixed resolution lo/high-primtives. Right?
I sometimes want to have a "primitive" with the minor radius in normal resolution (16-sided) and the major radius in hi-res (48-sided).
This seams to be impossible do in PrimGen2.


RE: LDraw Torus Generator - Kevin - 2017-06-07

(2017-06-06, 21:17)Magnus Forsberg Wrote: Sorry, didn't mean to spoil the fun....

But, I think it could be useful to have anyway. It creates a mixed resolution lo/high-primtives. Right?
I sometimes want to have a "primitive" with the minor radius in normal resolution (16-sided) and the major radius in hi-res (48-sided).
This seams to be impossible do in PrimGen2.

No worries.  The fun was creating the spreadsheet in the first place.

Yes, that's exactly what it does.  I found that hexadecagons were good enough for the cross section of my tori, but I needed the higher resolution around the major radius.  The arrows in the example I posted had only 2 segments at low resolution.  At high resolution they have 6, and that is enough to smooth them out.

Thanks!

Kevin


RE: LDraw Torus Generator - Philippe Hurbain - 2017-06-07

I too would like to see mixed mode tori! I often needed them. I propose to create a new kind of tori, with a file name beginning with tm instead of t (the rest of the nomenclature beeing the same) and place them in the \48 folder. What others think of this? To make this really fly, we need an update of primgen2 (Mike, Nils?) though Kevin tool can be used in the meantime, and some primitive substitution support by LDView (Travis?)


RE: LDraw Torus Generator - Kevin - 2017-06-07

(2017-06-07, 7:06)Philippe Hurbain Wrote: I too would like to see mixed mode tori! I often needed them. I propose to create a new kind of tori, with a file name beginning with tm instead of t (the rest of the nomenclature beeing the same) and place them in the \48 folder. What others think of this? To make this really fly, we need an update of primgen2 (Mike, Nils?) though Kevin tool can be used in the meantime, and some primitive substitution support by LDView (Travis?)

I updated my Google Doc sheet to use your suggested "tm" prefix.  I think that makes the "48" redundant in the filename (though I haven't removed it yet). 

Perhaps the new standard could be simply tmi####.dat, tmo####.dat, and tmq####.dat.  That would leave one extra character (assuming a desire to adhere to 8.3 filenames) that could potentially be used for some other piece of information--perhaps a count of 1/48 slices with specific letters to describe 12-, 16-, 24-, and 48-slice tori.

Kevin


RE: LDraw Torus Generator - Philippe Hurbain - 2017-06-07

(2017-06-07, 7:36)Kevin Wrote:
(2017-06-07, 7:06)Philippe Hurbain Wrote: I too would like to see mixed mode tori! I often needed them. I propose to create a new kind of tori, with a file name beginning with tm instead of t (the rest of the nomenclature beeing the same) and place them in the \48 folder. What others think of this? To make this really fly, we need an update of primgen2 (Mike, Nils?) though Kevin tool can be used in the meantime, and some primitive substitution support by LDView (Travis?)

I updated my Google Doc sheet to use your suggested "tm" prefix.  I think that makes the "48" redundant in the filename (though I haven't removed it yet). 

Perhaps the new standard could be simply tmi####.dat, tmo####.dat, and tmq####.dat.  That would leave one extra character (assuming a desire to adhere to 8.3 filenames) that could potentially be used for some other piece of information--perhaps a count of 1/48 slices with specific letters to describe 12-, 16-, 24-, and 48-slice tori.

Kevin
Sticking with 8.3 is no longer a requirement... 48 in filename remains needed if the new tori are to go in p\48 folder


RE: LDraw Torus Generator - Magnus Forsberg - 2017-06-07

OK, we need this, but then the header needs more tweaking.

The naming of torus primitives are tricky. A correct name would be:  48/tm48q?????.dat
The parttype should be: Unofficial_48_Primitive.
It should have a BFC statement:  0 BFC CERTIFY CCW
A scalable primitive must have four decimals on every x/y/z value.

OK, maybe I'm nitpicking, but these changes would make it usable.


RE: LDraw Torus Generator - Kevin - 2017-06-08

(2017-06-07, 21:18)Magnus Forsberg Wrote: OK, we need this, but then the header needs more tweaking.

The naming of torus primitives are tricky. A correct name would be:  48/tm48q?????.dat
The parttype should be: Unofficial_48_Primitive.
It should have a BFC statement:  0 BFC CERTIFY CCW
A scalable primitive must have four decimals on every x/y/z value.

OK, maybe I'm nitpicking, but these changes would make it usable.

Thanks for the additional feedback.  I have made the requested changes:

1) If the sections per circle is 48 or greater, "48\" is prepended to the name, and "_48" is inserted into the parttype. 
2) Added support for "unit" in the file name when the minor radius = 1
3) I corrected and verified the CCW winding for all quadrilaterals and added the BFC statement.
4) I have expanded the precision to 4 decimal places but allow truncation of trailing zeros for quads and edges.

Right now it only generates q-type tori.  Would it be useful to add i-, o-, and r- types as well?

Kevin