niacdoial / blemd

BMD importer for blender (BDL format also partially supported)
GNU General Public License v3.0
32 stars 13 forks source link

Can't import images on Mac #39

Open NewgamePlusLD opened 4 years ago

NewgamePlusLD commented 4 years ago

I get this error whenever I try to import something.

WARNING bpy.ops.import_mesh.bmd.shp1 shp1, dumpBatch(): unknown attrib %d in batch, it might not display correctly (x2) (x1) ERROR bpy.ops.import_mesh.bmd.main Could not extract images. This could be the cause of a plugin crash later on (error is For now, image extraction does not support your platform) (x1) WARNING bpy.ops.import_mesh.bmd.texhelper Problem with image /Users/----------/Pikmin 2 Creatures/Onikurage [Big Jellyfloat]/Model/enemy_bmd/Textures/kurage_ia4.tga (error is Error: Cannot read '/Users/-------/Pikmin 2 Creatures/Onikurage [Big Jellyfloat]/Model/enemy_bmd/Textures/kurage_ia4.tga': No such file or directory (x1) ERROR bpy.ops.import_mesh.bmd.shp1 impossible SHP attribute 2 (x914) ) (x1) ERROR bpy.ops.import_mesh.bmd.maxH Your platform (%s) is not supported. images will not be imported (x1)

niacdoial commented 4 years ago

yeah, that's kinda what I expected.

The thing is, BleMD relies on a small complied C++ program to extract the images (because otherwise it would take way too long.) So far, I only managed to compile that program for windows and linux ('buntu 18.04, IIRC).

If you know how to, you can compile that program yourself, and name the executable "bmdview.mac" or something. It's a single file (image importing subprocess/bmdview.cpp). Afterwards, you might want to change a few lines in common.py:

if sys.platform[:3].lower()=='win':
    SEP = '\\'
elif sys.platform=='linux':
    SEP = '/'
+elif sys.platform=='darwin':
+    SEP='/'
else:
    log.error('Your platform (%s) is not supported. images will not be imported')
    SEP = '/'  # a decent default
[...]

def SubProcCall(exefile, args, startpath=os.getcwd()):
    # this is the function to edit to adapt the program for non-windows platforms
    # just add an 'elif' to the  if/else block below, in which `exefile` is adapted
    # (from 'path/to/bmdview' to 'path/to/bmdview.exe' in this example)

    if sys.platform[:3].lower() == "win":  # windows: use EXE
        exefile += '.exe'
    elif sys.platform == 'linux':
        exefile += '.lin'
+    elif sys.platform == 'darwin':
+        exefile += '.mac'

This is assuming sys.platform=='darwin' for mac.