[orx-math] Add orx-math module

This commit is contained in:
Edwin Jakobs
2025-02-02 11:24:39 +01:00
parent 13bc4bc472
commit c88c4454e1
10 changed files with 555 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
package simplexrange
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.boxMesh
import org.openrndr.extra.math.simplexrange.SimplexRange3D
import org.openrndr.math.Vector3
fun main() {
application {
configure {
width = 720
height = 720
}
program {
val box = boxMesh()
extend(Orbital()) {
eye = Vector3(1.0, -1.0, 1.0).normalized * 140.0
fov = 15.0
}
extend {
val sr = SimplexRange3D(
ColorRGBa.PINK.toLinear(),
ColorRGBa.RED.toLinear(),
ColorRGBa.MAGENTA.toLinear(),
ColorRGBa.BLUE.toLinear()
)
for (z in 0 until 20)
for (y in 0 until 20)
for (x in 0 until 20) {
drawer.isolated {
drawer.translate(x - 10.0, y - 10.0, z - 10.0)
drawer.fill = sr.value(x / 20.0, y / 20.0, z / 20.0)
drawer.vertexBuffer(box, DrawPrimitive.TRIANGLES)
}
}
}
}
}
}