Reputation: 157
I’ve been able to create a MDLMesh and convert to SCNGeometry to render in SceneKit. But I haven’t been able to get crease support in my meshes or geometry.
I just wanted to verify that I’m taking the correct steps to add crease support for my mesh.
I’m not looking for specific solutions, just a general idea of how one would go about adding crease support to a mesh. Anyone with experience on this would be great.
Upvotes: 2
Views: 539
Reputation: 61
The following should work, assuming you've prepared the data as edge pairs of four byte integers, and the crease values as floats.
geometry.edgeCreasesSource = [SCNGeometrySource geometrySourceWithData:ecsData
semantic:SCNGeometrySourceSemanticEdgeCrease
vectorCount:creaseCount
floatComponents:YES
componentsPerVector:1
bytesPerComponent:4
dataOffset:0
dataStride:sizeof(float)];
geometry.edgeCreasesElement = [SCNGeometryElement geometryElementWithData:eceData
primitiveType:SCNGeometryPrimitiveTypeLine
primitiveCount:creaseCount
bytesPerIndex:4];
Upvotes: 1
Reputation: 13462
SceneKit has edgeCreasesElement
and edgeCreasesSource
as well as the vertexCrease
semantic.
You can take a look at the documentation for SCNGeometry.subdivisionLevel
for more information.
Upvotes: 2