DarkStarSword / 3d-fixes

Stereoscopic 3D fixes using Helix mod & 3DMigoto
111 stars 129 forks source link

Missing ib file when exporting #31

Closed S52968 closed 3 months ago

S52968 commented 8 months ago

When exporting using the Blender plugin, I get a vb, vb0, vgmap, and fmt file, but no ib file. I'm using Blender 3.6 with the latest version of the plugin. The model is imported into Blender as an ib + vb file.

DarkStarSword commented 8 months ago

Can you please attach a sample of the files exhibiting this issue?

S52968 commented 8 months ago

Sorry for that, I've attached the files.

These are frame dumps of a hand: 000159-ib=cb574966-vs=c7b6348a8d4deab5-ps=f37ba4ae9503eaed.txt 000159-vb0=62844cf5-vs=c7b6348a8d4deab5-ps=f37ba4ae9503eaed.txt

And these are the same hand but extracted through using Gust Tools and Gust Stuff from the game Blue Reflection. I didn't want to upload them to another place so I added the .txt extension to make them uploadable to this comment: 14.fmt.txt 14.ib.txt 14.vb.txt 14.vgmap.txt

When importing as a frame dump it allows me to get the ib file, but the vb + ib does not give me an ib file output.

eArmada8 commented 3 months ago

I can confirm the same issue. The issue is that the plugin is exporting the index buffer as .vb instead of .ib.

Blender 4.2 LTS, blank workspace, current commit 705bed5, imported .ib/.vb from prior version, exported to .ib/.vb. The plugin is exporting the .ib file with a .vb extension.

When I rename the .vb file to .ib, the plugin can import the .fmt/.ib/.vb0 back into Blender successfully at that point.

EDIT: I think the issue is on line 1734:

        ib_path = vb_path

I'm not sure what this is line is originally intended to do, but exporting the .ib before this line is executed seems to fix the error. I swapped the order of vb and ib export (lines 1732-1746) from:

    base, ext = os.path.splitext(vb_path)
    for (suffix, vgmap) in vgmaps.items():
        ib_path = vb_path
        if suffix:
            ib_path = '%s-%s%s' % (base, suffix, ext)
        vgmap_path = os.path.splitext(ib_path)[0] + '.vgmap'
        print('Exporting %s...' % ib_path)
        vb.remap_blendindices(obj, vgmap)
        vb.write(ib_path, strides, operator=operator)
        vb.revert_blendindices_remap()
        sorted_vgmap = collections.OrderedDict(sorted(vgmap.items(), key=lambda x:x[1]))
        json.dump(sorted_vgmap, open(vgmap_path, 'w'), indent=2)

    if ib is not None:
        ib.write(open(ib_path, 'wb'), operator=operator)

to:

    if ib is not None:
        ib.write(open(ib_path, 'wb'), operator=operator)

    base, ext = os.path.splitext(vb_path)
    for (suffix, vgmap) in vgmaps.items():
        ib_path = vb_path
        if suffix:
            ib_path = '%s-%s%s' % (base, suffix, ext)
        vgmap_path = os.path.splitext(ib_path)[0] + '.vgmap'
        print('Exporting %s...' % ib_path)
        vb.remap_blendindices(obj, vgmap)
        vb.write(ib_path, strides, operator=operator)
        vb.revert_blendindices_remap()
        sorted_vgmap = collections.OrderedDict(sorted(vgmap.items(), key=lambda x:x[1]))
        json.dump(sorted_vgmap, open(vgmap_path, 'w'), indent=2)

I'm guessing there is a more elegant solution available, such as using a different variable name instead of ib_path inside that for loop?

DarkStarSword commented 3 months ago

Possibly a regression added in 97ee9073378e5ef9a23e71b3a0bbd77209031205 ? Prior to that the variable inside the vgmap block was just path rather than ib_path - I suspect this was probably a search and replace error. I've pushed up a change reverting that to path - please test it and let me know if it works.

eArmada8 commented 3 months ago

Tested and working, thank you very much!

EDIT: Since my G1M exporter (gust stuff) was mentioned, I'll mention here that I've released a new version fully compatible with the latest commit of the plugin.