... | ... | @@ -19,9 +19,8 @@ IceSL also extends Lua's types in order to specify shapes and transforms. The ma |
|
|
|
|
|
Creating a shape in IceSL does not automatically render it in the final scene. In order to do this, you need to emit it.
|
|
|
|
|
|
```lua
|
|
|
emit( shape, brush )
|
|
|
```
|
|
|
```emit( shape, brush )```
|
|
|
|
|
|
* ```shape```: the shape to render
|
|
|
* ```brush```: the brush's index to render the shape with. 0 by default
|
|
|
|
... | ... | @@ -80,19 +79,13 @@ Let ```v``` and ```u``` be vectors and ```n``` a number. |
|
|
|
|
|
## Matrices
|
|
|
Construction:
|
|
|
```lua
|
|
|
m( m11, m12, m13, m14,
|
|
|
m21, m22, m23, m24,
|
|
|
m31, m32, m33, m34,
|
|
|
m41, m42, m43, m44 )
|
|
|
```
|
|
|
|
|
|
```m( m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44 )```
|
|
|
|
|
|
or
|
|
|
```lua
|
|
|
m{ m11, m12, m13, m14,
|
|
|
m21, m22, m23, m24,
|
|
|
m31, m32, m33, m34,
|
|
|
m41, m42, m43, m44 }
|
|
|
```
|
|
|
|
|
|
```m{ m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44 }```
|
|
|
|
|
|
Creates the matrix $`\begin{bmatrix} m_{11} & m_{12} & m_{13} & m_{14} \\ m_{21} & m_{22} & m_{23} & m_{24} \\ m_{31} & m_{32} & m_{33} & m_{34}\\ m_{41} & m_{42} & m_{43} & m_{44}\end{bmatrix}`$.
|
|
|
|
|
|
Members:
|
... | ... | @@ -120,47 +113,41 @@ Angles in IceSL are expected to be written in **degrees**. |
|
|
|
|
|
# Shapes
|
|
|
## Primitive Shapes
|
|
|
```lua
|
|
|
load(path)
|
|
|
```
|
|
|
```load(path)```
|
|
|
|
|
|
Loads the 3d mesh at ```path```. The mesh must be watertight.
|
|
|
* ```path```: Absolute path to a 3d mesh. It supports the following extensions:
|
|
|
* **stl**
|
|
|
* **obj**
|
|
|
* **3ds**
|
|
|
|
|
|
```lua
|
|
|
sphere(r, c)
|
|
|
```
|
|
|
```sphere(r, c)```
|
|
|
|
|
|
Creates a sphere of radius ```r``` centered on ```c```. ```sphere(r)``` is syntactic sugar for ```sphere(r,v(0,0,0))``` -a centered sphere.
|
|
|
* ```r```: the sphere's radius
|
|
|
* ```c```: the sphere's center
|
|
|
|
|
|
```lua
|
|
|
cube(dx, dy, dz)
|
|
|
```
|
|
|
```cube(dx, dy, dz)```
|
|
|
|
|
|
Creates a cube with with sides ```dx```, ```dy```, ```dz``` with its bottom face centered on the origin. ```cube(d)``` and ```cube(v)``` are syntactic sugars for ```cube(d,d,d)``` and ```cube(v.x,v.y,v.z)``` respectively.
|
|
|
* ```dx```: length of the face perdendicular to the X-axis
|
|
|
* ```dy```: length of the face perpendicular to the Y-axis
|
|
|
* ```dz```: length of the face perpendicular to the Z-axis
|
|
|
|
|
|
```lua
|
|
|
cone(r0, r1, c0, c1)
|
|
|
```
|
|
|
```cone(r0, r1, c0, c1)```
|
|
|
|
|
|
Creates a cone with base radius ```r0```, top radius ```r1```, base center ```c0``` and top center ```c1```. Moreover, ```cone(r0,r1,h)``` is syntactic sugar for ```cone(r0,r1,v(0,0,0),v(0,0,h))```.
|
|
|
* ```r0```: the cone's base radius
|
|
|
* ```r1```: the cone's top radius
|
|
|
* ```c0```: the cone's base center
|
|
|
* ```c1```: the cone's top center
|
|
|
|
|
|
```lua
|
|
|
cylinder(r, c0, c1)
|
|
|
```
|
|
|
```cylinder(r, c0, c1)```
|
|
|
|
|
|
Creates a cylinder with radius ```r```, base center ```c0``` and top center ```c1```. It is syntactic sugar for ```cone(r,r,c0,c1)```. Additionally, ```cylinder(r,h)``` is also syntactic sugar for ```cone(r,r,h)```.
|
|
|
|
|
|
```lua
|
|
|
polyhedron(points,indices)
|
|
|
```
|
|
|
```polyhedron(points,indices)```
|
|
|
|
|
|
Creates a polyhedron with ```points``` as its vertex and ```indices``` to specify its faces.
|
|
|
* ```points```: an array of vectors containing the polyhedron's vertex
|
|
|
* ```indices```: an array of vectors specifying the polyhedron's faces. Each vector specifies a face constructed from three vertex indices represented by the vector's compotnents. Indices start from 0 and faces point outwards whenever the orientation of the vertices to which the indices refer to is counterclockwise.
|
... | ... | @@ -183,9 +170,8 @@ emit( p ) |
|
|
</tr>
|
|
|
</table>
|
|
|
|
|
|
```lua
|
|
|
Void
|
|
|
```
|
|
|
```Void```
|
|
|
|
|
|
Creates an empty primitive
|
|
|
|
|
|
## Centered Primitives
|
... | ... | @@ -201,9 +187,8 @@ Many primitives can be automatically centered at creation to their center of sym |
|
|
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)
|
|
|
```
|
|
|
```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
|
... | ... | @@ -226,9 +211,8 @@ emit( linear_extrude(dir, triangle) ) |
|
|
</tr>
|
|
|
</table>
|
|
|
|
|
|
```lua
|
|
|
linear_extrude_from_oriented(dir, points)
|
|
|
```
|
|
|
```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
|
... | ... | @@ -242,7 +226,7 @@ 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))
|
|
|
emit( linear_extrude_from_oriented(dir, polygon) )
|
|
|
```
|
|
|
|
|
|
</td>
|
... | ... | @@ -252,9 +236,8 @@ emit( linear_extrude_from_oriented(dir, polygon)) |
|
|
</tr>
|
|
|
</table>
|
|
|
|
|
|
```lua
|
|
|
rotate_extrude(points, nsteps)
|
|
|
```
|
|
|
```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>
|
... | ... | @@ -274,9 +257,8 @@ emit( rotate_extrude( triangle, 100 ) ) |
|
|
</tr>
|
|
|
</table>
|
|
|
|
|
|
```lua
|
|
|
sections_extrude(contours)
|
|
|
```
|
|
|
```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>
|
... | ... | @@ -308,4 +290,43 @@ emit(se) |
|
|
<img src="uploads/84e315d1cc4e2a6fbad720171f180280/Example_sections_extrude.jpg" width="200">
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table> |
|
|
\ No newline at end of file |
|
|
</table>
|
|
|
|
|
|
## Implicits
|
|
|
IceSL supports implicits by way of the [GL Shading Language](https://www.khronos.org/opengl/wiki/OpenGL_Shading_Language) (GLSL). A comprehensive list of the built-in functions of GLSL can be found [here](http://www.shaderific.com/glsl-functions/)
|
|
|
|
|
|
```implicit_distance_field(boxMin, boxMax, fragment)```
|
|
|
|
|
|
```implicit_solid(boxMin, boxMax, voxSize, fragment)```
|
|
|
|
|
|
Creates an object out of the [implicit geometry](https://en.wikipedia.org/wiki/Implicit_function) calculated in ```fragment```. The bounding box constructed by ```boxMin``` and ```boxMax``` defines the boundaries of the implicit shape.
|
|
|
* ```boxMin, boxMax```: domain of the implicit. The domain is specified by the box constructed with corners ```boxMin``` and ```boxMax```
|
|
|
* ```voxSize```: voxel output size. Lower values result in greater quality at the expense of higher calculation costs.
|
|
|
* ```fragment```: string containing the GLSL progam. This program calculates the implicit function that defines the output geometry.
|
|
|
|
|
|
Implicits are calculated in IceSL with a sphere tracing method (detailed [here](http://graphics.cs.illinois.edu/sites/default/files/zeno.pdf)). The program specified in ```fragment``` must contain a function called either ```float distance(vec3 p)```, in the case of ```implicit_distance_field```, or ```float solid(vec3 p)``` in the case of ```implicit_solid```. This function calculates the distance field or the solid/empty classification respectively for every point of the domain of the box. A resulting negative value is interpreted as _solid_ whereas a positive value means _hollow_. Consider the following example.
|
|
|
|
|
|
<table>
|
|
|
<tr>
|
|
|
<td>
|
|
|
|
|
|
```lua
|
|
|
cube = implicit_distance_field( v(-10,-10,-10), v(10,10,10),
|
|
|
[[
|
|
|
float distance(vec3 p) {
|
|
|
return -1;
|
|
|
}
|
|
|
]])
|
|
|
emit (cube)
|
|
|
```
|
|
|
|
|
|
</td>
|
|
|
<td>
|
|
|
<img src="uploads/98f1f60e808308d35a4b4f2ea2e9280c/Example_implicit_1.png" width="200">
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table>
|
|
|
|
|
|
Above, every point in the domain of the implicit is marked as _solid_, therefore the geometry created has the shape of the boundary box.
|
|
|
|
|
|
Choosing ```implicit_distance_field``` over ```implicit_solid``` can be summarized as follows: The former requires to estimate a distance to the surface, which can prove difficult and prone to artifacts (when the estimate is too far off from reality). The latter is much easier, as the function simply has to return negative for solid and positive for empty. |
|
|
\ No newline at end of file |