diff --git a/orx-obj-loader/src/main/kotlin/OBJLoader.kt b/orx-obj-loader/src/main/kotlin/OBJLoader.kt index 931d6b74..ab59d452 100644 --- a/orx-obj-loader/src/main/kotlin/OBJLoader.kt +++ b/orx-obj-loader/src/main/kotlin/OBJLoader.kt @@ -1,4 +1,4 @@ -package modeling +package org.openrndr.extra.objloader import org.openrndr.draw.VertexBuffer import org.openrndr.draw.vertexBuffer @@ -41,6 +41,21 @@ fun bounds(triangles: List): Box { return Box(Vector3(minX, minY, minZ), maxX - minX, maxY - minY, maxZ - minZ) } +fun List.vertexBuffer():VertexBuffer { + val vertexBuffer = vertexBuffer(objVertexFormat, size*3) + vertexBuffer.put { + this@vertexBuffer.forEach { + for (i in 0 until it.positions.size) { + write(it.positions[i]) + write(it.normals[i]) + write(Vector2.ZERO) + } + } + } + vertexBuffer.shadow.destroy() + return vertexBuffer +} + fun loadOBJ(fileOrUrl: String): Map> { return try { val url = URL(fileOrUrl)