[orx-hash-grid] Add HashGrid3D

This commit is contained in:
Edwin Jakobs
2024-05-13 12:26:13 +02:00
parent 0a4e3fb0a7
commit 334a0c6dd9
5 changed files with 228 additions and 1 deletions

View File

@@ -16,7 +16,7 @@ fun main() {
}
val filteredPoints = points.filter(20.0)
extend {
drawer.circles(filteredPoints, 4.0)
drawer.circles(filteredPoints, 10.0)
}
}
}

View File

@@ -0,0 +1,42 @@
import org.openrndr.WindowMultisample
import org.openrndr.application
import org.openrndr.draw.DrawPrimitive
import org.openrndr.draw.isolated
import org.openrndr.draw.shadeStyle
import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.hashgrid.filter
import org.openrndr.extra.meshgenerators.sphereMesh
import org.openrndr.extra.noise.uniformRing
import org.openrndr.math.Vector3
import kotlin.random.Random
fun main() = application {
configure {
width = 720
height = 720
multisample = WindowMultisample.SampleCount(4)
}
program {
val r = Random(0)
val points = (0 until 10000).map {
Vector3.uniformRing(0.0, 10.0, r)
}
val sphere = sphereMesh(radius = 0.25)
val filteredPoints = points.filter(0.5)
extend(Orbital()) {
eye = Vector3(0.0, 0.0, 15.0)
}
extend {
drawer.shadeStyle = shadeStyle {
fragmentTransform = """x_fill.rgb *= abs(v_viewNormal.z);"""
}
for (point in filteredPoints) {
drawer.isolated {
drawer.translate(point)
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
}
}
}
}
}