Add demos to orx-mesh-generators

This commit is contained in:
Edwin Jakobs
2020-04-10 19:50:13 +02:00
parent 5785c90937
commit 8c591c4830
8 changed files with 367 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ package org.openrndr.extras.meshgenerators
import org.openrndr.math.Matrix44
import org.openrndr.math.Vector2
import org.openrndr.math.Vector3
import org.openrndr.math.YPolarity
import org.openrndr.math.transforms.rotateY
fun generateCap(sides: Int, radius: Double, enveloppe: List<Vector2> = listOf(Vector2(0.0, 0.0), Vector2(1.0, 0.0)), writer: VertexWriter) {
@@ -13,7 +14,7 @@ fun generateCap(sides: Int, radius: Double, enveloppe: List<Vector2> = listOf(Ve
val normals2D = enveloppe.zipWithNext().map {
val d = it.second - it.first
d.normalized.perpendicular()
d.normalized.perpendicular(YPolarity.CCW_POSITIVE_Y)
}
val basePositions = cleanEnveloppe.map { Vector3(it.x, it.y, 0.0) }

View File

@@ -24,7 +24,7 @@ fun generateTaperedCylinder(sides: Int, segments: Int, radiusStart: Double, radi
val dphi = (Math.PI * 2) / sides
val ddeg = (360.0) / sides
val invertFactor = if (invert) -1.0 else 1.0
val invertFactor = if (invert) 1.0 else -1.0
val dr = radiusEnd - radiusStart
@@ -61,7 +61,7 @@ fun generateTaperedCylinder(sides: Int, segments: Int, radiusStart: Double, radi
val n1 = (Matrix44.rotateZ((side+1) * ddeg) * baseNormal.xyz0).xyz.normalized * invertFactor
if (!invert) {
if (invert) {
vertexWriter(Vector3(x00, y00, z0), n0, Vector2(u0, v0))
vertexWriter(Vector3(x10, y10, z0), n1, Vector2(u0, v1))
vertexWriter(Vector3(x11, y11, z1), n1, Vector2(u1, v1))