Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. The obj file is not displayed as a mesh.
Qt 6.11 is out! See what's new in the release blog

The obj file is not displayed as a mesh.

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Anton1978A Offline
    Anton1978A Offline
    Anton1978
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • Anton1978A Offline
      Anton1978A Offline
      Anton1978
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      1
      • F Offline
        F Offline
        film
        wrote on last edited by
        #3

        Can you share the code with me?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved