2

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.

  1. Create MDLSubmeshTopology
  2. For the new topology object assign MDLMeshBuffers to edgeCreaseIndices, edgeCreases and Int to edgeCreaseCount properties.
  3. Create MDLSubmesh with topology object.

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.

Phi
  • 157
  • 1
  • 8
  • I've never seen any SceneKit crease sample code or articles. If you find something, please write it up! – Hal Mueller Nov 25 '16 at 05:18
  • Yea I've searched a lot, couldn't really find anything related to implementing creases into mesh or geometry. If I do find anything helpful I'll update the post with it. So far I've tried to add creases in SceneKit geometry and ModelIO meshes, no luck. But it's good to see someone else interested in this topic. Thanks for commenting. – Phi Nov 25 '16 at 06:12

2 Answers2

2

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.

mnuages
  • 13,049
  • 2
  • 23
  • 40
  • Based on your answer most likely the issue is the data I'm feeding into edgeCreasesElement and edgeCreasesSource. Thanks for taking the time to point me in the right direction. – Phi Dec 12 '16 at 01:16
  • Anyone had luck exporting data from third-party tools that can be read with these semantics? Neither Blender nor Maya 2016 seem to export creases to DAE. –  Dec 15 '16 at 20:23
  • @Erik the only format I've found that exports data related to edge creases is FBX, but I'm using Maya LT 2017, so my options are limited. – Phi Apr 16 '17 at 01:04
1

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];