diff --git a/orx-kdtree/src/jvmDemo/kotlin/DemoKNearestNeighbour01.kt b/orx-kdtree/src/jvmDemo/kotlin/DemoKNearestNeighbour01.kt
index a95909e5..7716b0d6 100644
--- a/orx-kdtree/src/jvmDemo/kotlin/DemoKNearestNeighbour01.kt
+++ b/orx-kdtree/src/jvmDemo/kotlin/DemoKNearestNeighbour01.kt
@@ -11,34 +11,32 @@ import org.openrndr.shape.LineSegment
* cursor are highlighted with circles and lines connecting them to the cursor.
*
* Key features:
- * - Generates 1000 random 2D points within the canvas dimensions (1080x720).
+ * - Generates 1000 random 2D points within the canvas.
* - Builds a KD-tree from the list of points for optimized spatial querying.
* - Visualizes the points and highlights the 7 nearest neighbors to the user's cursor position dynamically.
* - Highlights include red-colored circles around the nearest points and red lines connecting them to the cursor.
*/
-fun main() {
- application {
- configure {
- width = 1080
- height = 720
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ }
+
+ program {
+ val points = MutableList(1000) {
+ Vector2(Math.random() * width, Math.random() * height)
}
+ val tree = points.kdTree()
- program {
- val points = MutableList(1000) {
- Vector2(Math.random() * width, Math.random() * height)
- }
- val tree = points.kdTree()
+ extend {
+ drawer.circles(points, 5.0)
- extend {
- drawer.circles(points, 5.0)
-
- val kNearest = tree.findKNearest(mouse.position, k = 7)
- drawer.fill = ColorRGBa.RED
- drawer.stroke = ColorRGBa.RED
- drawer.strokeWeight = 2.0
- drawer.circles(kNearest, 7.0)
- drawer.lineSegments(kNearest.map { LineSegment(mouse.position, it) })
- }
+ val kNearest = tree.findKNearest(mouse.position, k = 7)
+ drawer.fill = ColorRGBa.RED
+ drawer.stroke = ColorRGBa.RED
+ drawer.strokeWeight = 2.0
+ drawer.circles(kNearest, 7.0)
+ drawer.lineSegments(kNearest.map { LineSegment(mouse.position, it) })
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-kdtree/src/jvmDemo/kotlin/DemoNearestNeighbour01.kt b/orx-kdtree/src/jvmDemo/kotlin/DemoNearestNeighbour01.kt
index 5470e3c1..00c6436e 100644
--- a/orx-kdtree/src/jvmDemo/kotlin/DemoNearestNeighbour01.kt
+++ b/orx-kdtree/src/jvmDemo/kotlin/DemoNearestNeighbour01.kt
@@ -3,8 +3,8 @@ import org.openrndr.extra.kdtree.kdTree
import org.openrndr.math.Vector2
/**
- * Initializes an interactive graphical application that displays 1000 randomly distributed 2D points
- * on a canvas of dimensions 1280x720. The points are organized into a KD-tree for efficient spatial querying.
+ * Initializes an interactive graphical application that displays 1000 randomly distributed 2D points.
+ * The points are organized into a KD-tree for efficient spatial querying.
*
* Key functionality:
* - Displays the points as small circles on the canvas.
@@ -14,24 +14,22 @@ import org.openrndr.math.Vector2
* - KD-tree structure enables efficient nearest-neighbor searches.
* - The nearest point to the cursor is determined and visually emphasized in real-time as the cursor moves.
*/
-fun main() {
- application {
- configure {
- width = 1280
- height = 720
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ }
+ program {
+ val points = MutableList(1000) {
+ Vector2(Math.random() * width, Math.random() * height)
}
- program {
- val points = MutableList(1000) {
- Vector2(Math.random() * width, Math.random() * height)
- }
- val tree = points.kdTree()
- extend {
- drawer.circles(points, 5.0)
- val nearest = tree.findNearest(mouse.position)
- nearest?.let {
- drawer.circle(it.x, it.y, 20.0)
- }
+ val tree = points.kdTree()
+ extend {
+ drawer.circles(points, 5.0)
+ val nearest = tree.findNearest(mouse.position)
+ nearest?.let {
+ drawer.circle(it.x, it.y, 20.0)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-kdtree/src/jvmDemo/kotlin/DemoRangeQuery01.kt b/orx-kdtree/src/jvmDemo/kotlin/DemoRangeQuery01.kt
index bada40a3..3cd483ec 100644
--- a/orx-kdtree/src/jvmDemo/kotlin/DemoRangeQuery01.kt
+++ b/orx-kdtree/src/jvmDemo/kotlin/DemoRangeQuery01.kt
@@ -11,40 +11,37 @@ import org.openrndr.math.Vector2
* user's cursor position.
*
* Key features:
- * - Generates and displays 1000 random 2D points within canvas dimensions of 1080x720.
+ * - Generates and displays 1000 random 2D points within the canvas.
* - Builds a KD-tree structure for optimized querying of spatial data.
* - Dynamically highlights points within a specified radius (50.0) from the cursor position.
* - Visualizes the current query radius around the cursor as an outline circle.
* - Uses different fill and stroke styles to distinguish highlighted points and query visuals.
*/
-fun main() {
- application {
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ }
- configure {
- width = 1080
- height = 720
+ program {
+ val points = MutableList(1000) {
+ Vector2(Math.random() * width, Math.random() * height)
}
+ val tree = points.kdTree()
+ val radius = 50.0
- program {
- val points = MutableList(1000) {
- Vector2(Math.random() * width, Math.random() * height)
- }
- val tree = points.kdTree()
- val radius = 50.0
+ extend {
+ drawer.circles(points, 5.0)
- extend {
- drawer.circles(points, 5.0)
+ val allInRange = tree.findAllInRadius(mouse.position, radius = radius)
+ drawer.fill = ColorRGBa.PINK
+ drawer.stroke = ColorRGBa.PINK
+ drawer.strokeWeight = 2.0
+ drawer.circles(allInRange, 7.0)
- val allInRange = tree.findAllInRadius(mouse.position, radius = radius)
- drawer.fill = ColorRGBa.PINK
- drawer.stroke = ColorRGBa.PINK
- drawer.strokeWeight = 2.0
- drawer.circles(allInRange, 7.0)
-
- drawer.fill = null
- drawer.strokeWeight = 1.0
- drawer.circle(mouse.position, radius)
- }
+ drawer.fill = null
+ drawer.strokeWeight = 1.0
+ drawer.circle(mouse.position, radius)
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-marching-squares/src/jvmDemo/kotlin/FindContours01.kt b/orx-marching-squares/src/jvmDemo/kotlin/FindContours01.kt
index 3bb7f909..61cb60a1 100644
--- a/orx-marching-squares/src/jvmDemo/kotlin/FindContours01.kt
+++ b/orx-marching-squares/src/jvmDemo/kotlin/FindContours01.kt
@@ -3,21 +3,19 @@ import org.openrndr.color.ColorRGBa
import org.openrndr.extra.marchingsquares.findContours
import org.openrndr.math.Vector2
-fun main() {
- application {
- configure {
- width = 720
- height = 720
- }
- program {
- extend {
- drawer.clear(ColorRGBa.BLACK)
- drawer.stroke = ColorRGBa.PINK
- fun f(v: Vector2) = v.distanceTo(drawer.bounds.center) - 200.0
- val contours = findContours(::f, drawer.bounds, 16.0)
- drawer.fill = null
- drawer.contours(contours)
- }
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ }
+ program {
+ extend {
+ drawer.clear(ColorRGBa.BLACK)
+ drawer.stroke = ColorRGBa.PINK
+ fun f(v: Vector2) = v.distanceTo(drawer.bounds.center) - 200.0
+ val contours = findContours(::f, drawer.bounds, 16.0)
+ drawer.fill = null
+ drawer.contours(contours)
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-marching-squares/src/jvmDemo/kotlin/FindContours02.kt b/orx-marching-squares/src/jvmDemo/kotlin/FindContours02.kt
index 04a9b68f..d9a59739 100644
--- a/orx-marching-squares/src/jvmDemo/kotlin/FindContours02.kt
+++ b/orx-marching-squares/src/jvmDemo/kotlin/FindContours02.kt
@@ -5,21 +5,19 @@ import org.openrndr.math.Vector2
import kotlin.math.PI
import kotlin.math.cos
-fun main() {
- application {
- configure {
- width = 720
- height = 720
- }
- program {
- extend {
- drawer.clear(ColorRGBa.BLACK)
- drawer.stroke = ColorRGBa.PINK
- fun f(v: Vector2) = cos((v.distanceTo(drawer.bounds.center) / 100.0) * 2 * PI)
- val contours = findContours(::f, drawer.bounds.offsetEdges(-24.0), 16.0)
- drawer.fill = null
- drawer.contours(contours)
- }
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ }
+ program {
+ extend {
+ drawer.clear(ColorRGBa.BLACK)
+ drawer.stroke = ColorRGBa.PINK
+ fun f(v: Vector2) = cos((v.distanceTo(drawer.bounds.center) / 100.0) * 2 * PI)
+ val contours = findContours(::f, drawer.bounds.offsetEdges(-24.0), 16.0)
+ drawer.fill = null
+ drawer.contours(contours)
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-marching-squares/src/jvmDemo/kotlin/FindContours03.kt b/orx-marching-squares/src/jvmDemo/kotlin/FindContours03.kt
index 7721b391..68ff8a53 100644
--- a/orx-marching-squares/src/jvmDemo/kotlin/FindContours03.kt
+++ b/orx-marching-squares/src/jvmDemo/kotlin/FindContours03.kt
@@ -6,24 +6,23 @@ import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin
-fun main() {
- application {
- configure {
- width = 720
- height = 720
- }
- program {
- extend {
- drawer.clear(ColorRGBa.BLACK)
- drawer.stroke = ColorRGBa.PINK
- drawer.fill = null
- fun f(v: Vector2): Double {
- val p = v + Vector2(cos(v.y * 0.1 + seconds) * 40.0, sin(v.x * 0.1 + seconds) * 40.0)
- return cos((p.distanceTo(drawer.bounds.center) / 720.0) * 12 * PI)
- }
- val contours = findContours(::f, drawer.bounds.offsetEdges(-2.0), 4.0)
- drawer.contours(contours)
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ }
+ program {
+ extend {
+ drawer.clear(ColorRGBa.BLACK)
+ drawer.stroke = ColorRGBa.PINK
+ drawer.fill = null
+ fun f(v: Vector2): Double {
+ val p = v + Vector2(cos(v.y * 0.1 + seconds) * 40.0, sin(v.x * 0.1 + seconds) * 40.0)
+ return cos((p.distanceTo(drawer.bounds.center) / 720.0) * 12 * PI)
}
+
+ val contours = findContours(::f, drawer.bounds.offsetEdges(-2.0), 4.0)
+ drawer.contours(contours)
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-marching-squares/src/jvmDemo/kotlin/FindContours04.kt b/orx-marching-squares/src/jvmDemo/kotlin/FindContours04.kt
index e19116b4..c5098b27 100644
--- a/orx-marching-squares/src/jvmDemo/kotlin/FindContours04.kt
+++ b/orx-marching-squares/src/jvmDemo/kotlin/FindContours04.kt
@@ -7,30 +7,30 @@ import org.openrndr.math.Vector2
import kotlin.math.PI
import kotlin.math.cos
-fun main() {
- application {
- configure {
- width = 640
- height = 480
- }
- program {
- val image = loadImage("demo-data/images/image-001.png")
- image.shadow.download()
- extend {
- drawer.clear(ColorRGBa.BLACK)
- drawer.stroke = ColorRGBa.BLACK
- drawer.fill = null
- fun f(v: Vector2): Double {
- val iv = v.toInt()
- val d = if (iv.x >= 0 && iv.y >= 0 && iv.x < image.width && iv.y < image.height) image.shadow[iv.x, iv.y].luminance else 0.0
- return cos(d * PI * 8.0 + seconds)
- }
-
- val contours = findContours(::f, drawer.bounds.offsetEdges(32.0), 4.0)
- drawer.drawStyle.colorMatrix = grayscale()
- drawer.image(image)
- drawer.contours(contours)
+fun main() = application {
+ configure {
+ width = 720
+ height = 540
+ }
+ program {
+ val image = loadImage("demo-data/images/image-001.png")
+ image.shadow.download()
+ extend {
+ drawer.clear(ColorRGBa.BLACK)
+ drawer.stroke = ColorRGBa.BLACK
+ drawer.fill = null
+ fun f(v: Vector2): Double {
+ val iv = v.toInt()
+ val d =
+ if (iv.x >= 0 && iv.y >= 0 && iv.x < image.width && iv.y < image.height) image.shadow[iv.x, iv.y].luminance else 0.0
+ return cos(d * PI * 8.0 + seconds)
}
+
+ val contours = findContours(::f, drawer.bounds.offsetEdges(32.0), 4.0)
+ drawer.drawStyle.colorMatrix = grayscale()
+ drawer.scale(width.toDouble() / image.width, height.toDouble() / image.height)
+ drawer.image(image)
+ drawer.contours(contours)
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-mesh-generators/src/jvmDemo/kotlin/DemoAll.kt b/orx-mesh-generators/src/jvmDemo/kotlin/DemoAll.kt
index 625d7d20..d6d655f4 100644
--- a/orx-mesh-generators/src/jvmDemo/kotlin/DemoAll.kt
+++ b/orx-mesh-generators/src/jvmDemo/kotlin/DemoAll.kt
@@ -8,62 +8,62 @@ import org.openrndr.math.Vector2
import org.openrndr.math.Vector3
import org.openrndr.shape.Rectangle
-fun main() {
- application {
- configure {
- multisample = WindowMultisample.SampleCount(8)
- }
- program {
- val meshes = listOf(
- boxMesh(1.0, 1.0, 1.0),
- sphereMesh(radius = 0.5),
- dodecahedronMesh(0.5),
- cylinderMesh(radius = 0.5, length = 1.0, center = true),
- planeMesh(Vector3.ZERO, Vector3.UNIT_X, Vector3.UNIT_Y),
- capMesh(
- 15, 0.5,
- listOf(Vector2.ZERO, Vector2(0.5, 0.2), Vector2.UNIT_X)
- ),
- revolveMesh(5, 0.5)
- )
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ multisample = WindowMultisample.SampleCount(8)
+ }
+ program {
+ val meshes = listOf(
+ boxMesh(1.0, 1.0, 1.0),
+ sphereMesh(radius = 0.5),
+ dodecahedronMesh(0.5),
+ cylinderMesh(radius = 0.5, length = 1.0, center = true),
+ planeMesh(Vector3.ZERO, Vector3.UNIT_X, Vector3.UNIT_Y),
+ capMesh(
+ 15, 0.5,
+ listOf(Vector2.ZERO, Vector2(0.5, 0.2), Vector2.UNIT_X)
+ ),
+ revolveMesh(5, 0.5)
+ )
- val texture = colorBuffer(256, 256)
- val s = texture.shadow
- for (y in 0 until 256) {
- for (x in 0 until 256) {
- s[x, y] = ColorRGBa(x / 256.0, y / 256.0, 0.0, 1.0)
- }
+ val texture = colorBuffer(256, 256)
+ val s = texture.shadow
+ for (y in 0 until 256) {
+ for (x in 0 until 256) {
+ s[x, y] = ColorRGBa(x / 256.0, y / 256.0, 0.0, 1.0)
}
- s.upload()
+ }
+ s.upload()
- val positions = Rectangle.fromCenter(Vector2.ZERO, width * 0.01, height * 0.01)
- .grid(4, 2).flatten().map {
- it.center.vector3(z = -5.0)
- }
+ val positions = Rectangle.fromCenter(Vector2.ZERO, width * 0.01, height * 0.01)
+ .grid(4, 2).flatten().map {
+ it.center.vector3(z = -5.0)
+ }
- extend {
- drawer.clear(ColorRGBa.PINK)
- drawer.perspective(60.0, width * 1.0 / height, 0.01, 1000.0)
- drawer.depthWrite = true
- drawer.depthTestPass = DepthTestPass.LESS_OR_EQUAL
- drawer.shadeStyle = shadeStyle {
- fragmentTransform = """
+ extend {
+ drawer.clear(ColorRGBa.PINK)
+ drawer.perspective(60.0, width * 1.0 / height, 0.01, 1000.0)
+ drawer.depthWrite = true
+ drawer.depthTestPass = DepthTestPass.LESS_OR_EQUAL
+ drawer.shadeStyle = shadeStyle {
+ fragmentTransform = """
float light = dot(v_worldNormal, p_light) * 0.5 + 0.5;
x_fill = texture(p_texture, va_texCoord0.xy);
x_fill.rgb *= light;
""".trimIndent()
- parameter("texture", texture)
- parameter("light", Vector3(1.0).normalized)
- }
- meshes.forEachIndexed { i, mesh ->
- drawer.isolated {
- translate(positions[i])
- rotate(Vector3.UNIT_Y, seconds * 12)
- rotate(Vector3.UNIT_X, seconds * 25)
- vertexBuffer(mesh, DrawPrimitive.TRIANGLES)
- }
+ parameter("texture", texture)
+ parameter("light", Vector3(1.0).normalized)
+ }
+ meshes.forEachIndexed { i, mesh ->
+ drawer.isolated {
+ translate(positions[i])
+ rotate(Vector3.UNIT_Y, seconds * 12)
+ rotate(Vector3.UNIT_X, seconds * 25)
+ vertexBuffer(mesh, DrawPrimitive.TRIANGLES)
}
}
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-mesh-generators/src/jvmDemo/kotlin/DemoBox.kt b/orx-mesh-generators/src/jvmDemo/kotlin/DemoBox.kt
index 9d9d7adc..3277ae75 100644
--- a/orx-mesh-generators/src/jvmDemo/kotlin/DemoBox.kt
+++ b/orx-mesh-generators/src/jvmDemo/kotlin/DemoBox.kt
@@ -9,37 +9,37 @@ import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.meshgenerators.boxMesh
import org.openrndr.math.Vector3
-fun main() {
- application {
- configure {
- multisample = WindowMultisample.SampleCount(8)
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ multisample = WindowMultisample.SampleCount(8)
+ }
+ program {
+ val box = boxMesh(1.0, 1.0, 1.0)
+
+ val texture = colorBuffer(256, 256)
+ val s = texture.shadow
+ for (y in 0 until 256) {
+ for (x in 0 until 256) {
+ s[x, y] = ColorRGBa(x / 256.0, y / 256.0, 0.0, 1.0)
+ }
}
- program {
- val box = boxMesh(1.0, 1.0, 1.0)
+ s.upload()
- val texture = colorBuffer(256, 256)
- val s = texture.shadow
- for (y in 0 until 256) {
- for (x in 0 until 256) {
- s[x, y] = ColorRGBa(x/256.0, y/256.0, 0.0, 1.0)
- }
- }
- s.upload()
-
- extend(Orbital()) {
- eye = Vector3(1.0, 1.0, 1.0)
- }
- extend {
- drawer.clear(ColorRGBa.PINK)
- drawer.shadeStyle = shadeStyle {
- fragmentTransform = """
+ extend(Orbital()) {
+ eye = Vector3(1.0, 1.0, 1.0)
+ }
+ extend {
+ drawer.clear(ColorRGBa.PINK)
+ drawer.shadeStyle = shadeStyle {
+ fragmentTransform = """
x_fill = texture(p_texture, va_texCoord0.xy);
""".trimIndent()
- parameter("texture", texture)
- }
- drawer.drawStyle.cullTestPass = CullTestPass.FRONT
- drawer.vertexBuffer(box, DrawPrimitive.TRIANGLES)
+ parameter("texture", texture)
}
+ drawer.drawStyle.cullTestPass = CullTestPass.FRONT
+ drawer.vertexBuffer(box, DrawPrimitive.TRIANGLES)
}
}
}
\ No newline at end of file
diff --git a/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex01.kt b/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex01.kt
index f52fbcee..5b2d4fc2 100644
--- a/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex01.kt
+++ b/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex01.kt
@@ -9,38 +9,36 @@ import org.openrndr.extra.meshgenerators.buildTriangleMesh
import org.openrndr.extra.meshgenerators.sphere
import org.openrndr.math.Vector3
-fun main() {
- application {
- configure {
- width = 800
- height = 800
- multisample = WindowMultisample.SampleCount(8)
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ multisample = WindowMultisample.SampleCount(8)
+ }
+ program {
+ val m = buildTriangleMesh {
+ color = ColorRGBa.PINK
+ sphere(32, 32, 1.0)
+
+ color = ColorRGBa.WHITE
+ translate(0.0, -2.0, 0.0)
+ box(4.0, 4.0, 4.0)
+
}
- program {
- val m = buildTriangleMesh {
- color = ColorRGBa.PINK
- sphere(32, 32, 1.0)
- color = ColorRGBa.WHITE
- translate(0.0, -2.0, 0.0)
- box(4.0, 4.0, 4.0)
+ extend(Orbital()) {
+ this.eye = Vector3(0.0, 3.0, 7.0)
+ this.lookAt = Vector3(0.0, 2.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 = """
+ extend {
+ drawer.shadeStyle = shadeStyle {
+ fragmentTransform = """
x_fill = va_color;
x_fill.rgb *= v_viewNormal.z;
""".trimIndent()
- }
- drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
}
+ drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex02.kt b/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex02.kt
index fec94728..a2c1e941 100644
--- a/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex02.kt
+++ b/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex02.kt
@@ -8,60 +8,58 @@ import org.openrndr.extra.meshgenerators.cylinder
import org.openrndr.extra.meshgenerators.hemisphere
import org.openrndr.math.Vector3
-fun main() {
- application {
- configure {
- width = 800
- height = 800
- multisample = WindowMultisample.SampleCount(8)
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ multisample = WindowMultisample.SampleCount(8)
+ }
+ program {
+ extend(Orbital()) {
+ this.eye = Vector3(0.0, 10.0, 20.0)
+ this.lookAt = Vector3(0.0, 5.0, 0.0)
}
- program {
- extend(Orbital()) {
- this.eye = Vector3(0.0, 10.0, 20.0)
- this.lookAt = Vector3(0.0, 5.0, 0.0)
+ val m = buildTriangleMesh {
+ isolated {
+ translate(0.0, 12.0, 0.0)
+ hemisphere(32, 16, 5.0)
}
- val m = buildTriangleMesh {
- isolated {
- translate(0.0, 12.0, 0.0)
- hemisphere(32, 16, 5.0)
- }
- isolated {
- translate(0.0, 9.0, 0.0)
- rotate(Vector3.UNIT_X, 90.0)
- cylinder(32, 1, 5.0, 6.0, center = true)
- }
- isolated {
- translate(0.0, 6.0, 0.0)
- rotate(Vector3.UNIT_X, 180.0)
- hemisphere(32, 16, 5.0)
- }
- isolated {
- val legCount = 12
- val baseRadius = 3.0
- val legRadius = 0.05
- val legLength = 4.0
- for (i in 0 until legCount) {
- isolated {
- val dphi = 360.0 / legCount
- rotate(Vector3.UNIT_Y, dphi * i)
- translate(baseRadius, 0.0, 0.0)
- rotate(Vector3.UNIT_Z, -15.0)
- translate(0.0, legLength / 2.0, 0.0)
- rotate(Vector3.UNIT_X, 90.0)
- cylinder(32, 1, legRadius, legLength, center = true)
- }
+ isolated {
+ translate(0.0, 9.0, 0.0)
+ rotate(Vector3.UNIT_X, 90.0)
+ cylinder(32, 1, 5.0, 6.0, center = true)
+ }
+ isolated {
+ translate(0.0, 6.0, 0.0)
+ rotate(Vector3.UNIT_X, 180.0)
+ hemisphere(32, 16, 5.0)
+ }
+ isolated {
+ val legCount = 12
+ val baseRadius = 3.0
+ val legRadius = 0.05
+ val legLength = 4.0
+ for (i in 0 until legCount) {
+ isolated {
+ val dphi = 360.0 / legCount
+ rotate(Vector3.UNIT_Y, dphi * i)
+ translate(baseRadius, 0.0, 0.0)
+ rotate(Vector3.UNIT_Z, -15.0)
+ translate(0.0, legLength / 2.0, 0.0)
+ rotate(Vector3.UNIT_X, 90.0)
+ cylinder(32, 1, legRadius, legLength, center = true)
}
}
}
- extend {
- drawer.shadeStyle = shadeStyle {
- fragmentTransform = """
+ }
+ extend {
+ drawer.shadeStyle = shadeStyle {
+ fragmentTransform = """
x_fill.rgb *= v_viewNormal.z;
""".trimIndent()
- }
- drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
}
+ drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex03.kt b/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex03.kt
index f53d53f8..30380bbf 100644
--- a/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex03.kt
+++ b/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex03.kt
@@ -6,78 +6,80 @@ import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.meshgenerators.*
import org.openrndr.math.Vector3
-fun main() {
- application {
- configure {
- width = 800
- height = 800
- multisample = WindowMultisample.SampleCount(8)
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ multisample = WindowMultisample.SampleCount(8)
+ }
+ program {
+ extend(Orbital()) {
+ this.eye = Vector3(0.0, 10.0, 20.0)
+ this.lookAt = Vector3(0.0, 5.0, 0.0)
}
- program {
- extend(Orbital()) {
- this.eye = Vector3(0.0, 10.0, 20.0)
- this.lookAt = Vector3(0.0, 5.0, 0.0)
+ val m = buildTriangleMesh {
+ isolated {
+ translate(0.0, 12.0, 0.0)
+ hemisphere(32, 16, 5.0)
}
- val m = buildTriangleMesh {
+
+ val ridges = 5
+ val midLength = 6.0
+ val ridgeLength = midLength / ridges
+ val ridgeRadius = 5.5
+
+ for (r in 0 until ridges) {
isolated {
- translate(0.0, 12.0, 0.0)
- hemisphere(32, 16, 5.0)
+ translate(
+ 0.0,
+ ridgeLength / 4.0 + r * ridgeLength + 6.0,
+ 0.0
+ )
+ rotate(Vector3.UNIT_X, 270.0)
+ taperedCylinder(32, 1, 5.0, ridgeRadius, ridgeLength / 2.0, center = true)
}
- val ridges = 5
- val midLength = 6.0
- val ridgeLength = midLength / ridges
- val ridgeRadius = 5.5
-
- for (r in 0 until ridges) {
+ isolated {
+ translate(
+ 0.0,
+ ridgeLength / 4.0 + ridgeLength / 2.0 + r * ridgeLength + 6.0,
+ 0.0
+ )
+ rotate(Vector3.UNIT_X, 270.0)
+ taperedCylinder(32, 1, ridgeRadius, 5.0, ridgeLength / 2.0, center = true)
+ }
+ }
+ isolated {
+ translate(0.0, 6.0, 0.0)
+ rotate(Vector3.UNIT_X, 180.0)
+ hemisphere(32, 16, 5.0)
+ }
+ isolated {
+ val legCount = 12
+ val baseRadius = 3.0
+ val legRadius = 0.05
+ val legLength = 4.0
+ for (i in 0 until legCount) {
isolated {
- translate(0.0,
- ridgeLength/4.0 + r * ridgeLength + 6.0,
- 0.0)
- rotate(Vector3.UNIT_X, 270.0)
- taperedCylinder(32, 1, 5.0, ridgeRadius, ridgeLength/ 2.0, center = true)
- }
-
- isolated {
- translate(0.0,
- ridgeLength/4.0 + ridgeLength/2.0 + r * ridgeLength + 6.0,
- 0.0)
- rotate(Vector3.UNIT_X, 270.0)
- taperedCylinder(32, 1, ridgeRadius, 5.0, ridgeLength/2.0, center = true)
- }
- }
- isolated {
- translate(0.0, 6.0, 0.0)
- rotate(Vector3.UNIT_X, 180.0)
- hemisphere(32, 16, 5.0)
- }
- isolated {
- val legCount = 12
- val baseRadius = 3.0
- val legRadius = 0.05
- val legLength = 4.0
- for (i in 0 until legCount) {
- isolated {
- val dphi = 360.0 / legCount
- rotate(Vector3.UNIT_Y, dphi * i)
- translate(baseRadius, 0.0, 0.0)
- rotate(Vector3.UNIT_Z, -15.0)
- translate(0.0, legLength/2.0, 0.0)
- rotate(Vector3.UNIT_X, 90.0)
- cylinder(32, 1, legRadius, legLength, center = true)
- }
+ val dphi = 360.0 / legCount
+ rotate(Vector3.UNIT_Y, dphi * i)
+ translate(baseRadius, 0.0, 0.0)
+ rotate(Vector3.UNIT_Z, -15.0)
+ translate(0.0, legLength / 2.0, 0.0)
+ rotate(Vector3.UNIT_X, 90.0)
+ cylinder(32, 1, legRadius, legLength, center = true)
}
}
}
+ }
- extend {
- drawer.shadeStyle = shadeStyle {
- fragmentTransform = """
+ extend {
+ drawer.shadeStyle = shadeStyle {
+ fragmentTransform = """
x_fill.rgb *= v_viewNormal.z;
""".trimIndent()
- }
- drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
}
+ drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex04.kt b/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex04.kt
index 9f364ef2..25b11f42 100644
--- a/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex04.kt
+++ b/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex04.kt
@@ -7,98 +7,98 @@ import org.openrndr.extra.meshgenerators.*
import org.openrndr.math.Vector2
import org.openrndr.math.Vector3
-fun main() {
- application {
- configure {
- width = 800
- height = 800
- multisample = WindowMultisample.SampleCount(8)
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ multisample = WindowMultisample.SampleCount(8)
+ }
+ program {
+ extend(Orbital()) {
+ this.eye = Vector3(0.0, 15.0, 15.0)
}
- program {
- extend(Orbital()) {
- this.eye = Vector3(0.0, 15.0, 15.0)
- }
- val m = buildTriangleMesh {
- val sides = 12
- isolated {
- translate(0.0, 12.0, 0.0)
- cap(sides, 5.0, listOf(
- Vector2(0.0, 1.0),
- Vector2(0.5, 1.0),
- Vector2(0.5, 0.5),
- Vector2(0.9, 0.5),
- Vector2(1.0, 0.0))
+ val m = buildTriangleMesh {
+ val sides = 12
+ isolated {
+ translate(0.0, 12.0, 0.0)
+ cap(
+ sides, 5.0, listOf(
+ Vector2(0.0, 1.0),
+ Vector2(0.5, 1.0),
+ Vector2(0.5, 0.5),
+ Vector2(0.9, 0.5),
+ Vector2(1.0, 0.0)
)
- }
+ )
+ }
- val ridges = 5
- val midLength = 6.0
- val ridgeLength = midLength / ridges
- val ridgeRadius = 5.5
+ val ridges = 5
+ val midLength = 6.0
+ val ridgeLength = midLength / ridges
+ val ridgeRadius = 5.5
- for (r in 0 until ridges) {
- isolated {
- translate(
- 0.0,
- ridgeLength / 6.0 + r * ridgeLength + 6.0,
- 0.0
- )
- rotate(Vector3.UNIT_X, 270.0)
- taperedCylinder(sides, 1, 5.0, ridgeRadius, ridgeLength / 3.0, center = true)
- }
- isolated {
- translate(
- 0.0,
- ridgeLength / 6.0 + ridgeLength / 3.0 + r * ridgeLength + 6.0,
- 0.0
- )
- rotate(Vector3.UNIT_X, 270.0)
- taperedCylinder(sides, 1, ridgeRadius, ridgeRadius, ridgeLength / 3.0, center = true)
- }
-
- isolated {
- translate(
- 0.0,
- ridgeLength / 6.0 + 2 * ridgeLength / 3.0 + r * ridgeLength + 6.0,
- 0.0
- )
- rotate(Vector3.UNIT_X, 270.0)
- taperedCylinder(sides, 1, ridgeRadius, 5.0, ridgeLength / 3.0, center = true)
- }
+ for (r in 0 until ridges) {
+ isolated {
+ translate(
+ 0.0,
+ ridgeLength / 6.0 + r * ridgeLength + 6.0,
+ 0.0
+ )
+ rotate(Vector3.UNIT_X, 270.0)
+ taperedCylinder(sides, 1, 5.0, ridgeRadius, ridgeLength / 3.0, center = true)
}
isolated {
- translate(0.0, 6.0, 0.0)
- rotate(Vector3.UNIT_X, 180.0)
- cap(sides, 5.0, listOf(Vector2(0.0, 0.0), Vector2(1.0, 0.0)))
+ translate(
+ 0.0,
+ ridgeLength / 6.0 + ridgeLength / 3.0 + r * ridgeLength + 6.0,
+ 0.0
+ )
+ rotate(Vector3.UNIT_X, 270.0)
+ taperedCylinder(sides, 1, ridgeRadius, ridgeRadius, ridgeLength / 3.0, center = true)
}
+
isolated {
- val legCount = 12
- val baseRadius = 4.5
- val legRadius = 0.05
- val legLength = 7.0
- for (i in 0 until legCount) {
- isolated {
- val dphi = 360.0 / legCount
- rotate(Vector3.UNIT_Y, dphi * i)
- translate(baseRadius, 0.0, 0.0)
- translate(0.0, legLength / 2.0, 0.0)
- rotate(Vector3.UNIT_X, 90.0)
- cylinder(sides, 1, legRadius, legLength, center = true)
- }
+ translate(
+ 0.0,
+ ridgeLength / 6.0 + 2 * ridgeLength / 3.0 + r * ridgeLength + 6.0,
+ 0.0
+ )
+ rotate(Vector3.UNIT_X, 270.0)
+ taperedCylinder(sides, 1, ridgeRadius, 5.0, ridgeLength / 3.0, center = true)
+ }
+ }
+ isolated {
+ translate(0.0, 6.0, 0.0)
+ rotate(Vector3.UNIT_X, 180.0)
+ cap(sides, 5.0, listOf(Vector2(0.0, 0.0), Vector2(1.0, 0.0)))
+ }
+ isolated {
+ val legCount = 12
+ val baseRadius = 4.5
+ val legRadius = 0.05
+ val legLength = 7.0
+ for (i in 0 until legCount) {
+ isolated {
+ val dphi = 360.0 / legCount
+ rotate(Vector3.UNIT_Y, dphi * i)
+ translate(baseRadius, 0.0, 0.0)
+ translate(0.0, legLength / 2.0, 0.0)
+ rotate(Vector3.UNIT_X, 90.0)
+ cylinder(sides, 1, legRadius, legLength, center = true)
}
}
}
+ }
- extend {
- drawer.shadeStyle = shadeStyle {
- fragmentTransform = """
+ extend {
+ drawer.shadeStyle = shadeStyle {
+ fragmentTransform = """
x_fill.rgb *= v_viewNormal.z;
""".trimIndent()
- }
- drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
}
+ drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex05.kt b/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex05.kt
index 7cd32ea9..754515c6 100644
--- a/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex05.kt
+++ b/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex05.kt
@@ -11,38 +11,36 @@ import org.openrndr.extra.meshgenerators.twist
import org.openrndr.math.Vector3
import org.openrndr.shape.Circle
-fun main() {
- application {
- configure {
- width = 800
- height = 800
- multisample = WindowMultisample.SampleCount(8)
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ multisample = WindowMultisample.SampleCount(8)
+ }
+ program {
+ extend(Orbital()) {
+ this.eye = Vector3(0.0, 30.0, 50.0)
}
- program {
- extend(Orbital()) {
- this.eye = Vector3(0.0, 30.0, 50.0)
- }
- val m = buildTriangleMesh {
- grid(5, 5, 5) { u, v, w ->
- isolated {
- translate(u * 20.0, v * 20.0, w * 20.0)
- extrudeShape(Circle(0.0, 0.0, 50.0).shape, 4.0, scale = 0.1)
- }
+ val m = buildTriangleMesh {
+ grid(5, 5, 5) { u, v, w ->
+ isolated {
+ translate(u * 20.0, v * 20.0, w * 20.0)
+ extrudeShape(Circle(0.0, 0.0, 50.0).shape, 4.0, scale = 0.1)
}
- twist(360.0 / 200.0, 0.0)
- twist(360.0 / 200.0, 0.0, Vector3.UNIT_X)
- twist(360.0 / 200.0, 0.0, Vector3.UNIT_Z)
}
+ twist(360.0 / 200.0, 0.0)
+ twist(360.0 / 200.0, 0.0, Vector3.UNIT_X)
+ twist(360.0 / 200.0, 0.0, Vector3.UNIT_Z)
+ }
- extend {
- drawer.shadeStyle = shadeStyle {
- fragmentTransform = """
+ extend {
+ drawer.shadeStyle = shadeStyle {
+ fragmentTransform = """
x_fill.rgb *= v_viewNormal.z;
""".trimIndent()
- }
- drawer.drawStyle.cullTestPass = CullTestPass.FRONT
- drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
}
+ drawer.drawStyle.cullTestPass = CullTestPass.FRONT
+ drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex06.kt b/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex06.kt
index bdfa6993..b5394e24 100644
--- a/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex06.kt
+++ b/orx-mesh-generators/src/jvmDemo/kotlin/DemoComplex06.kt
@@ -13,50 +13,48 @@ import org.openrndr.math.Vector3
* Interactive orbital camera.
*
*/
-fun main() {
- application {
- configure {
- width = 800
- height = 800
- multisample = WindowMultisample.SampleCount(8)
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ multisample = WindowMultisample.SampleCount(8)
+ }
+ program {
+ extend(Orbital()) {
+ this.eye = Vector3(3.0, 3.0, 10.0)
+ this.fov = 60.0
}
- program {
- extend(Orbital()) {
- this.eye = Vector3(3.0, 3.0, 10.0)
- this.fov = 60.0
- }
- val m = buildTriangleMesh {
- grid(5, 5) { u, v ->
- isolated {
- grid(3, 3, 3, GridCoordinates.UNIPOLAR) { x, y, z ->
- val pos0 = Vector3(u, v, 0.0) * 10.0
- val pos1 = Vector3(x, y, z) * 2.0
- val pos2 = pos0 + pos1 + Vector3(
- y * 0.12 + z * 0.3,
- x * 0.14 + z * 0.15,
- x * 0.16 + y * 0.17
- )
- // Drop some boxes
- if(simplex(0, pos1 * 0.5 + pos0 * 0.05) > 0) {
- translate(pos2)
- color = rgb(x, y, z)
- box(1.2, 1.2, 1.2)
- }
+ val m = buildTriangleMesh {
+ grid(5, 5) { u, v ->
+ isolated {
+ grid(3, 3, 3, GridCoordinates.UNIPOLAR) { x, y, z ->
+ val pos0 = Vector3(u, v, 0.0) * 10.0
+ val pos1 = Vector3(x, y, z) * 2.0
+ val pos2 = pos0 + pos1 + Vector3(
+ y * 0.12 + z * 0.3,
+ x * 0.14 + z * 0.15,
+ x * 0.16 + y * 0.17
+ )
+ // Drop some boxes
+ if (simplex(0, pos1 * 0.5 + pos0 * 0.05) > 0) {
+ translate(pos2)
+ color = rgb(x, y, z)
+ box(1.2, 1.2, 1.2)
}
}
}
}
+ }
- extend {
- drawer.shadeStyle = shadeStyle {
- fragmentTransform = """
+ extend {
+ drawer.shadeStyle = shadeStyle {
+ fragmentTransform = """
x_fill = va_color;
vec3 s = sin(v_worldPosition.xyz * 2.5);
x_fill.rgb += s * 0.1 - 0.1;
""".trimIndent()
- }
- drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
}
+ drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude01.kt b/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude01.kt
index 2eae562a..a9ed6908 100644
--- a/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude01.kt
+++ b/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude01.kt
@@ -11,57 +11,55 @@ import org.openrndr.extra.shapes.splines.toPath3D
import org.openrndr.math.Vector3
import org.openrndr.shape.Circle
-fun main() {
- application {
- configure {
- width = 800
- height = 800
- multisample = WindowMultisample.SampleCount(8)
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ 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(-1.0, 0.0, 0.0)
+
+ for (i in 0 until 3) {
+ extrudeContourSteps(
+ Circle(0.0, 0.0, 0.5).contour,
+ path,
+ 160,
+ Vector3.UNIT_Y,
+ contourDistanceTolerance = 0.02,
+ pathDistanceTolerance = 0.001
+ )
+ translate(1.0, 0.0, 0.0)
+ }
+
+
}
- 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()
+ extend(Orbital()) {
+ this.eye = Vector3(0.0, 3.0, 7.0)
+ this.lookAt = Vector3(0.0, 2.0, 0.0)
+ }
-
- translate(-1.0, 0.0, 0.0)
-
- for (i in 0 until 3) {
- extrudeContourSteps(
- Circle(0.0, 0.0, 0.5).contour,
- path,
- 160,
- Vector3.UNIT_Y,
- contourDistanceTolerance = 0.02,
- pathDistanceTolerance = 0.001
- )
- translate(1.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 = """
+ extend {
+ drawer.shadeStyle = shadeStyle {
+ fragmentTransform = """
x_fill = va_color;
x_fill.rgb *= v_viewNormal.z;
""".trimIndent()
- }
-
- drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
}
+
+ drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude02.kt b/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude02.kt
index 64caa775..240d7a77 100644
--- a/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude02.kt
+++ b/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude02.kt
@@ -12,60 +12,56 @@ 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)
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ 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)
+ }
}
- 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()
+ extend(Orbital()) {
+ this.eye = Vector3(0.0, 3.0, 7.0)
+ this.lookAt = Vector3(0.0, 2.0, 0.0)
+ }
-
- 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 = """
+ extend {
+ drawer.shadeStyle = shadeStyle {
+ fragmentTransform = """
x_fill = va_color;
x_fill.rgb *= v_viewNormal.z;
""".trimIndent()
- }
-
- drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
}
+
+ drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude03.kt b/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude03.kt
index 421d249a..1ce96a8a 100644
--- a/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude03.kt
+++ b/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude03.kt
@@ -15,82 +15,76 @@ import org.openrndr.shape.Path3D
import kotlin.math.PI
import kotlin.math.exp
-fun main() {
- application {
- configure {
- width = 800
- height = 800
- multisample = WindowMultisample.SampleCount(8)
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ multisample = WindowMultisample.SampleCount(8)
+ }
+ program {
+ fun spiralPath(a: Double, k: Double, cycles: Double, steps: Int, direction: Double = 1.0): Path3D {
+ val points = (0 until steps).map {
+
+ val theta = ((PI * 2.0 * cycles) / steps) * it
+ val radius = a * exp(k * theta)
+
+ val c = Polar(theta.asDegrees, radius).cartesian
+ c.xy0
+ }
+ return Path3D.fromPoints(points, false)
}
- program {
- fun spiralPath(a: Double, k: Double, cycles: Double, steps: Int, direction:Double = 1.0): Path3D {
- val points = (0 until steps).map {
- val theta = ((PI * 2.0 * cycles) / steps) * it
- val radius = a * exp(k * theta)
+ val spiral = buildTriangleMesh {
+ for (i in -1..1 step 2) {
+ val p = spiralPath(0.2 * i, 0.25, 4.0, 400)
- val c = Polar(theta.asDegrees, radius).cartesian
- c.xy0
- }
- return Path3D.fromPoints(points, false)
+ extrudeContourAdaptive(
+ Circle(0.0, 0.0, 0.1).contour,
+ p,
+ Vector3.UNIT_Z,
+ contourDistanceTolerance = 0.02,
+ pathDistanceTolerance = 0.001
+ )
}
- val spiral = buildTriangleMesh {
- for (i in -1..1 step 2) {
- val p = spiralPath(0.2 * i, 0.25, 4.0, 400)
+ isolated {
+ color = ColorRGBa.YELLOW
+ rotate(Vector3.UNIT_X, 90.0)
- extrudeContourAdaptive(
- Circle(0.0, 0.0, 0.1).contour,
- p,
- Vector3.UNIT_Z,
- contourDistanceTolerance = 0.02,
- pathDistanceTolerance = 0.001
- )
- }
+ //rotate(Vector3.UNIT_Y, 45.0)
+ for (j in 0 until 1) {
+ for (i in -1..1 step 2) {
- isolated {
- color = ColorRGBa.YELLOW
- rotate(Vector3.UNIT_X, 90.0)
+ val rotationDegrees = j * 180.0 / 1.0
+ val rotation = rotationDegrees.asRadians
+ val scale = exp(rotation * 0.25)
- //rotate(Vector3.UNIT_Y, 45.0)
- for (j in 0 until 1) {
- for (i in -1..1 step 2) {
+ val p = spiralPath(0.2 * i * scale, 0.25, 4.0, 400)
- val rotationDegrees = j * 180.0 / 1.0
- val rotation = rotationDegrees.asRadians
- val scale = exp(rotation * 0.25)
-
- val p = spiralPath(0.2 * i * scale, 0.25, 4.0, 400)
-
- extrudeContourAdaptive(
- Circle(0.0, 0.0, 0.1).contour,
- p,
- Vector3.UNIT_Z,
- contourDistanceTolerance = 0.02,
- pathDistanceTolerance = 0.001
- )
- }
- rotate(Vector3.UNIT_Y, 180.0 / 1.0)
+ extrudeContourAdaptive(
+ Circle(0.0, 0.0, 0.1).contour,
+ p,
+ Vector3.UNIT_Z,
+ contourDistanceTolerance = 0.02,
+ pathDistanceTolerance = 0.001
+ )
}
+ rotate(Vector3.UNIT_Y, 180.0 / 1.0)
}
-
-
-
}
+ }
- extend(Orbital())
- extend {
- drawer.shadeStyle = shadeStyle {
- fragmentTransform = """
+ extend(Orbital())
+ extend {
+ drawer.shadeStyle = shadeStyle {
+ fragmentTransform = """
x_fill = va_color;
x_fill.rgb *= v_viewNormal.z;
""".trimIndent()
- }
-
- drawer.rotate(Vector3.UNIT_X, seconds*20.0)
- drawer.vertexBuffer(spiral, DrawPrimitive.TRIANGLES)
-
}
+
+ drawer.rotate(Vector3.UNIT_X, seconds * 20.0)
+ drawer.vertexBuffer(spiral, DrawPrimitive.TRIANGLES)
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude04.kt b/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude04.kt
index 0f5cd333..56cb2bda 100644
--- a/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude04.kt
+++ b/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude04.kt
@@ -16,71 +16,69 @@ import org.openrndr.shape.Segment3D
* Extruded Bézier tubes grown on a morphing Bézier surface.
*
*/
-fun main() {
- application {
- configure {
- width = 800
- height = 800
- multisample = WindowMultisample.SampleCount(8)
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ multisample = WindowMultisample.SampleCount(8)
+ }
+ program {
+ val crossSection = Circle(0.0, 0.0, 0.2).contour
+
+ extend(Orbital()) {
+ this.eye = Vector3(0.0, 3.0, 7.0)
+ this.lookAt = Vector3(0.0, 0.0, 0.0)
}
- program {
- val crossSection = Circle(0.0, 0.0, 0.2).contour
- extend(Orbital()) {
- this.eye = Vector3(0.0, 3.0, 7.0)
- this.lookAt = Vector3(0.0, 0.0, 0.0)
- }
-
- extend {
- drawer.shadeStyle = shadeStyle {
- fragmentTransform = """
+ extend {
+ drawer.shadeStyle = shadeStyle {
+ fragmentTransform = """
x_fill = va_color;
x_fill.rgb *= v_viewNormal.z;
""".trimIndent()
- }
-
- val m = buildTriangleMesh {
- val beziers = List(4) { curveId ->
- val n = List(12) {
- Random.simplex(it * 7.387, curveId * 5.531 + seconds * 0.05) * 10.0
- }
- Segment3D(
- Vector3(n[0], n[1], n[2]),
- Vector3(n[3], n[4], n[5]),
- Vector3(n[6], n[7], n[8]),
- Vector3(n[9], n[10], n[11])
- )
- }
-
- for (i in 0 until 20) {
- val t = i / (20.0 - 1.0)
- val path = Path3D(
- listOf(
- Segment3D(
- beziers[0].position(t),
- beziers[1].position(t),
- beziers[2].position(t),
- beziers[3].position(t)
- )
- ), false
- )
- color = if(i % 2 == 0) ColorRGBa.PINK else ColorRGBa.WHITE.shade(0.1)
- extrudeContourSteps(
- crossSection,
- path,
- 120,
- Vector3.UNIT_Y,
- contourDistanceTolerance = 0.05,
- pathDistanceTolerance = 0.05
- )
- }
- }
-
- drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
-
- // Remember to free the memory! Otherwise, the computer will quickly run out of RAM.
- m.destroy()
}
+
+ val m = buildTriangleMesh {
+ val beziers = List(4) { curveId ->
+ val n = List(12) {
+ Random.simplex(it * 7.387, curveId * 5.531 + seconds * 0.05) * 10.0
+ }
+ Segment3D(
+ Vector3(n[0], n[1], n[2]),
+ Vector3(n[3], n[4], n[5]),
+ Vector3(n[6], n[7], n[8]),
+ Vector3(n[9], n[10], n[11])
+ )
+ }
+
+ for (i in 0 until 20) {
+ val t = i / (20.0 - 1.0)
+ val path = Path3D(
+ listOf(
+ Segment3D(
+ beziers[0].position(t),
+ beziers[1].position(t),
+ beziers[2].position(t),
+ beziers[3].position(t)
+ )
+ ), false
+ )
+ color = if (i % 2 == 0) ColorRGBa.PINK else ColorRGBa.WHITE.shade(0.1)
+ extrudeContourSteps(
+ crossSection,
+ path,
+ 120,
+ Vector3.UNIT_Y,
+ contourDistanceTolerance = 0.05,
+ pathDistanceTolerance = 0.05
+ )
+ }
+ }
+
+ drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
+
+ // Remember to free the memory! Otherwise, the computer will quickly run out of RAM.
+ m.destroy()
}
}
}
diff --git a/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude05.kt b/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude05.kt
index 2d80da3c..83bcd763 100644
--- a/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude05.kt
+++ b/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude05.kt
@@ -18,72 +18,70 @@ import kotlin.math.cos
* Extruded Bézier tubes grown on a morphing Bézier surface.
*
*/
-fun main() {
- application {
- configure {
- width = 800
- height = 800
- multisample = WindowMultisample.SampleCount(8)
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ multisample = WindowMultisample.SampleCount(8)
+ }
+ program {
+ val crossSection = Circle(0.0, 0.0, 0.2).contour
+
+ extend(Orbital()) {
+ this.eye = Vector3(0.0, 3.0, 7.0)
+ this.lookAt = Vector3(0.0, 0.0, 0.0)
}
- program {
- val crossSection = Circle(0.0, 0.0, 0.2).contour
- extend(Orbital()) {
- this.eye = Vector3(0.0, 3.0, 7.0)
- this.lookAt = Vector3(0.0, 0.0, 0.0)
- }
-
- extend {
- drawer.shadeStyle = shadeStyle {
- fragmentTransform = """
+ extend {
+ drawer.shadeStyle = shadeStyle {
+ fragmentTransform = """
x_fill = va_color;
x_fill.rgb *= v_viewNormal.z;
""".trimIndent()
- }
-
- val m = buildTriangleMesh {
- val beziers = List(4) { curveId ->
- val n = List(12) {
- Random.simplex(it * 7.387, curveId * 5.531 + seconds * 0.05) * 10.0
- }
- Segment3D(
- Vector3(n[0], n[1], n[2]),
- Vector3(n[3], n[4], n[5]),
- Vector3(n[6], n[7], n[8]),
- Vector3(n[9], n[10], n[11])
- )
- }
-
- for (i in 0 until 20) {
- val t = i / (20.0 - 1.0)
- val path = Path3D(
- listOf(
- Segment3D(
- beziers[0].position(t),
- beziers[1].position(t),
- beziers[2].position(t),
- beziers[3].position(t)
- )
- ), false
- )
- color = if(i % 2 == 0) ColorRGBa.PINK else ColorRGBa.WHITE.shade(0.1)
- extrudeContourStepsScaled(
- crossSection,
- path,
- 120,
- Vector3.UNIT_Y,
- contourDistanceTolerance = 0.05,
- pathDistanceTolerance = 0.05,
- scale = { tt: Double -> 0.5 - 0.5 * cos(tt * 2 * PI) }
- )
- }
- }
-
- drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
-
- // Remember to free the memory! Otherwise, the computer will quickly run out of RAM.
- m.destroy()
}
+
+ val m = buildTriangleMesh {
+ val beziers = List(4) { curveId ->
+ val n = List(12) {
+ Random.simplex(it * 7.387, curveId * 5.531 + seconds * 0.05) * 10.0
+ }
+ Segment3D(
+ Vector3(n[0], n[1], n[2]),
+ Vector3(n[3], n[4], n[5]),
+ Vector3(n[6], n[7], n[8]),
+ Vector3(n[9], n[10], n[11])
+ )
+ }
+
+ for (i in 0 until 20) {
+ val t = i / (20.0 - 1.0)
+ val path = Path3D(
+ listOf(
+ Segment3D(
+ beziers[0].position(t),
+ beziers[1].position(t),
+ beziers[2].position(t),
+ beziers[3].position(t)
+ )
+ ), false
+ )
+ color = if (i % 2 == 0) ColorRGBa.PINK else ColorRGBa.WHITE.shade(0.1)
+ extrudeContourStepsScaled(
+ crossSection,
+ path,
+ 120,
+ Vector3.UNIT_Y,
+ contourDistanceTolerance = 0.05,
+ pathDistanceTolerance = 0.05,
+ scale = { tt: Double -> 0.5 - 0.5 * cos(tt * 2 * PI) }
+ )
+ }
+ }
+
+ drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
+
+ // Remember to free the memory! Otherwise, the computer will quickly run out of RAM.
+ m.destroy()
}
}
}
diff --git a/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude06.kt b/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude06.kt
index 44cc90d7..491a608b 100644
--- a/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude06.kt
+++ b/orx-mesh-generators/src/jvmDemo/kotlin/DemoExtrude06.kt
@@ -22,25 +22,24 @@ import kotlin.math.cos
* based on the t value along a Path3D. In other words, a tube in which the cross-section does not need
* to be constant, but can be scaled, rotated and displaced along its curvy axis.
*/
-fun main() {
- application {
- configure {
- width = 800
- height = 800
- multisample = WindowMultisample.SampleCount(8)
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ multisample = WindowMultisample.SampleCount(8)
+ }
+ program {
+ Random.seed = System.currentTimeMillis().toString()
+
+ val texture = loadImage("demo-data/images/peopleCity01.jpg").also {
+ it.wrapU = WrapMode.REPEAT
+ it.wrapV = WrapMode.REPEAT
+ it.filterMag = MagnifyingFilter.LINEAR
+ it.filterMin = MinifyingFilter.LINEAR
}
- program {
- Random.seed = System.currentTimeMillis().toString()
- val texture = loadImage("demo-data/images/peopleCity01.jpg").also {
- it.wrapU = WrapMode.REPEAT
- it.wrapV = WrapMode.REPEAT
- it.filterMag = MagnifyingFilter.LINEAR
- it.filterMin = MinifyingFilter.LINEAR
- }
-
- val shader = shadeStyle {
- fragmentTransform = """
+ val shader = shadeStyle {
+ fragmentTransform = """
// A. Passed color
x_fill = va_color;
@@ -56,38 +55,37 @@ fun main() {
// Black fog (darken far away shapes)
x_fill.rgb += v_viewPosition.z * 0.05;
""".trimIndent()
- parameter("img", texture)
- }
+ parameter("img", texture)
+ }
- extend(Orbital()) {
- eye = Vector3(0.0, 3.0, 7.0)
- lookAt = Vector3(0.0, 0.0, 0.0)
- }
- extend {
- drawer.stroke = null
+ extend(Orbital()) {
+ eye = Vector3(0.0, 3.0, 7.0)
+ lookAt = Vector3(0.0, 0.0, 0.0)
+ }
+ extend {
+ drawer.stroke = null
- val path = get3DPath(10.0, seconds * 0.05, 400)
- val tubes = makeTubes(path, seconds * 0.2)
+ val path = get3DPath(10.0, seconds * 0.05, 400)
+ val tubes = makeTubes(path, seconds * 0.2)
- shader.parameter("seconds", seconds * 0.1)
- drawer.fill = ColorRGBa.WHITE
- drawer.shadeStyle = shader
- tubes.forEachIndexed { i, vb ->
- shader.parameter("offset", i * 0.3 + 0.2)
+ shader.parameter("seconds", seconds * 0.1)
+ drawer.fill = ColorRGBa.WHITE
+ drawer.shadeStyle = shader
+ tubes.forEachIndexed { i, vb ->
+ shader.parameter("offset", i * 0.3 + 0.2)
- // Mirror the mesh 5 times
- repeat(5) {
- drawer.isolated {
- rotate(Vector3.UNIT_Z, it * 72.0)
- vertexBuffer(vb, DrawPrimitive.TRIANGLES)
- }
+ // Mirror the mesh 5 times
+ repeat(5) {
+ drawer.isolated {
+ rotate(Vector3.UNIT_Z, it * 72.0)
+ vertexBuffer(vb, DrawPrimitive.TRIANGLES)
}
-
- // Remember to free the memory! Otherwise, the computer will quickly run out of RAM.
- vb.destroy()
}
+ // Remember to free the memory! Otherwise, the computer will quickly run out of RAM.
+ vb.destroy()
}
+
}
}
}
diff --git a/orx-mesh-generators/src/jvmDemo/kotlin/decal/DemoDecal01.kt b/orx-mesh-generators/src/jvmDemo/kotlin/decal/DemoDecal01.kt
index c98ca3c1..04d08e99 100644
--- a/orx-mesh-generators/src/jvmDemo/kotlin/decal/DemoDecal01.kt
+++ b/orx-mesh-generators/src/jvmDemo/kotlin/decal/DemoDecal01.kt
@@ -15,42 +15,40 @@ import java.io.File
* Demonstrate decal generator as an object slicer
* @see
*/
-fun main() {
- application {
- configure {
- width = 720
- height = 720
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ }
+ program {
+ val obj = loadOBJMeshData(File("demo-data/obj-models/suzanne/Suzanne.obj")).toMeshData().triangulate()
+
+ val slices = 25
+ val sliceStep = 0.1
+ val sliceWidth = 0.14
+
+ val sliceVBs = (0 until slices).map {
+ val projector = buildTransform {
+ translate(0.0, 0.0, -1.0 + it * sliceStep)
+ }
+ val decal = obj.decal(projector, Vector3(4.0, 4.0, sliceWidth))
+ val vb = decal.toVertexBuffer()
+ vb
}
- program {
- val obj = loadOBJMeshData(File("demo-data/obj-models/suzanne/Suzanne.obj")).toMeshData().triangulate()
- val slices = 25
- val sliceStep = 0.1
- val sliceWidth = 0.14
-
- val sliceVBs = (0 until slices).map {
- val projector = buildTransform {
- translate(0.0, 0.0, -1.0 + it * sliceStep)
- }
- val decal = obj.decal(projector, Vector3(4.0, 4.0, sliceWidth))
- val vb = decal.toVertexBuffer()
- vb
+ extend(Orbital()) {
+ eye = Vector3(0.0, 0.0, 2.0)
+ }
+ extend {
+ drawer.shadeStyle = shadeStyle {
+ fragmentTransform = """x_fill.rgb = v_viewNormal.rgb * 0.5 + 0.5; """
}
- extend(Orbital()) {
- eye = Vector3(0.0, 0.0, 2.0)
- }
- extend {
- drawer.shadeStyle = shadeStyle {
- fragmentTransform = """x_fill.rgb = v_viewNormal.rgb * 0.5 + 0.5; """
- }
-
- drawer.translate(0.0, 0.0, slices * 0.5 * 0.5)
- for (i in 0 until sliceVBs.size) {
- drawer.vertexBuffer(sliceVBs[i], DrawPrimitive.TRIANGLES)
- drawer.translate(0.0, 0.0, -0.5)
- }
+ drawer.translate(0.0, 0.0, slices * 0.5 * 0.5)
+ for (i in 0 until sliceVBs.size) {
+ drawer.vertexBuffer(sliceVBs[i], DrawPrimitive.TRIANGLES)
+ drawer.translate(0.0, 0.0, -0.5)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-mesh-generators/src/jvmDemo/kotlin/decal/DemoDecal02.kt b/orx-mesh-generators/src/jvmDemo/kotlin/decal/DemoDecal02.kt
index e0bf39ff..378281c8 100644
--- a/orx-mesh-generators/src/jvmDemo/kotlin/decal/DemoDecal02.kt
+++ b/orx-mesh-generators/src/jvmDemo/kotlin/decal/DemoDecal02.kt
@@ -17,71 +17,69 @@ import kotlin.math.PI
* Demonstrate decal generation and rendering
* @see
*/
-fun main() {
- application {
- configure {
- width = 720
- height = 720
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ }
+ program {
+ /** base object */
+ val obj = loadOBJMeshData(File("demo-data/obj-models/suzanne/Suzanne.obj"))
+ .toMeshData() // convert from CompoundMeshData to MeshData
+ .triangulate() // convert to triangles, we need this for the decal generation steps
+
+ /** object [VertexBuffer] */
+ val objVB = obj.toVertexBuffer()
+
+
+ /** positions for the decal projectors */
+ val decalPositions = listOf(
+ Vector3(0.35, 0.245, 0.8),
+ Vector3(-0.35, 0.245, 0.8)
+ )
+
+ /** decal vertex buffers */
+ val decalVBs = decalPositions.map {
+ val projector = buildTransform {
+ translate(it)
+ }
+ val decal = obj.decal(projector, Vector3(2.0, 2.0, 0.5))
+ val vb = decal.toVertexBuffer()
+ vb
}
- program {
- /** base object */
- val obj = loadOBJMeshData(File("demo-data/obj-models/suzanne/Suzanne.obj"))
- .toMeshData() // convert from CompoundMeshData to MeshData
- .triangulate() // convert to triangles, we need this for the decal generation steps
- /** object [VertexBuffer] */
- val objVB = obj.toVertexBuffer()
-
-
- /** positions for the decal projectors */
- val decalPositions = listOf(
- Vector3(0.35, 0.245, 0.8),
- Vector3(-0.35, 0.245, 0.8)
- )
-
- /** decal vertex buffers */
- val decalVBs = decalPositions.map {
- val projector = buildTransform {
- translate(it)
+ extend(Orbital()) {
+ eye = Vector3(0.0, 0.0, 2.0)
+ }
+ extend {
+ /* draw the base mesh */
+ drawer.isolated {
+ drawer.shadeStyle = shadeStyle {
+ fragmentTransform = """x_fill.rgb = vec3(v_viewNormal * 0.5 + 0.5); """
}
- val decal = obj.decal(projector, Vector3(2.0, 2.0, 0.5))
- val vb = decal.toVertexBuffer()
- vb
+ drawer.vertexBuffer(objVB, DrawPrimitive.TRIANGLES)
}
- extend(Orbital()) {
- eye = Vector3(0.0, 0.0, 2.0)
- }
- extend {
- /* draw the base mesh */
- drawer.isolated {
+ /* draw the decals */
+ drawer.isolated {
+ for ((index, decal) in decalVBs.withIndex()) {
+ /* offset the projection transform to avoid z-fighting */
+ drawer.projection = buildTransform {
+ translate(0.0, 0.0, -1e-4)
+ } * drawer.projection
+
+ /* draw effects on the decal geometry */
drawer.shadeStyle = shadeStyle {
- fragmentTransform = """x_fill.rgb = vec3(v_viewNormal * 0.5 + 0.5); """
- }
- drawer.vertexBuffer(objVB, DrawPrimitive.TRIANGLES)
- }
-
- /* draw the decals */
- drawer.isolated {
- for ((index, decal) in decalVBs.withIndex()) {
- /* offset the projection transform to avoid z-fighting */
- drawer.projection = buildTransform {
- translate(0.0, 0.0, -1e-4)
- } * drawer.projection
-
- /* draw effects on the decal geometry */
- drawer.shadeStyle = shadeStyle {
- fragmentTransform = """
+ fragmentTransform = """
float d = length(va_texCoord0.xy - vec2(0.5));
float sd = smoothstep(-0.01, 0.01, cos(p_time + d * 3.1415 * 2.0 * 10.0));
float l = max(0.0, va_normal.z);
x_fill = vec4(0.0, 0.0, 0.0, l * sd * 0.5); """
- parameter("time", seconds * PI * 2 + index * PI)
- }
- drawer.vertexBuffer(decal, DrawPrimitive.TRIANGLES)
+ parameter("time", seconds * PI * 2 + index * PI)
}
+ drawer.vertexBuffer(decal, DrawPrimitive.TRIANGLES)
}
}
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-mesh-generators/src/jvmDemo/kotlin/tangents/DemoTangents01.kt b/orx-mesh-generators/src/jvmDemo/kotlin/tangents/DemoTangents01.kt
index cde4c609..3df7e00c 100644
--- a/orx-mesh-generators/src/jvmDemo/kotlin/tangents/DemoTangents01.kt
+++ b/orx-mesh-generators/src/jvmDemo/kotlin/tangents/DemoTangents01.kt
@@ -11,6 +11,10 @@ import org.openrndr.math.Vector3
import java.io.File
fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ }
program {
val obj = loadOBJMeshData(File("demo-data/obj-models/suzanne/Suzanne.obj")).toMeshData().triangulate()
val tangentObj = obj.estimateTangents()
diff --git a/orx-no-clear/README.md b/orx-no-clear/README.md
index f12c0cd4..1316acf4 100644
--- a/orx-no-clear/README.md
+++ b/orx-no-clear/README.md
@@ -25,7 +25,7 @@ Optionally, a static `backdrop` may be setup by providing custom code.
- Example 1. Customising the backdrop with an image
```kotlin
extend(NoClear()) {
- val img = loadImage("data\\backdrop.png")
+ val img = loadImage("data/backdrop.png")
backdrop = {
drawer.image(img, 0.0, 0.0, width * 1.0, height * 1.0)
}
diff --git a/orx-no-clear/src/jvmDemo/kotlin/DemoNoClear.kt b/orx-no-clear/src/jvmDemo/kotlin/DemoNoClear.kt
index c2d4ea17..4994a97a 100644
--- a/orx-no-clear/src/jvmDemo/kotlin/DemoNoClear.kt
+++ b/orx-no-clear/src/jvmDemo/kotlin/DemoNoClear.kt
@@ -2,60 +2,72 @@ import org.openrndr.application
import org.openrndr.color.ColorHSLa
import org.openrndr.color.rgb
import org.openrndr.draw.isolated
+import org.openrndr.extensions.SingleScreenshot
import org.openrndr.extra.noclear.NoClear
import org.openrndr.math.Polar
import org.openrndr.shape.contour
import kotlin.math.sin
-fun main() {
- application {
- program {
- var time = 0.0
+fun main() = application {
+ configure {
+ width = 720
+ height = 540
+ }
+ program {
+ var time = 0.0
- // ------------------------------------------------------------
- // By default OPENRNDR clears the canvas on each animation
- // frame. NoClear disables that behavior, letting you
- // draw on top of what you drew previously.
- // That's the default in some other frameworks.
- // ------------------------------------------------------------
- extend(NoClear()) {
- // backdrop is optional and it sets the initial state
- // of the canvas. It can be a generative pattern, an image
- // loaded from disk... In this case we start with dark gray.
- backdrop = { drawer.clear(rgb(0.15)) }
+ // ------------------------------------------------------------
+ // By default OPENRNDR clears the canvas on each animation
+ // frame. NoClear disables that behavior, letting you
+ // draw on top of what you drew previously.
+ // That's the default in some other frameworks.
+ // ------------------------------------------------------------
+ extend(NoClear()) {
+ // backdrop is optional, and it sets the initial state
+ // of the canvas. It can be code generated or an image
+ // loaded from disk. In this case we start with dark gray.
+ backdrop = { drawer.clear(rgb(0.15)) }
+ }
+
+ if (System.getProperty("takeScreenshot") == "true") {
+ extensions.filterIsInstance().forEach {
+ it.delayFrames = 60
}
+ }
+ extend {
+ // Draw something. For this demo *what* you draw is not so
+ // important, only the fact that it stays on the canvas
+ // until you draw something else on top of it.
- extend {
- // Draw something. For this demo *what* you draw is not so
- // important, only the fact that it stays on the canvas
- // until you draw something else on top of it.
+ drawer.isolated {
+ // center the origin
+ translate(bounds.center)
- drawer.isolated {
- // center the origin
- translate(bounds.center)
+ for (i in 0..5) {
+ time += 0.01
- for(i in 0..5) {
- time += 0.01
-
- // Make a list of 4 points rotating around the center at
- // different speeds
- val points = List(4) {
- Polar(time * (15.0 + it * 5),
- 250.0 * sin(time + it * 65)).cartesian
- }
-
- // Use those 4 points to create a bezier curve
- val c = contour {
- moveTo(points.first())
- curveTo(points[1], points[2], points.last())
- }
-
- // Draw the curve with increasing hue and lightness modulation
- fill = null
- stroke = ColorHSLa(time * 10.0, 0.8,
- 0.5 + 0.2 * sin(time * 3), 0.5).toRGBa()
- contour(c)
+ // Make a list of 4 points rotating around the center at
+ // different speeds
+ val points = List(4) {
+ Polar(
+ time * (15.0 + it * 5),
+ 250.0 * sin(time + it * 65)
+ ).cartesian
}
+
+ // Use those 4 points to create a Bézier curve
+ val c = contour {
+ moveTo(points.first())
+ curveTo(points[1], points[2], points.last())
+ }
+
+ // Draw the curve with increasing hue and lightness modulation
+ fill = null
+ stroke = ColorHSLa(
+ time * 10.0, 0.8,
+ 0.5 + 0.2 * sin(time * 3), 0.5
+ ).toRGBa()
+ contour(c)
}
}
}
diff --git a/orx-obj-loader/src/jvmDemo/kotlin/DemoObjCompoundRW01.kt b/orx-obj-loader/src/jvmDemo/kotlin/DemoObjCompoundRW01.kt
index 79701f22..64636464 100644
--- a/orx-obj-loader/src/jvmDemo/kotlin/DemoObjCompoundRW01.kt
+++ b/orx-obj-loader/src/jvmDemo/kotlin/DemoObjCompoundRW01.kt
@@ -1,15 +1,32 @@
import org.openrndr.application
+import org.openrndr.draw.loadFont
import org.openrndr.extra.objloader.loadOBJMeshData
import org.openrndr.extra.objloader.toObj
+import org.openrndr.math.Vector2
import java.io.File
-fun main() {
- application {
- program {
- val path = "demo-data/obj-models"
- val cm = loadOBJMeshData(File("$path/suzanne/Suzanne.obj"))
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ }
+ program {
+ val path = "demo-data/obj-models"
+ val cm = loadOBJMeshData(File("$path/suzanne/Suzanne.obj"))
- println(cm.toObj())
+ // Convert mesh data to Wavefront OBJ String representation
+ val obj = cm.toObj()
+
+ println(obj)
+
+ val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 24.0)
+
+ extend {
+ // Draw part of the OBJ data as text
+ drawer.fontMap = font
+ drawer.texts(obj.split("\n").take(50), List(50) {
+ Vector2(10.0, 20.0 + it * 20.0)
+ })
}
}
-}
\ No newline at end of file
+}
diff --git a/orx-obj-loader/src/jvmDemo/kotlin/DemoObjLoader01.kt b/orx-obj-loader/src/jvmDemo/kotlin/DemoObjLoader01.kt
index 470f5245..cd642a18 100644
--- a/orx-obj-loader/src/jvmDemo/kotlin/DemoObjLoader01.kt
+++ b/orx-obj-loader/src/jvmDemo/kotlin/DemoObjLoader01.kt
@@ -7,6 +7,10 @@ import org.openrndr.extra.objloader.loadOBJasVertexBuffer
import org.openrndr.math.Vector3
fun main() = application {
+ configure {
+ width = 720
+ height = 540
+ }
program {
val mesh = loadOBJasVertexBuffer("demo-data/obj-models/suzanne/Suzanne.obj")
diff --git a/orx-obj-loader/src/jvmDemo/kotlin/DemoObjSaver01.kt b/orx-obj-loader/src/jvmDemo/kotlin/DemoObjSaver01.kt
index 68bef7b1..047fb842 100644
--- a/orx-obj-loader/src/jvmDemo/kotlin/DemoObjSaver01.kt
+++ b/orx-obj-loader/src/jvmDemo/kotlin/DemoObjSaver01.kt
@@ -5,6 +5,7 @@ import org.openrndr.extra.objloader.saveOBJ
fun main() = application {
configure {
+ width = 720
height = 100
}
program {
diff --git a/orx-obj-loader/src/jvmDemo/kotlin/DemoObjSaver02.kt b/orx-obj-loader/src/jvmDemo/kotlin/DemoObjSaver02.kt
index 6277e4c5..18820e11 100644
--- a/orx-obj-loader/src/jvmDemo/kotlin/DemoObjSaver02.kt
+++ b/orx-obj-loader/src/jvmDemo/kotlin/DemoObjSaver02.kt
@@ -6,6 +6,7 @@ import org.openrndr.extra.objloader.saveOBJ
fun main() = application {
configure {
+ width = 720
height = 100
}
program {
diff --git a/orx-obj-loader/src/jvmDemo/kotlin/DemoWireframe01.kt b/orx-obj-loader/src/jvmDemo/kotlin/DemoWireframe01.kt
index 85c82524..c8310dac 100644
--- a/orx-obj-loader/src/jvmDemo/kotlin/DemoWireframe01.kt
+++ b/orx-obj-loader/src/jvmDemo/kotlin/DemoWireframe01.kt
@@ -16,48 +16,46 @@ import org.openrndr.shape.Path3D
import java.io.File
import kotlin.math.cos
-fun main() {
- application {
- configure {
- width = 720
- height = 720
- multisample = WindowMultisample.SampleCount(4)
+fun main() = application {
+ configure {
+ width = 720
+ height = 720
+ multisample = WindowMultisample.SampleCount(4)
+ }
+ program {
+ val vb = loadOBJasVertexBuffer("orx-obj-loader/test-data/non-planar.obj")
+ val md = readObjMeshData(File("orx-obj-loader/test-data/non-planar.obj").readLines())
+
+ val paths = md.wireframe().map {
+ Path3D.fromPoints(it, true)
}
- program {
- val vb = loadOBJasVertexBuffer("orx-obj-loader/test-data/non-planar.obj")
- val md = readObjMeshData(File("orx-obj-loader/test-data/non-planar.obj").readLines())
- val paths = md.wireframe().map {
- Path3D.fromPoints(it, true)
- }
-
- extend(Orbital())
- extend {
- drawer.rotate(Vector3.Companion.UNIT_Y, seconds * 45.0 + 45.0, TransformTarget.MODEL)
- drawer.translate(0.0, 0.0, 9.0, TransformTarget.VIEW)
- drawer.shadeStyle = shadeStyle {
- fragmentTransform = """
+ extend(Orbital())
+ extend {
+ drawer.rotate(Vector3.Companion.UNIT_Y, seconds * 45.0 + 45.0, TransformTarget.MODEL)
+ drawer.translate(0.0, 0.0, 9.0, TransformTarget.VIEW)
+ drawer.shadeStyle = shadeStyle {
+ fragmentTransform = """
x_fill.rgb = normalize(v_viewNormal) * 0.5 + vec3(0.5);
""".trimIndent()
- }
+ }
- drawer.vertexBuffer(vb, DrawPrimitive.TRIANGLES)
- drawer.stroke = ColorRGBa.WHITE
- drawer.strokeWeight = 1.0
+ drawer.vertexBuffer(vb, DrawPrimitive.TRIANGLES)
+ drawer.stroke = ColorRGBa.WHITE
+ drawer.strokeWeight = 1.0
- drawer.shadeStyle = shadeStyle {
- vertexTransform = """
+ drawer.shadeStyle = shadeStyle {
+ vertexTransform = """
x_projectionMatrix[3][2] -= 0.001;
""".trimIndent()
- }
-
- drawer.strokeWeight = 1.0
- drawer.paths(paths.mapIndexed { index, it ->
- it.sub(
- 0.0, cos(seconds * 0.5 + index * 0.5) * 0.5 + 0.5
- )
- })
}
+
+ drawer.strokeWeight = 1.0
+ drawer.paths(paths.mapIndexed { index, it ->
+ it.sub(
+ 0.0, cos(seconds * 0.5 + index * 0.5) * 0.5 + 0.5
+ )
+ })
}
}
-}
\ No newline at end of file
+}