The obj file is not displayed as a mesh.

  • The obj file is not displayed as a mesh.

    Good day.
    I continue to study 3D.
    Now I'm trying to add an object from obj to the scene.
    Here's what happened:

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtQuick3D 1.15
    import Qt3D.Core 2.15
    import QtQuick3D.Helpers 1.15
    import Qt3D.Extras 2.15
    Window {
        id: root
        width: 800
        height: 600
        visible: true
        title: qsTr("Hello World")
        View3D {
            id: view
            anchors.fill: parent
            environment: SceneEnvironment {
                clearColor: "skyblue"
                backgroundMode: SceneEnvironment.Color
            PerspectiveCamera {
                id: mainCamera
                position: Qt.vector3d(0, 500, 500)
                eulerRotation.x: -50
            WasdController  {
                controlledObject: mainCamera
            DirectionalLight {
                eulerRotation.x: -30
                eulerRotation.y: -70
            MegaTeaport {
                id: teaport

    and the MegaTeaport.qml file

    import Qt3D.Core 2.0
    import Qt3D.Render 2.0
    import QtQuick3D 1.15
    Entity {
        id: root
        property Material materials: DefaultMaterial {diffuseColor: "green"}
        components: [ transform, mesh, root.material ]
        Transform {
            id: transform
            translation: Qt.vector3d(0, 0, 0)
            scale: 0.5
        Mesh {
            id: mesh
            source: "new/prefix1/Items/trefoil.obj"

    Everything is assembled without errors, but the window is empty.
    At first I thought that I might need to process the file before importing it, but when I inserted the file from the example (Qt 3D: Wireframe QML Example) into the code, the situation did not change.
    That means it's not about the file, I'm stupid.
    I also suspect that I have not attached the material correctly.
    What can be wrong?

  • I figured it out, you can load obj only using SceneLoader, and in its turn it must be packed into Entity.
    Confusingly, examples like Qt Quick 3D - Simple Example.

Log in to reply