[orx-obj-loader] Add support for wireframes and non-planar and concave faces
This commit is contained in:
18
orx-obj-loader/src/main/kotlin/MeshData.kt
Normal file
18
orx-obj-loader/src/main/kotlin/MeshData.kt
Normal file
@@ -0,0 +1,18 @@
|
||||
package org.openrndr.extra.objloader
|
||||
|
||||
@JvmRecord
|
||||
data class MeshData(val vertexData: VertexData, val polygonGroups: Map<String, List<IndexedPolygon>>) {
|
||||
fun triangulate(): MeshData {
|
||||
return copy(polygonGroups = polygonGroups.mapValues {
|
||||
it.value.flatMap { polygon -> polygon.triangulate(vertexData) }
|
||||
})
|
||||
}
|
||||
|
||||
fun flattenPolygons(): Map<String, List<Polygon>> {
|
||||
return polygonGroups.mapValues {
|
||||
it.value.map { ip ->
|
||||
ip.toPolygon(vertexData)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user