Importing 3D object with materials in balsam
-
Hello everyone,
I am currently trying to import a 3d model that I made in blender.
I export 3d models as .obj files in default settings:
then I use balsam to convert .obj file to qml asset:
Then I copy the meshes, maps folders and qml file to my project. When I run it it shows the meshes and the decals that I added but the metallic material that I made in blender doesn't show up.(maps folder contains the maps for on and off decals but there is no picture for metal material that I made)
Here is the qml file that balsam outputs:
import QtQuick3D 1.15 import QtQuick 2.15 Node { id: switch_edited_obj Model { id: switch_ source: "meshes/switch_.mesh" DefaultMaterial { id: node01___Default_material diffuseColor: "#ffcccccc" } materials: [ node01___Default_material ] } Model { id: on_ source: "meshes/on_.mesh" DefaultMaterial { id: on_material diffuseMap: Texture { source: "maps/on.png" tilingModeHorizontal: Texture.Repeat tilingModeVertical: Texture.Repeat } opacityMap: Texture { source: "maps/on.png" tilingModeHorizontal: Texture.Repeat tilingModeVertical: Texture.Repeat } } materials: [ on_material ] } Model { id: off source: "meshes/off.mesh" DefaultMaterial { id: off_material diffuseMap: Texture { source: "maps/off.png" tilingModeHorizontal: Texture.Repeat tilingModeVertical: Texture.Repeat } opacityMap: Texture { source: "maps/off.png" tilingModeHorizontal: Texture.Repeat tilingModeVertical: Texture.Repeat } } materials: [ off_material ] } Model { id: switch_001 source: "meshes/switch_001.mesh" materials: [ node01___Default_material ] } }
I am new to both blender and qt quick 3d therefore I may have missed a fundamental step in the process. I appreciate your help.
-
I noticed that .obj files does not contain material information in them, instead blender creates a .mtl file along with it. As far as I know balsam does not accept .mtl files along with .obj so instead I tried other formats. I tried all formats in https://doc.qt.io/qt-5/qtquick3d-tool-balsam.html#supported-3d-asset-types . GLTF2 (.gltf, .glb) format worked for me. However the other formats that blender can output did not give material information.