0
$\begingroup$

new to this community so apologizes form my newbee questions. I'm trying to use Blender as (fully fledged) 3d editor in replacement of the (painful) Xcode one. In other words, I'm trying to use Blender to create SceneKit files, essentially, DAE files which I can convert to .scn format.

Now I'm facing issues while exporting weighted shape keys. I know that the process is not so straightforward. I have to use one or both of these tools (https://github.com/HungryProton/collada-exporter-2.8 and https://github.com/JonAllee/ColladaMorphAdjuster) in order to have Xcode recognize the morphers. The problem is that the exported DAE files, whether I use the default blender exporter or the "better" one (Godot) it makes no differences, the "basis" geometry and the "target" (named "Key1" in the example) geometry are identical.

<geometry id="id-mesh-5" name="Basis">
    <mesh>
        <source id="id-mesh-5-positions">
            <float_array id="id-mesh-5-positions-array" count="12"> -1.0 -1.0 0.0 1.0 -1.0 0.0 1.4718186855316162 1.5137341022491455 -0.5436773300170898 -1.0 1.0 0.0</float_array>
            <technique_common>
            <accessor source="#id-mesh-5-positions-array" count="4" stride="3">
                <param name="X" type="float"/>
                <param name="Y" type="float"/>
                <param name="Z" type="float"/>
            </accessor>
            </technique_common>
        </source>
        <source id="id-mesh-5-normals">
            <float_array id="id-mesh-5-normals-array" count="12"> 0.10777641087770462 0.10777641087770462 0.988315999507904 0.10777641087770462 0.10777641087770462 0.988315999507904 0.10777641087770462 0.10777641087770462 0.988315999507904 0.10777641087770462 0.10777641087770462 0.988315999507904</float_array>
            <technique_common>
            <accessor source="#id-mesh-5-normals-array" count="4" stride="3">
                <param name="X" type="float"/>
                <param name="Y" type="float"/>
                <param name="Z" type="float"/>
            </accessor>
            </technique_common>
        </source>
        <source id="id-mesh-5-texcoord-0">
            <float_array id="id-mesh-5-texcoord-0-array" count="8"> 0.0 0.0 1.0 0.0 1.0 1.0 0.0 1.0</float_array>
            <technique_common>
            <accessor source="#id-mesh-5-texcoord-0-array" count="4" stride="2">
                <param name="S" type="float"/>
                <param name="T" type="float"/>
            </accessor>
            </technique_common>
        </source>
        <vertices id="id-mesh-5-vertices">
            <input semantic="POSITION" source="#id-mesh-5-positions"/>
        </vertices>
        <polygons count="1" material="id-trimat-6">
            <input semantic="VERTEX" source="#id-mesh-5-vertices" offset="0"/>
            <input semantic="NORMAL" source="#id-mesh-5-normals" offset="0"/>
            <input semantic="TEXCOORD" source="#id-mesh-5-texcoord-0" offset="0" set="0"/>
            <p> 0 1 2 3 </p>
        </polygons>
    </mesh>
</geometry>
<geometry id="id-mesh-7" name="Key1">
    <mesh>
        <source id="id-mesh-7-positions">
            <float_array id="id-mesh-7-positions-array" count="12"> -1.0 -1.0 0.0 1.0 -1.0 0.0 1.4718186855316162 1.5137341022491455 -0.5436773300170898 -1.0 1.0 0.0</float_array>
            <technique_common>
            <accessor source="#id-mesh-7-positions-array" count="4" stride="3">
                <param name="X" type="float"/>
                <param name="Y" type="float"/>
                <param name="Z" type="float"/>
            </accessor>
            </technique_common>
        </source>
        <source id="id-mesh-7-normals">
            <float_array id="id-mesh-7-normals-array" count="12"> 0.10777641087770462 0.10777641087770462 0.988315999507904 0.10777641087770462 0.10777641087770462 0.988315999507904 0.10777641087770462 0.10777641087770462 0.988315999507904 0.10777641087770462 0.10777641087770462 0.988315999507904</float_array>
            <technique_common>
            <accessor source="#id-mesh-7-normals-array" count="4" stride="3">
                <param name="X" type="float"/>
                <param name="Y" type="float"/>
                <param name="Z" type="float"/>
            </accessor>
            </technique_common>
        </source>
        <source id="id-mesh-7-texcoord-0">
            <float_array id="id-mesh-7-texcoord-0-array" count="8"> 0.0 0.0 1.0 0.0 1.0 1.0 0.0 1.0</float_array>
            <technique_common>
            <accessor source="#id-mesh-7-texcoord-0-array" count="4" stride="2">
                <param name="S" type="float"/>
                <param name="T" type="float"/>
            </accessor>
            </technique_common>
        </source>
        <vertices id="id-mesh-7-vertices">
            <input semantic="POSITION" source="#id-mesh-7-positions"/>
        </vertices>
        <polygons count="1" material="id-trimat-8">
            <input semantic="VERTEX" source="#id-mesh-7-vertices" offset="0"/>
            <input semantic="NORMAL" source="#id-mesh-7-normals" offset="0"/>
            <input semantic="TEXCOORD" source="#id-mesh-7-texcoord-0" offset="0" set="0"/>
            <p> 0 1 2 3 </p>
        </polygons>
    </mesh>
