Add option to use existing vertex buffer in meshGenerator

This commit is contained in:
Edwin Jakobs
2020-01-14 23:47:18 +01:00
parent f8cee11ab8
commit 8dc4bfd8fc

View File

@@ -1,8 +1,6 @@
package org.openrndr.extras.meshgenerators package org.openrndr.extras.meshgenerators
import org.openrndr.draw.VertexBuffer import org.openrndr.draw.VertexBuffer
import org.openrndr.draw.vertexBuffer
import org.openrndr.draw.vertexFormat
import org.openrndr.math.Matrix44 import org.openrndr.math.Matrix44
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.math.Vector3 import org.openrndr.math.Vector3
@@ -140,16 +138,11 @@ fun GeneratorBuffer.extrudeShapes(shapes: List<Shape>, length: Double, scale: Do
} }
fun meshGenerator(vertexBuffer: VertexBuffer? = null, builder: GeneratorBuffer.() -> Unit): VertexBuffer {
fun meshGenerator(builder: GeneratorBuffer.() -> Unit): VertexBuffer {
val gb = GeneratorBuffer() val gb = GeneratorBuffer()
gb.builder() gb.builder()
val vb = vertexBuffer(vertexFormat { val vb = vertexBuffer ?: meshVertexBuffer(gb.data.size)
position(3)
normal(3)
textureCoordinate(2)
}, gb.data.size)
val bb = gb.toByteBuffer() val bb = gb.toByteBuffer()
bb.rewind() bb.rewind()