Demos: ensure 720px wide, reduce indentation
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,42 +15,40 @@ import java.io.File
|
||||
* Demonstrate decal generator as an object slicer
|
||||
* @see <img src="https://raw.githubusercontent.com/openrndr/orx/media/orx-mesh-generators/images/decal-DemoDecal01Kt.png">
|
||||
*/
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,71 +17,69 @@ import kotlin.math.PI
|
||||
* Demonstrate decal generation and rendering
|
||||
* @see <img src="https://raw.githubusercontent.com/openrndr/orx/media/orx-mesh-generators/images/decal-DemoDecal02Kt.png">
|
||||
*/
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user