</geometry>

So that changing the value of the weight doesn't morph anything at all (it morphs the object into itself).
Have been able to find a couple of tutorials about animating emojis (https://medium.com/better-programming/exporting-a-3d-character-from-blender-2-8-to-xcode-and-implement-like-animoji-using-arkit-scenekit-3d223aa6a29f). They seem to use the exported file, more or less "as is", whence I assume that the exported DAE contains different geometries.
I could manually tweak the exported DAE but I'm wondering if there's something trivial I'm missing.

Any idea is warmly welcome.

EDIT

The XML code snippet, is what actually Blender exports into the COLLADA file: "id-mesh-5" (aka "Basis") is the source geometry, while "id-mesh-7" (aka "Key1) should be the morphed geometry, the one associated with a "1" weight. Apparently the exporter is utilizing always a weight of 0 for generating the new geometry.

$\endgroup$

1 Answer 1

0
$\begingroup$

If you are using shapekeys for your target morphs, there should only be 1 object in the Blender scene hierarchy, that of the one you are trying to morph. In Blender, ensure that you can successfully play with the shapekey weight and actually morph the mesh there first. Does XCode recognize the "Geometry Morpher" on the right panel in the scene viewer?

If you aren't using shapekeys, another solution would be to set the SCNMorpher up in code, make sure you have separate geometries for your basis and Key1 objects. Note the topology should be the same (vertex count and order) but the position of the vertices should be different in 3D space. Then, set the morph target to your Key1 geometry.

$\endgroup$
7
  • $\begingroup$ Hi Davis. Thanks a lot for your suggestions. Well, I'd answer almost all your question with a yes. As you can see I'm trying out very simple geometries, just for testing. Everything in Blender woks fine. I can even animate the shapekey weight. And I can see the morpher in Xcode. It actually works fine even. If I manually edit the DAE file by changing arbitrarily Key1's geometry, Xcode morphs fine. The problem is that if I use the exported DAE "as is", i.e. without manual edit, the two geometries are identical. It seems to be an export problem. $\endgroup$
    – user95995
    Commented May 10, 2020 at 17:10
  • $\begingroup$ Both the "standard" COLLADA exporter and the "better" one, both seem to produce identical geometries, as if they ignore any changes to the geometry associated wit the relevant weight, as if they use always the zero weight for the key (while the fully morphed geometry is associated with "one"). I could arrange things more or less manually, as you say, but that would be quite annoying for managing complex geometries/animation. Should I file a bug report agains the DAE exporter? $\endgroup$
    – user95995
    Commented May 10, 2020 at 17:30
  • $\begingroup$ Neither of those exporters are expected to work "as is" with XCode, it is a known issue and the reason for why ColladaMorphAdjuster exists. You can view the associated Blender task here. I also don't understand what you mean by "manual edit", are you doing this programmatically or in Blender GUI or in XCode GUI? $\endgroup$
    – C. Davis
    Commented May 10, 2020 at 20:15
  • $\begingroup$ Perhaps providing a code sample and/or screenshots would help me suggest a solution. $\endgroup$
    – C. Davis
    Commented May 10, 2020 at 20:21
  • $\begingroup$ Hi Davis. After additional test it turned out to be a problem with the "better" exporter. It's a bug in the fork I've used. Using another fork solved the issue (while the "standard" exporter isn't working "as is". It needs the mentioned additional tools). Now, on the other hand, I'm facing another problem. If the shape key is animated, the relevant animation is honored (played) in Xcode Scene's editor, but not at run-time. But this is another problem, for which I'm going to post a question in the relevant Apple's developer forum. Thank for your help. $\endgroup$
    – user95995
    Commented May 13, 2020 at 16:30

You must log in to answer this question.