... | ... | @@ -884,4 +884,231 @@ emit(merge(centroids)) |
|
|
<img src="uploads/d1b3017bdeac39f7162c26f9ea279795/Example_distribute.png" width="200">
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table> |
|
|
\ No newline at end of file |
|
|
</table>
|
|
|
|
|
|
# Other Functionality
|
|
|
## Printing setttings
|
|
|
It is possible for custom printing settings to be shown and modified in IceSL's UI. Currently there is support for two types of settings; booleans and numbers. The following two definitions can be used in file ```features.lua``` of a printer profile:
|
|
|
|
|
|
```add_checkbox_setting(internal_name, description, tooltip)```
|
|
|
|
|
|
```add_setting(internal_name, description, minVal, maxVal, tooltip)```
|
|
|
|
|
|
Adds setting ```internal_name``` with ```description```, minimum value ```minValue``` and maximum value ```maxValue```. Default value is ```false``` for ```add_checkbox_setting``` and ```minValue``` for ```add_setting```:
|
|
|
* ```internal_name``` : internal name for setting
|
|
|
* ```description``` : description of setting (shown in UI)
|
|
|
* ```minValue``` : minimal value in case of a number setting (i.e., ```add_setting```)
|
|
|
* ```maxValue``` : maximum value in case of a number setting (i.e., ```add_setting```)
|
|
|
* ```tooltip``` : tooltip help to show in IceSL's UI. This parameter is '''optional'''.
|
|
|
|
|
|
|
|
|
The setting's value can then be queried in file ```printer.lua``` of the printer profile by using the setting's ```internal_name```.
|
|
|
|
|
|
Scripts also have the ability to change printing settings directly from within them. This allows the user (among other reasons) to specify printing settings tailored to the geometry being described in the script.
|
|
|
|
|
|
IceSL gives priority to an assignment of a printing setting according to the following list:
|
|
|
1. Default IceSL values -- ''bottom priority''
|
|
|
2. Printer features (i.e., ```features.lua``` in printer profiles)
|
|
|
3. Print profile (e.g., fast print, high quiality, etc.)
|
|
|
4. Material profile (e.g., abs, pla, etc.)
|
|
|
5. Lua script
|
|
|
6. User interface -- ''top priority''
|
|
|
|
|
|
For example, if the value of a setting is specified in a printer profile as well as in the lua script, the latter takes priority. Moreover, if the user sets it manually using the UI then this overrides all other assignements.
|
|
|
|
|
|
```set_setting_value(setting, value)```
|
|
|
|
|
|
Sets the printing parameter ```settings``` to ```value```
|
|
|
* ```setting```: Internal name of the printing setting to change
|
|
|
* ```value```: Value to assign. May be a boolean, a number, a string or a table. The latter is reserved to ''per-layer'' assignments whereas the table is to be constructed as follows:
|
|
|
** ```{ [key_0]=value_0, ... , [key_n]=value_n }```
|
|
|
|
|
|
```set_setting_value(setting, tex3d, boxMin, boxMax)```
|
|
|
|
|
|
Sets the printing parameter ```setting``` as a ''field'' that extends from ```boxMin``` to ```boxMax``` with values from ```tex3d```
|
|
|
* ```setting```: Internal name of the printing setting to change
|
|
|
* ```tex3d```: Value of the field as a 3d texture
|
|
|
* ```boxMin,boxMax```: Field extent
|
|
|
|
|
|
## Variable caching
|
|
|
It is possible to turn on/off variable caching in IceSL with the system variable ```enable_variable_cache```. Variable caching is useful when editing a script that constructs an object or preforms a calculation that is CPU intensive (i.e. consumes significant time).
|
|
|
|
|
|
In the following example it is possible to change the scaling of ```mesh``` without incurring in the penalty of re-calculating the result of ```to_mesh```:
|
|
|
|
|
|
<table>
|
|
|
<tr>
|
|
|
<td>
|
|
|
|
|
|
```lua
|
|
|
enable_variable_cache = true
|
|
|
s = sphere(10)
|
|
|
if not mesh then
|
|
|
mesh = to_mesh(s,1)
|
|
|
end
|
|
|
emit(scale(1) * mesh)
|
|
|
```
|
|
|
|
|
|
</td>
|
|
|
<td>
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table>
|
|
|
|
|
|
## Tweaks
|
|
|
```ui_scalar(name, default, min, max)```
|
|
|
|
|
|
Creates a sliding bar to interactively set a float value between ```min``` and ```max```.
|
|
|
* ```name```: the sliding bar's name
|
|
|
* ```default```: default value
|
|
|
* ```min```: minimum value
|
|
|
* ```max```: maximum value
|
|
|
|
|
|
<table>
|
|
|
<tr>
|
|
|
<td>
|
|
|
|
|
|
```lua
|
|
|
r = ui_scalar("Radius",10,1,20)
|
|
|
emit(sphere(r))
|
|
|
```
|
|
|
|
|
|
</td>
|
|
|
<td>
|
|
|
<img src="uploads/e942eccb69903c2991560051674b463f/Example_tweaks.png" width="200">
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table>
|
|
|
|
|
|
## Fields
|
|
|
Fields are UI objects for interactively building 3D textures. They are useful for carving, sculpting and specifying surfaces among other things.
|
|
|
|
|
|
```ui_field(name, boxMin, boxMax)```
|
|
|
|
|
|
Creates a labeled button to build a 3D texture in the box space specified by ```boxMin``` and ```boxMax```.
|
|
|
* ```name```: field name
|
|
|
* ```boxMin```: left corner of the 3D texture
|
|
|
* ```boxMax```: right corner of the 3D texture
|
|
|
|
|
|
```ui_field_value_at(name, p)```
|
|
|
|
|
|
Retrieves the value of the field ```name``` (created by ```ui_field```) at position ```p```.
|
|
|
* ```name```: field name
|
|
|
* ```p```: position to inquire
|
|
|
|
|
|
```ui_file(fileName)```
|
|
|
|
|
|
Creates a UI to load/save all the script's tweaks and field values from/into ```fileName```.
|
|
|
|
|
|
* ```fileName```: file path to load/save tweaks and fields values
|
|
|
|
|
|
The following example sculpts a sphere using a field named ```Sculpting``` and saves the field values into the file ```sculpt.xml```
|
|
|
|
|
|
<table>
|
|
|
<tr>
|
|
|
<td>
|
|
|
|
|
|
```lua
|
|
|
s = sphere(10)
|
|
|
bx = bbox(s)
|
|
|
bx:enlarge(1)
|
|
|
f = ui_field('Sculpting',bx:min_corner(),bx:max_corner())
|
|
|
ui_file(Path..'sculpt.xml')
|
|
|
result = intersection(s,to_voxel_solid(f,bx:min_corner(),bx:max_corner()))
|
|
|
emit(result)
|
|
|
```
|
|
|
|
|
|
</td>
|
|
|
<td>
|
|
|
<img src="uploads/30f7f0ead3f449befc9d5fe67b5b0d96/Example_fields.png" width="200">
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table>
|
|
|
|
|
|
In the next example, we use a field to avoid distributing (i.e. function ```distribute```) parts of the shape surface.
|
|
|
|
|
|
<table>
|
|
|
<tr>
|
|
|
<td>
|
|
|
|
|
|
```lua
|
|
|
enable_variable_cache = true
|
|
|
shape = sphere(10)
|
|
|
if not s then
|
|
|
s = distribute(shape, 0.5)
|
|
|
end
|
|
|
bx = bbox(shape)
|
|
|
bx:enlarge(1)
|
|
|
f = ui_field('surface', bx:min_corner(),bx:max_corner())
|
|
|
cubes = {}
|
|
|
for i = 1,#s do
|
|
|
if ui_field_value_at('surface', s[i][1]) > 0.5 then
|
|
|
cubes[#cubes+1] = translate(s[i][1]) * frame(s[i][2]) * ccube(s[i][3])
|
|
|
end
|
|
|
end
|
|
|
emit(union(shape,merge(cubes)))
|
|
|
```
|
|
|
|
|
|
</td>
|
|
|
<td>
|
|
|
<img src="uploads/3e2d7dde362967adb094ef5328aac543/Example_fields2.png" width="200">
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table>
|
|
|
|
|
|
## Mesh Information
|
|
|
|
|
|
```bbox(shape)```
|
|
|
|
|
|
Returns the bounding box of ```shape``` as an object ```AAB```.
|
|
|
* ```shape```: Input shape
|
|
|
The ```AAB``` object has the following members:
|
|
|
* ```min_corner```: Minimum corner of the bounding box '''(vector)'''
|
|
|
* ```max_corner```: Maximum corner of the bounding box '''(vector)'''
|
|
|
* ```center```: Center of the bounding box '''(vector)'''
|
|
|
* ```extent```: Dimensions of the bounding box '''(vector)'''
|
|
|
* ```empty```: Boolean value indicating whether the bounding box is '''(bool)'''
|
|
|
* ```enlarge(mm)```: Enlarges the box by ```mm``` millimeters '''(method)'''
|
|
|
|
|
|
```mesh_vertices(mesh)```
|
|
|
|
|
|
Returns a table containing the vertices of a mesh.
|
|
|
* ```mesh```: Input mesh
|
|
|
|
|
|
```mesh_normals(mesh)```
|
|
|
|
|
|
Returns a table containing the normals of a mesh.
|
|
|
* ```mesh```: Input mesh
|
|
|
```mesh_local_edge_size(mesh)```
|
|
|
|
|
|
Returns a table containing the average connecting edge length of every vertex of a mesh.
|
|
|
|
|
|
## Miscellaneous Functions
|
|
|
|
|
|
```print(str)```
|
|
|
|
|
|
Prints the message ```str```
|
|
|
|
|
|
```dofile(path)```
|
|
|
|
|
|
Executes the scipt in ```path```
|
|
|
* ```str```: input string
|
|
|
|
|
|
```load_image(filename)```
|
|
|
|
|
|
Returns a 2D table where each ''(i,j)'' index is a vector that corresponds to the rgb pixel from the image file ```filename```
|
|
|
|
|
|
```screenshot()```
|
|
|
|
|
|
Saves a screenshot in the ```pictures``` folder or current script folder for the windows and linux builds respectively.
|
|
|
|
|
|
```sleep(ms)```
|
|
|
|
|
|
Suspends execution of IceSL by ```ms``` milliseconds.
|
|
|
* ```ms```: number of milliseconds
|
|
|
* ```path```: path to the script file
|
|
|
|
|
|
```dump(shape, filename)```
|
|
|
|
|
|
Saves the shape ```shape``` in file ```filename```
|
|
|
* ```shape```: shape to save
|
|
|
* ```filename```: destination file to save the shape. Supports '''stl''' and '''obj''' extensions |
|
|
\ No newline at end of file |