... | ... | @@ -186,4 +186,126 @@ emit( p ) |
|
|
```lua
|
|
|
Void
|
|
|
```
|
|
|
Creates an empty primitive |
|
|
\ No newline at end of file |
|
|
Creates an empty primitive
|
|
|
|
|
|
## Centered Primitives
|
|
|
Many primitives can be automatically centered at creation to their center of symmetry with respect to their bounding boxes. The following table lists their centered versions.
|
|
|
|
|
|
| Primitive | Centered Version | Alternative Centered Version |
|
|
|
| --------- | ---------------- | ---------------------------- |
|
|
|
| ```load(path)``` | ```load_centered(path)``` | ```load_centered_on_plate(path)``` |
|
|
|
| ```cube(dx,dy,dz)``` | ```ccube(dx,dy,dz)``` | ```box(dx,dy,dz)``` |
|
|
|
| ```cone(r0,r1,h)``` | ```ccone(r0,r1,h)``` | |
|
|
|
| ```cylinder(r,h)``` | ```ccylinder(r,h)``` | |
|
|
|
|
|
|
Additionally, the cube and box primitives have the versions ```ocube(dx,dy,dz)``` and ```cornerbox(dx,dy,dz)``` that position their front lower-left corners at the origin.
|
|
|
|
|
|
## Non-primitive Shapes
|
|
|
```lua
|
|
|
linear_extrude(dir, points)
|
|
|
```
|
|
|
Creates a closed object from the extrusion of a polygon along a direction ```dir```. The polygon's orientations is specified as set of either clockwise or counter-clockwise 2D vertices in ```points```.
|
|
|
* ```dir```: extruding direction
|
|
|
* ```points```: polygon specification
|
|
|
|
|
|
<table>
|
|
|
<tr>
|
|
|
<td>
|
|
|
|
|
|
```lua
|
|
|
triangle = { v(-10,0), v(0,10), v(10,0) }
|
|
|
-- 50 units along the Z-axis
|
|
|
dir = v(0,0,50)
|
|
|
emit( linear_extrude(dir, triangle) )
|
|
|
```
|
|
|
|
|
|
</td>
|
|
|
<td>
|
|
|
<img src="uploads/d49fa94fafa25664d5a02a674f2b21ae/Example_linear_extrude.png" width="200">
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table>
|
|
|
|
|
|
```lua
|
|
|
linear_extrude_from_oriented(dir, points)
|
|
|
```
|
|
|
Creates a closed object from the extrusion of a polygon along a direction ```dir```. Solid geometry is specified as set of *closed* (i.e. the last vertex matches the first one) counter-clockwise 2D vertices and hollow geometry is specified as a set of closed clockwise 2D vertices in ```points```.
|
|
|
* ```dir```: extruding direction
|
|
|
* ```points```: polygon specification
|
|
|
|
|
|
<table>
|
|
|
<tr>
|
|
|
<td>
|
|
|
|
|
|
```lua
|
|
|
polygon = {
|
|
|
v(10,10), v(-10,10), v(-10,-10), v(10,-10), v(10,10), -- Solid
|
|
|
v(0,6), v(6,-6), v(-6,-6), v(0,6) } -- Hollow
|
|
|
dir = v(0,0,10)
|
|
|
emit( linear_extrude_from_oriented(dir, polygon))
|
|
|
```
|
|
|
|
|
|
</td>
|
|
|
<td>
|
|
|
<img src="uploads/2c40c2e7a34c7b15751a6425267aaf18/Example_linear_extrude_from_oriented.png" width="200">
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table>
|
|
|
|
|
|
```lua
|
|
|
rotate_extrude(points, nsteps)
|
|
|
```
|
|
|
Creates a closed object from the spinning of a polygon along the Z-axis (axis of revolution). The polygon is specified as set of counter-clockwise 2D vertices in ```points```. ```nsteps``` defines the number of steps in the revolution of the polygon, the more steps the smoother the resulting shape is.
|
|
|
|
|
|
<table>
|
|
|
<tr>
|
|
|
<td>
|
|
|
|
|
|
```lua
|
|
|
radius = v(10,0,0)
|
|
|
triangle = { radius + v(1,0,0), radius + v(0,1,0), radius + v(-1,0,0) }
|
|
|
emit( rotate_extrude( triangle, 100 ) )
|
|
|
```
|
|
|
|
|
|
</td>
|
|
|
<td>
|
|
|
<img src="uploads/ae89126ccae1653103493ffef57bc099/Example_rotate_extrude.png" width="200">
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table>
|
|
|
|
|
|
```lua
|
|
|
sections_extrude(contours)
|
|
|
```
|
|
|
Crates a closed object by conecting each polygon contained in ```contours```. Similar to the functions above, a polygon is defined as a table of at least three points. ```contours``` is a table of more than one polygon and all polygons must contain the same number of points.
|
|
|
|
|
|
<table>
|
|
|
<tr>
|
|
|
<td>
|
|
|
|
|
|
```lua
|
|
|
se = sections_extrude({
|
|
|
{rotate( 0,Z) * v( 0, 0, 0),
|
|
|
rotate( 0,Z) * v(10, 0, 0),
|
|
|
rotate( 0,Z) * v(10,10, 0),
|
|
|
rotate( 0,Z) * v( 0,10, 0)},
|
|
|
|
|
|
{rotate( 60,Z) * v( 0, 0,10),
|
|
|
rotate( 60,Z) * v(10, 0,10),
|
|
|
rotate( 60,Z) * v(10,10,10),
|
|
|
rotate( 60,Z) * v( 0,10,10)},
|
|
|
|
|
|
{rotate(120,Z) * v( 0, 0,20),
|
|
|
rotate(120,Z) * v(10, 0,20),
|
|
|
rotate(120,Z) * v(10,10,20),
|
|
|
rotate(120,Z) * v( 0,10,20)}
|
|
|
})
|
|
|
emit(se)
|
|
|
```
|
|
|
|
|
|
</td>
|
|
|
<td>
|
|
|
<img src="uploads/84e315d1cc4e2a6fbad720171f180280/Example_sections_extrude.jpg" width="200">
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table> |
|
|
\ No newline at end of file |