[orx-mesh-generators] Comment extrude demos

Remove deprecated use of Random.
This commit is contained in:
Abe Pazos
2025-08-28 11:45:20 +02:00
parent c8e02bfb1c
commit a4079327dd
6 changed files with 73 additions and 14 deletions

View File

@@ -11,6 +11,16 @@ import org.openrndr.extra.shapes.splines.toPath3D
import org.openrndr.math.Vector3
import org.openrndr.shape.Circle
/**
* Demonstrates how to create curved tubes by extruding
* a circular contour along a 3D catmullRom-path
* using [buildTriangleMesh] and [extrudeContourSteps].
*
* The result is a [org.openrndr.draw.VertexBuffer] which can be rendered with
* `drawer.vertexBuffer()`.
* An [Orbital] camera makes the scene interactive. A minimal `shadeStyle` is used
* to simulate a directional light.
*/
fun main() = application {
configure {
width = 720

View File

@@ -12,6 +12,16 @@ import org.openrndr.math.Vector3
import org.openrndr.shape.Circle
import org.openrndr.shape.Shape
/**
* Demonstrates how to create hollow tubes with thickness by extruding
* a circular [Shape] built out of two concentric circular contours.
* Note that the inner contour is reversed.
*
* The result is a [org.openrndr.draw.VertexBuffer] which can be rendered with
* `drawer.vertexBuffer()`.
* An [Orbital] camera makes the scene interactive. A minimal `shadeStyle` is used
* to simulate a directional light.
*/
fun main() = application {
configure {
width = 720
@@ -33,7 +43,12 @@ fun main() = application {
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))
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(

View File

@@ -6,6 +6,7 @@ import org.openrndr.draw.shadeStyle
import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.meshgenerators.buildTriangleMesh
import org.openrndr.extra.meshgenerators.extrudeContourAdaptive
import org.openrndr.extra.meshgenerators.extrudeContourSteps
import org.openrndr.math.Polar
import org.openrndr.math.Vector3
import org.openrndr.math.asDegrees
@@ -15,6 +16,19 @@ import org.openrndr.shape.Path3D
import kotlin.math.PI
import kotlin.math.exp
/**
* Demonstration creating two intersecting spirals
* using [buildTriangleMesh] and [extrudeContourAdaptive].
* This approach generates as many vertices as needed
* based on the provided tolerance.
*
* The result is a [org.openrndr.draw.VertexBuffer] which can be rendered with
* `drawer.vertexBuffer()`.
*
* The [Orbital] camera slowly rotates on its own while
* still being interactive.
* A minimal `shadeStyle` is used to simulate a directional light.
*/
fun main() = application {
configure {
width = 720

View File

@@ -6,14 +6,22 @@ import org.openrndr.draw.shadeStyle
import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.meshgenerators.buildTriangleMesh
import org.openrndr.extra.meshgenerators.extrudeContourSteps
import org.openrndr.extra.noise.Random
import org.openrndr.extra.noise.simplex
import org.openrndr.math.Vector3
import org.openrndr.shape.Circle
import org.openrndr.shape.Path3D
import org.openrndr.shape.Segment3D
/**
* Extruded Bézier tubes grown on a morphing Bézier surface.
* A series of 3D Bézier tubes grown on an animated,
* morphing, invisible Bézier surface.
*
* As if we were drawing a series of parallel lines
* on a piece of paper, then twisting and bending
* that paper over time.
*
* Demonstrates how to destroy a [org.openrndr.draw.VertexBuffer]
* on every animation frame to avoid filling out the memory.
*
*/
fun main() = application {
@@ -41,7 +49,7 @@ fun main() = application {
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
simplex(1413, it * 7.387, curveId * 5.531 + seconds * 0.05) * 10.0
}
Segment3D(
Vector3(n[0], n[1], n[2]),

View File

@@ -6,7 +6,7 @@ import org.openrndr.draw.shadeStyle
import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.meshgenerators.buildTriangleMesh
import org.openrndr.extra.meshgenerators.extrudeContourStepsScaled
import org.openrndr.extra.noise.Random
import org.openrndr.extra.noise.simplex
import org.openrndr.math.Vector3
import org.openrndr.shape.Circle
import org.openrndr.shape.Path3D
@@ -15,7 +15,15 @@ import kotlin.math.PI
import kotlin.math.cos
/**
* Extruded Bézier tubes grown on a morphing Bézier surface.
* A series of 3D Bézier tubes grown on an animated,
* morphing, invisible Bézier surface.
*
* This variation uses [extrudeContourStepsScaled] to
* apply a varying scaling to the cross-sections,
* making the ends shrink to a hairline.
*
* Calls `destroy` on the [org.openrndr.draw.VertexBuffer]
* on every animation frame to free the used memory.
*
*/
fun main() = application {
@@ -43,7 +51,7 @@ fun main() = application {
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
simplex(7453, it * 7.387, curveId * 5.531 + seconds * 0.05) * 10.0
}
Segment3D(
Vector3(n[0], n[1], n[2]),

View File

@@ -5,7 +5,6 @@ import org.openrndr.draw.*
import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.meshgenerators.buildTriangleMesh
import org.openrndr.extra.meshgenerators.extrudeContourStepsMorphed
import org.openrndr.extra.noise.Random
import org.openrndr.extra.noise.simplex
import org.openrndr.math.Polar
import org.openrndr.math.Vector2
@@ -18,9 +17,16 @@ import kotlin.math.PI
import kotlin.math.cos
/**
* Demo extrudeContourStepsMorphed which allows to create a mesh with a morphing cross-section
* 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.
* Demo [extrudeContourStepsMorphed] which allows creating a mesh with an animated, morphing cross-section
* 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 curved axis.
*
* Loads a texture and applies a repeat-wrapping mode to it.
* The texture can be enabled in the GLSL code inside
* the shadeStyle.
*
* The mesh is rendered 5 times rotated around axis Z
* for a radial-symmetry effect.
*/
fun main() = application {
configure {
@@ -29,8 +35,6 @@ fun main() = application {
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
@@ -94,7 +98,7 @@ val crossSection = Circle(Vector2.ZERO, 0.1).contour.transform(
transform { scale(5.0, 1.0, 1.0) }
)
// Create simplex-based 3D path
// Create a simplex-based 3D path
fun get3DPath(scale: Double, time: Double, steps: Int): Path3D {
val mult = 0.005
val points = List(steps) { Vector3.simplex(337, time + it * mult) * scale }