Markemp/Cryengine-Converter

Invalid node with instance_geometry that references geometry that does not exist

ventorvar opened this issue · 1 comments

Describe the bug
When importing collada into Blender you may receive the following errors:

Couldn't find a mesh by UID.
error: node id="primary_turret_debris", name="primary_turret_debris" refers to an undefined instance_mesh.
cannot find Object for Node with id="primary_turret_debris"

This is indicative of a node with an instance_geometry that references a geometry that does not exist. In this case, the relevant node from the dae is:

<node id="primary_turret_debris" name="primary_turret_debris" type="NODE">
            <matrix sid="transform">1.000000 0.000000 0.000000 0.012277 0.000000 1.000000 0.000000 -2.500000 0.000000 -0.000000 1.000000 1.750001 0.000000 0.000000 0.000000 0.000000</matrix>
            <instance_geometry name="primary_turret_debris" url="#primary_turret_debris-mesh">
              <bind_material>
                <technique_common />
              </bind_material>
            </instance_geometry>

"#primary_turret_debris-mesh does not exist in the dae.

** Sample Model with the issue

  • Star Citizen 3.14.0
  • Data\Objects\Vehicles\TMBL\Nova\TMBL_Nova.cga

Additional context
This state can happen in the following circumstances:

if (tmpVertices == null && tmpVertsUVs == null) // There is no vertex data for this node.  Skip.
                            continue;
  • Subsequently in WriteLibrary_VisualScenes the following check is performed on the source data, not the GeometryList that has been generated:
ChunkNode geometryNode = CryData.Models[1].NodeMap.Values.Where(a => a.Name == nodeChunk.Name).FirstOrDefault();
                    if (geometryNode == null)
                    {
                        tmpNode = CreateSimpleNode(nodeChunk);  // Can't find geometry for given node.
                    }
                    else
                    {
                        ChunkMesh geometryMesh = (ChunkMesh)CryData.Models[1].ChunkMap[geometryNode.ObjectNodeID];
                        tmpNode = CreateGeometryNode(geometryNode, geometryMesh);
                    }

Fixed by #98