DragonFF icon indicating copy to clipboard operation
DragonFF copied to clipboard

List index out of range when importing Renderware 3 DFF model

Open hejsanbajs opened this issue 1 year ago • 2 comments

Python: Traceback (most recent call last): File "C:\Users\wrenq\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\DragonFF-master\gui\dff_ot.py", line 286, in execute importer = dff_importer.import_dff( File "C:\Users\wrenq\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\DragonFF-master\ops\dff_importer.py", line 839, in import_dff dff_importer.import_dff(options['file_name']) File "C:\Users\wrenq\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\DragonFF-master\ops\dff_importer.py", line 810, in import_dff self.import_atomics() File "C:\Users\wrenq\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\DragonFF-master\ops\dff_importer.py", line 116, in import_atomics geom = self.dff.geometry_list[atomic.geometry] IndexError: list index out of range

DLL file

hejsanbajs avatar Jul 13 '24 05:07 hejsanbajs

After the latest update this model can be imported without errors, but it will not have any rigging. I suspect the necessary data is stored in the "Bone PLG" section, but I don't know how to parse it

image

Psycrow101 avatar Sep 13 '24 17:09 Psycrow101

I did some research on the "Bone PLG" section. The "Bone PLG" section contains a set of vertex groups data:

uint start_vertex
uint num_vertices
uint bone_id

For parsing:

GeomBone = namedtuple("GeomBone", "start_vertex num_vertices bone_id") # "<3I"

def read_bone_plg(self, parent_chunk, geometry):
    chunk_end = self.pos + parent_chunk.size

    geom_bones = []
    while self.pos < chunk_end:
        bone = Sections.read(GeomBone, self.data, self._read(12))
        if bone.num_vertices > 0:
            geom_bones.append(bone)

    geometry.extensions['bones'] = geom_bones

Frame's bone_id is stored in the "Animation PLG" section.

image

What needs to be added to the DFF importer:

  • construct armature if "Animation PLG" is found
  • set vertex groups if "Bone PLG" is found (no weights)
  • optionally import animation from "Animation PLG"

Psycrow101 avatar Sep 16 '24 13:09 Psycrow101