... | ... | @@ -782,3 +782,106 @@ Creates a mesh from ```shape``` using the marching cubes algorithm. Before calcu |
|
|
|
|
|
* ```shape```: input shape
|
|
|
* ```voxSize```: voxel size of space discretization (in mm)
|
|
|
|
|
|
## From Asset
|
|
|
```svg_ex(file,dpi)```
|
|
|
|
|
|
Extracts contours out of a SVG file. Returns a table of ```SVGContour``` objects.
|
|
|
* ```file```: input svg file
|
|
|
* ```dpi```: dots per inch. Use 90 for Inkscape files
|
|
|
The ```SVGContour``` object has the following members:
|
|
|
* ```outline```: The contour '''(table)'''
|
|
|
* ```fill ```: fill color for the contour '''(triplet)'''
|
|
|
* ```stroke```: stroke color for the contour '''(triplet)'''
|
|
|
* ```strokeWidth```: stroke width for the contour '''(num)'''
|
|
|
* ```hasFill```: contour is color-filled '''(bool)'''
|
|
|
* ```hasStroke```: contour is color-bordered '''(bool)'''
|
|
|
|
|
|
<table>
|
|
|
<tr>
|
|
|
<td>
|
|
|
|
|
|
```lua
|
|
|
svg_shapes = svg_ex('restroom.svg',90)
|
|
|
for i,contour in pairs(svg_shapes) do
|
|
|
if contour:hasFill() then
|
|
|
set_brush_color(i, contour:fill()[1], contour:fill()[2], contour:fill()[3])
|
|
|
end
|
|
|
emit(linear_extrude(v(0,0,5),contour:outline()), i)
|
|
|
end
|
|
|
```
|
|
|
|
|
|
</td>
|
|
|
<td>
|
|
|
<img src="uploads/434f1733f99e33e71f3666761209ade6/Example_svg_ex.png" width="200">
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table>
|
|
|
|
|
|
```font(ttf)```
|
|
|
|
|
|
Creates a font object based on the font described in the TrueType Font file ```ttf```.
|
|
|
* ```ttf```: TrueType Font file
|
|
|
The interface to the font object is the following:
|
|
|
* ```str(string, tracking)``` : Returns a 3D geometry of the string ```string```. If present, the font's [kerning](https://en.wikipedia.org/wiki/Kerning) information is added to ```tracking``` [tracking](https://en.wikipedia.org/wiki/Letter-spacing tracking).
|
|
|
|
|
|
<table>
|
|
|
<tr>
|
|
|
<td>
|
|
|
|
|
|
```lua
|
|
|
f = font(Path .. 'LiberationMono-Regular.ttf')
|
|
|
text = f:str('IceSL', 10)
|
|
|
emit(scale(0.5,0.5,10) * text)
|
|
|
```
|
|
|
|
|
|
</td>
|
|
|
<td>
|
|
|
<img src="uploads/4b1fa3e9b2e4de82b33e286f1a2aaa4d/Example_font.jpg" width="200">
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table>
|
|
|
|
|
|
```load_raw_voxels(fileName, thicken)```
|
|
|
|
|
|
Creates a shape out of raw voxel data in ```fileName```. ```thicken``` stands for the thickening applied to the voxels.
|
|
|
* ```fileName```: input file
|
|
|
* ```thicken```: thickening of voxels
|
|
|
The format of the file is a continuous chunk of voxels with the following information in sequence:
|
|
|
1. Position (3 ints)
|
|
|
2. Normal (3 floats)
|
|
|
3. Color (3 unsigned chars)
|
|
|
4. State (1 bool)
|
|
|
|
|
|
## Distribute
|
|
|
Additionally to changing the representations of a shape, IceSL also provides a function to calculate an evenly distributed set of points covering a surface. For each point this function also reports its surface normal and maximum distance to the set of nearest points.
|
|
|
|
|
|
```distribute(shape, density)```
|
|
|
|
|
|
Returns a Lua array describing the surface of ```shape``` using [Voronoid Iteration](https://en.wikipedia.org/wiki/Lloyd%27s_algorithm). The array is made out of triplets wherein the first element is a position of the surface, the second its surface normal and the third its distance to the furthest neighboring position in the array. How sparse the positions are is determined by the argument ```density```.
|
|
|
|
|
|
* ```shape```: input shape
|
|
|
* ```density```: position density. This argument is clamped to the unit interval where ```1``` signifies high density and ```0``` no density
|
|
|
|
|
|
<table>
|
|
|
<tr>
|
|
|
<td>
|
|
|
|
|
|
```lua
|
|
|
shape = cube(10)
|
|
|
s = distribute(shape, 0.2)
|
|
|
centroids = {}
|
|
|
for i = 1,#s,1 do
|
|
|
centroids[i] = translate(s[i][1]) * frame(s[i][2]) *
|
|
|
union{ cone(s[i][3],0,1), mirror(Z) * cone(s[i][3],0,1) }
|
|
|
end
|
|
|
emit(merge(centroids))
|
|
|
|
|
|
```
|
|
|
|
|
|
</td>
|
|
|
<td>
|
|
|
<img src="uploads/d1b3017bdeac39f7162c26f9ea279795/Example_distribute.png" width="200">
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table> |
|
|
\ No newline at end of file |