Welcome to Fractal Forums

Fractal Software => Structure Synth => Topic started by: barcud on October 23, 2017, 02:20:10 PM




Title: Exporting non-uniform scaled spheres and cylinders from Structure Synth
Post by: barcud on October 23, 2017, 02:20:10 PM
OK - here is something I've been playing with.
Structure Synth can't squash spheres or use cylinders.
So I wrote an export template which will give me the transformation matrices for my objects -convert them via a web page using three.js and export and object and material file.
Problem is that Structure Synth only exports the full transformation matrix for boxes.
So here is the script I used for the images:
balls
Code:
{y 12}cyl
{x 12}cyl2
{x -12}cyl3
{y -12}boxes
rule balls md 12 {
{z 0.4 s 6 12 0.3 h -80 sat 0.8}box::ball
{ s 0.8 0.9 1.4 rz 90 h 20}balls
}
rule cyl md 12 {
1 * {z 0.3 s 12 6 0.3 h 80 sat 0.8} 1 *{rx 90}box::cyl
{ s 0.7 0.9 1.4 rz 90 h 20}cyl
}
rule cyl2 md 12 {
1 * {z 0.3 s 12 6 0.3 h 80 sat 0.8} 1 *{ry 90}box::cyl
{ s 0.7 0.9 1.4 rz 90 h 20}cyl2
}
rule cyl3 md 12 {
1 * {z 0.3 s 12 6 0.3 h 80 sat 0.8} 1 *{rz 90}box::cyl
{ s 0.7 0.9 1.4 rz 90 h 20}cyl3
}
rule boxes md 12 {
{z 0.2 s 6 12 0.1 h -80 sat 0.8}box
{ s 0.7 0.9 1.4 rz 90 h 20}boxes
}
and the export template is:
Code:
<template defaultExtension="Matrix (*.txt)" name="MatrixBSC">
<description>
Exports matrix to create squashed spheres and cylinders using conversion
</description>
<primitive name="begin"><![CDATA[]]></primitive>
<primitive name="end"><![CDATA[]]></primitive>
<primitive name="box"><![CDATA[box
{matrix}
{r} {g} {b} {oneminusalpha}
]]></primitive>
<primitive name="box::ball"><![CDATA[sphere
{matrix}
{r} {g} {b} {oneminusalpha}
]]></primitive>
<primitive name="box::cyl"><![CDATA[cylinder
{matrix}
{r} {g} {b} {oneminusalpha}
]]></primitive>
</template>
This will result in a text file which has the object (sphere, box, cylinder) and the full transformation matrix + color info.
This file can be uploaded to a web page and produces the second image (colours are not rendered nicely but it is more about the geometries here).
Pressing "export" will create an .obj and .mtl file which can then be imported into a 3D program of your choice and rendered.
Yes - it is not that straight forward and the preview in Structure Synth is not that helpful but hey - it's a start.
Is there any interest in the converter web page?
All the conversion is done locally on your computer using javascript - there is no data transfer to a server involved - just matrix operations using three.js and an object exporter.
Exporting 1500 round objects takes about 10 seconds during which the web page is unresponsive.

Let me know what you think and/or if that is of interest to anybody.


Title: Re: Exporting non-uniform scaled spheres and cylinders from Structure Synth
Post by: barcud on October 23, 2017, 05:41:03 PM
If somebody actually wants to try it - copy the template from above and save it to the template folder.
Then take the script and run it - remember - the Structure Synth preview will only show boxes.
Export using the new template - this will result in a txt file.

Go to http://matrixconverter4structuresynth.created-by.me/converter.html (http://matrixconverter4structuresynth.created-by.me/converter.html)  and load the text file.
There in the preview you will see the spheres and cylinders.
Export to object will save the converted geometries in the download folder.

Nothing is actually transmitted to the server. The web page load three.js and a couple of helpers and all the conversion is done locally in your browser.

I have exported 2000 spheres but the obj file will be about 200MB - so be careful - start slowly.
The web page will be unresponsive during the export time - it takes usually about 10seconds for 1000 spheres.

This is a alpha version of the converter - nothing should go wrong but if it does let me know.