Exporting to OBJ - Image/texture files not copied to OBJ directory

FYI, only tested when exporting FBX to OBJ.

When exporting FBX files to OBJ, the image files are not copied into the OBJ directory.

I have the following input file structure:

- C:\Users\username\AppData\Local\Temp\reprojector
    - input_files
        - file_1
            model_1.fbx
            model_1_image.jpg
            model_2_image.jpg
        - file_2
            same structure as file_1

The below is what I expect the output to look like once I save to OBJ, note the base folder path is the same:

- C:\Users\username\AppData\Local\Temp\reprojector
    - processed_files
        - file_1
            model_1.obj
            model_1.mtl
            model_1_image.jpg
            model_2_image.jpg
        - file_2
            same structure as file_1

Instead, the output is the following:

- C:\Users\username\AppData\Local\Temp\reprojector
    - processed_files
        - file_1
            model_1.obj
            model_1.mtl
        - file_2
            same structure as file_1

The path to the image file within the mtl file for file_1 is as follows:

map_Kd model_1_image.jpg
map_Kd model_2_image.jpg

Clearly the .jpg files are not present within the same directory as the .mtl file, as the .mtl file suggests.

My Load/Save options use a LocalFileSystem, where I have tried using different inputs for the base directory. This only changes the location the .mtl file is saved, but the path to the .mtl file within the .obj file assumes the .mtl file is within the same directory as the .obj, even though the .mtl file is in a different directory.

I have also tried not using a LocalFileSystem, where the paths are still incorrect to the .jpg files.

My OBJ Save Options are as follows (hard coding the variables for clarity).
As a note, I have tried a combination of different values for the lookup paths & base LocalFileSystem:


     var lookupPaths = new List<string> {
        "@C:\Users\username\AppData\Local\Temp\reprojector\input_files\file_1\",
        "@C:\Users\username\AppData\Local\Temp\reprojector\processed_files\file_1\" };

    var options = new ObjSaveOptions
    {
        FileName = "@C:\Users\username\AppData\Local\Temp\reprojector\processed_files\file_1\model_1.obj",
        Verbose = false,
        EnableMaterials = true,
        LookupPaths = lookupPaths,
        FileSystem = new LocalFileSystem(@"C:\Users\username\AppData\Local\Temp\reprojector");
     };

Are the image files not copied by Aspose?
Is the developer meant to copy the image files over manually?
Or is Aspose meant to copy the image files and something is going wrong?
Or is Aspose meant to have the full path to the input image files within the .mtl file? i.e. is the path in the .mtl meant to look something like this:

map_Kd ..\..\input_files\file_1\model_1_image.jpg

What am I doing wrong?
I don’t mind if the .jpgs are not copied, the correct path to the original .jpg (relative or absolute?) within the .mtl will suffice.

FYI saving:

scene.Save(
    @C:\Users\username\AppData\Local\Temp\reprojector\processed_files\file_1\model_1.obj,
    options,
    cancellationToken)

Thanks,
Tom

@TPovey2

An investigation ticket has been logged as below in our issue tracking system to further analyze this case. We will let you know once it is resolved. Please spare us some time.

Issue ID(s): THREEDNET-1359

@TPovey2

This has been fixed in hot fix 22.3.1, now all SaveOptions will have a ExportTextures, it will try to locate textures(external or embedded) and save it to the output directory.

Scene scene = Scene.FromFile(@"D:\Projects\3d-references\glTF-Sample-Models\2.0\BoomBox\glTF-Binary\BoomBox.glb");
var opt = new ObjSaveOptions();
opt.ExportTextures = true;
scene.Save(@"D:\tmp\boombox\output.obj", opt);

All file formats that support exporting and external file as texture can use this option(e.g. FBX, 3DS, OBJ, USD, GLTF, DAE);

Perfect, thanks for the quick response

@asad.ali, is the hotfix deployed on nuget or elsewhere? Thanks.

@TPovey2

Please give us some time and let us get back to you shortly with the updates in this regard.

1 Like

@TPovey2

Please download the hotfix below.

Aspose.3D-23.3.1.zip (8.8 MB)

The issues you have found earlier (filed as THREEDNET-1359) have been fixed in this update. This message was posted using Bugs notification tool by Aspose.3D Team.