-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathDemoRseq4D01.kt
52 lines (49 loc) · 1.91 KB
/
DemoRseq4D01.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
package rseq
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.DrawPrimitive
import org.openrndr.draw.isolated
import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.meshgenerators.sphereMesh
import org.openrndr.extra.noise.rsequence.rSeq3D
import org.openrndr.extra.noise.rsequence.rSeq4D
import org.openrndr.math.Vector3
import org.openrndr.math.Vector4
import kotlin.math.abs
import kotlin.math.min
/**
* Demo that presents a 3D visualization of points distributed using a 4D quasirandom sequence (R4).
* Each point is represented as a sphere with it position and color derived from the sequence values.
*
* This function performs the following tasks:
* - Configures the application window dimensions to 720x720 pixels.
* - Initializes a 3D camera for orbital navigation of the scene.
* - Generates 10,000 points in 4D space using the `rSeq4D` function. The points are scaled
* and transformed into 3D positions with an additional w-coordinate for color variation.
* - Creates a reusable sphere mesh for rendering.
* - Renders each point as a sphere with its position determined by the 3D coordinates
* of the point and its color calculated by shifting the hue of a base color using
* the w-coordinate value.
*/
fun main() = application {
configure {
width = 720
height = 720
}
program {
val sphere = sphereMesh(radius = 0.1)
val points = (0 until 10000).map {
(rSeq4D(it) - Vector4(0.5, 0.5, 0.5, 0.0)) * Vector4(10.0, 10.0, 10.0, 1.0)
}
extend(Orbital())
extend {
for (point in points) {
drawer.isolated {
drawer.translate(point.xyz)
drawer.fill = ColorRGBa.RED.toHSVa().shiftHue(point.w * 360.0).toRGBa()
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
}
}
}
}
}