Wrong parameters in exported MTL


I am using VTK 9.2 (from pip) to generate height maps for robotics simulators, but I run into some issues when trying to display them in the simulators (Gazebo 9, and Isaac Sim). What’s happening is that the “Ka” parameter in the MTL is set to 0,0,0.
This results in the objects being transparent when displayed in the simulators.

Here is the code I am using to export the height maps:

def objExporter(polydata: vtk.vtkPolyData, save_path: str, image: vtk.vtkImageData = None):
    Saves a mesh as an OBJ file. Unlike objWriter, this methods generates UVs.

        polydata (vtk.vtkPolyData): the mesh to be exported.
        image (vtk.vtkImageData): the image to be saved as the texture of the object.
        save_path (str): the path to the saved file.
    # Creates the UV map based on a plane.
    bounds = polydata.GetBounds()
    map_to_plane = vtk.vtkTextureMapToPlane()
    map_to_plane.SetOrigin(0, 0, 0)
    map_to_plane.SetPoint1(bounds[1], 0, 0)
    map_to_plane.SetPoint2(0, bounds[3], 0)
    # Applies the UV map to a mapper
    mapper = vtk.vtkPolyDataMapper()
    # Creates a VTK texture
    texture = vtk.vtkTexture()
    # Creates an actor to combine the texture and the mesh.
    actor = vtk.vtkActor()
    # Creates a render window to be able to save the OBJ.
    ren = vtk.vtkRenderer()
    renWin = vtk.vtkRenderWindow()
    ren.SetBackground(1, 1, 1)
    renWin.SetSize(1000, 1000)
    # Saves the OBJ file.
    writer = vtk.vtkOBJExporter()

Using this code it generate the following MTL:

# wavefront mtl file written by the visualization toolkit

newmtl mtl1
Ka 0 0 0
Kd 1 1 1
Ks 0 0 0
Ns 1
Tr 1
illum 3
map_Kd map_0_0texture1.png

However, if I load this obj file in blender and save it again it has this MTL:

# wavefront mtl file written by the visualization toolkit

newmtl mtl1
Ns 0.999999
Ka 1.000000 1.000000 1.000000
Ks 0.000000 0.000000 0.000000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 1
map_Kd map_0_30texture1.png

I couldn’t figure out how to change these settings in VTK. I can always script the rewriting of the MTL file through bash, but this is inelegant, and I feel like this should be achievable through VTK.

I would truly appreciate if someone could point me in the right direction here!