-
Notifications
You must be signed in to change notification settings - Fork 37
/
DemoExtrude02.kt
71 lines (59 loc) · 2.12 KB
/
DemoExtrude02.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import org.openrndr.WindowMultisample
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.DrawPrimitive
import org.openrndr.draw.shadeStyle
import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.meshgenerators.buildTriangleMesh
import org.openrndr.extra.meshgenerators.extrudeShapeSteps
import org.openrndr.extra.shapes.splines.catmullRom
import org.openrndr.extra.shapes.splines.toPath3D
import org.openrndr.math.Vector3
import org.openrndr.shape.Circle
import org.openrndr.shape.Shape
fun main() {
application {
configure {
width = 800
height = 800
multisample = WindowMultisample.SampleCount(8)
}
program {
val m = buildTriangleMesh {
color = ColorRGBa.PINK
val path = listOf(
Vector3(0.0, 0.0, 0.0),
Vector3(-2.0, 2.0, 2.0),
Vector3(2.0, -4.0, 4.0),
Vector3(0.0, 0.0, 8.0)
).catmullRom(0.5, closed = false).toPath3D()
translate(-5.0, 0.0, 0.0)
val ring = Shape(listOf(Circle(0.0, 0.0, 0.5).contour, Circle(0.0, 0.0, 0.25).contour.reversed))
for (i in 0 until 5) {
extrudeShapeSteps(
ring,
path,
160,
Vector3.UNIT_Y,
contourDistanceTolerance = 0.02,
pathDistanceTolerance = 0.001
)
translate(2.0, 0.0, 0.0)
}
}
extend(Orbital()) {
this.eye = Vector3(0.0, 3.0, 7.0)
this.lookAt = Vector3(0.0, 2.0, 0.0)
}
extend {
drawer.shadeStyle = shadeStyle {
fragmentTransform = """
x_fill = va_color;
x_fill.rgb *= v_viewNormal.z;
""".trimIndent()
}
drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
}
}
}
}