I must admit, today is the first time I used QtCreator as well as QML.
In opposition to OP, I used an even simpler sample for my experiments:
the Qt 3D: Wireframe QML Example
After some fiddling, I came to the following receipt:
Open wireframe
example in QtCreator.
The sample uses a Wavefront OBJ file trefoil.obj
.
Locate the trefoil.obj
on disk.
I found it under .../Qt/Examples/Qt-5.13.0/qt3d/exampleresources/assets/obj
.
Store the sample files cube.obj
and cubeN.obj
from the other answer into this folder.
The absence of the referenced material file master.mtl
is in this example regardless.
As far as I understood, the materials are defined in QML. – Any loaded material would be overridden in any case.
In the project treeview of QtCreator, add the sample files cube.obj
and cubeN.obj
to Resources
/.../Qt/Examples/Qt-5.13.0/qt3d/exampleresources/obj.qrc
/assets
/obj
.
Opening .../Qt/Examples/Qt-5.13.0/qt3d/exampleresources/obj.qrc
afterwards in a text editor, I found:
<RCC>
<qresource prefix="/">
<file>assets/obj/trefoil.obj</file>
<file>assets/obj/toyplane.obj</file>
<file>assets/obj/ball.obj</file>
<file>assets/obj/plane-10x10.obj</file>
<file>assets/obj/material-sphere.obj</file>
<file>assets/obj/cube.obj</file>
<file>assets/obj/cubeN.obj</file>
</qresource>
</RCC>
- I copied the file
QML
/TrefoilKnot.qml
to QML
/Cube.qml
and QML
/CubeN.qml
and replaced the source
entries respectively – Cube.qml
:
import Qt3D.Core 2.0
import Qt3D.Render 2.0
Entity {
id: root
property real x: 0.0
property real y: 0.0
property real z: 0.0
property real scale: 1.0
property real theta: 0.0
property real phi: 0.0
property Material material
components: [ transform, mesh, root.material ]
Transform {
id: transform
translation: Qt.vector3d(root.x, root.y, root.z)
rotation: fromEulerAngles(theta, phi, 0)
scale: root.scale
}
Mesh {
id: mesh
source: "assets/obj/cube.obj"
}
}
- I added the files
Cube.qml
and CubeN.qml
to Resources
/wireframe.qrc
.
- I changed
QML
/main.qml
to add the entities Cube
and CubeN
:
TrefoilKnot {
id: trefoilKnot
material: wireframeMaterial
}
Cube {
id: cube
material: wireframeMaterial
}
/* Excluded:
CubeN {
id: cubeN
material: wireframeMaterial
}*/
After starting the application, I got the following result:

I tried the same for CubeN
and the result looked similar:

I'm on Windows 10 (64 bit) and used Qt 5.13.0 with Qt Creator 4.9.1.
Concerning the objgeometryloader.cpp
:
According to what I found in sources, the following OBJ commands are supported:
v
defines a vertex coordinate
vn
defines a vertex normal
vt
defines a vertex texture coordinate
f
defines a face (triangle or triangle fan)
o
defines an object with name.
Additionally, empty lines are skipped and comments if hashmark #
appears at begin of line (with no indentation).
Other lines with e.g.
mtllib
reference to material file
usemtl
activating a certain material from material file
g
starting a group
s
activating a certain smoothing group
seem to be just ignored.
Considering that this plug-in is a geometry loader, this seems reasonable.
I also saw plug-ins for scene parsers on woboq:
qt5/qt3d/src/plugins/sceneparsers/
+ assimp/
+ gltf/
+ gltfexport/
I googled a bit but couldn't find anything what is directly related to my current Qt Version 5.13 except Open Asset Import Library, version 4.1.0.