How to load SCNMorpher targets from Collade.dae morph controllers in SceneKit?

According to WWDC 2013, What's new in SceneKit for geometries for morphers may be contained in a .dae file:

All morphing and animation information can be downloaded from a DAE file, or you can create everything programmatically. "

I have a collada.dae file containing morph controllers. The file was created by the Blender Collada exporter with the "Enable Key Forms" option selected. This converts Blender form keys to Collada morphology controllers. When I check the resulting file, I see the shape keys listed after the main geometry, in <library_geometries>. The headers look like this:

<geometry id="Octopus-mesh_morph_Rest" name="Rest">
  <mesh>
    <source id="Octopus-mesh_morph_Rest-positions">

where Restis the name of the form key. The geometry for the shape / morph key then follows this heading.

After defining all the geometry, there is <library_controllers>:

<library_controllers>
<controller id="Octopus-morph" name="Octopus-morph">
  <morph source="#Octopus-mesh" method="NORMALIZED">
    <source id="Octopus-targets">
      <IDREF_array id="Octopus-targets-array" count="1">Octopus-mesh_morph_Rest</IDREF_array>
      <technique_common>
        <accessor source="#Octopus-targets-array" count="1" stride="1">
          <param name="IDREF" type="IDREF"/>
        </accessor>
      </technique_common>
    </source>
    <source id="Octopus-weights">
      <float_array id="Octopus-weights-array" count="1">0</float_array>
      <technique_common>
        <accessor source="#Octopus-weights-array" count="1" stride="1">
          <param name="MORPH_WEIGHT" type="float"/>
        </accessor>
      </technique_common>
    </source>
    <targets>
      <input semantic="MORPH_TARGET" source="#Octopus-targets"/>
      <input semantic="MORPH_WEIGHT" source="#Octopus-weights"/>
    </targets>
  </morph>
</controller>
</library_controllers>

How can I access these morph controllers from SceneKit? There is no information in the Xcode script editor that the morph controllers were recognized, for example, when you click play nothing happens, the animation folder is empty and there are no additional geometries besides the basic geometry.

When I load node, it has no property morpherand no animation keys. I tried to find a tree for records named "Rest", but there was nothing.

    let collada = SCNScene(named: "octopus.dae", inDirectory: "art.scnassets", options: nil)
    let octopus = collada?.rootNode.childNodeWithName("Octopus", recursively: true)
    octopus?.position = SCNVector3(0,-2,0)
    print(octopus?.morpher?.animationKeys) //nil
    print(octopus?.animationKeys) //Optional([])

- SCNMorpher Collada.dae? , Blender.dae? Objective-C , Swift. .

NSBundle .dae .dae , art.scnassets, , , :

    let collada = NSBundle.mainBundle().URLForResource("octopus", withExtension: "dae")!
    let sceneSource = SCNSceneSource(URL: collada, options: [
        SCNSceneSourceAnimationImportPolicyKey : SCNSceneSourceAnimationImportPolicyDoNotPlay
        ])
    let octopusDae = sceneSource?.entryWithIdentifier("Octopus", withClass: SCNNode.self)
    //let deform = sceneSource?.entryWithIdentifier("Rest", withClass: SCNGeometry.self)
            print(sceneSource?.entriesPassingTest(){(entry, id, stop) in return id.containsString("Rest") })
    print(octopusDae!.morpher)
    print(octopusDae!.animationKeys)

2

.obj , .obj . , Blender.dae, , (, Blender.obj SceneKit, , , -, ). .dae. SceneKit .

+4
1

, . . Blender: T50807.

SCNMorphers , instance_geometry _, _.

<node id="Cube" name="Cube" type="NODE">
    <matrix sid="transform">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</matrix>
    <instance_geometry url="#Cube-mesh" name="Cube">
      <bind_material>
        <technique_common>
          <instance_material symbol="Material-material" target="#Material-material"/>
        </technique_common>
      </bind_material>
    </instance_geometry>
  </node>

:

  <node id="Cube" name="Cube" type="NODE">
    <matrix sid="transform">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</matrix>
    <instance_controller url="#Cube-morph" name="Cube-morph">
      <bind_material>
        <technique_common>
          <instance_material symbol="Material-material" target="#Material-material"/>
        </technique_common>
      </bind_material>
    </instance_controller>
  </node>

SceneKit . , Collada node, SCNSkinner (aka Blender-), SCNMorhper (aka Blender shape key). Blender , , Collada CTS. Morph_on_skin, skin_on_morph, morph_on_morph SceneKit.

, SCNMorphers. : https://github.com/JonAllee/ColladaMorphAdjuster

+3

All Articles