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. Texture should be created from one of the subclasses
Forum Updated to NodeBB v4.3 + New Features

Texture should be created from one of the subclasses

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 2 Posters 820 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.
  • M Offline
    M Offline
    MaverickHunterX93
    wrote on last edited by MaverickHunterX93
    #1

    Hello,
    I get an error trying to run this code: Texture should be created from one of the subclasses. I do not understand this error nor do I know where i should start to fix it. Is there any way to just keep it as Texture and not change it to Texture2D?As when running the runtimeloader example code I do not get this error. Here is part of my code below but still generates the error.

    
    import QtQuick
    import QtQuick.Window
    import QtQuick.Controls
    import QtQuick.Layouts
    
    import Qt.labs.platform
    import QtCore
    import Qt3D.Core 
    import QtQuick3D
    import QtQuick3D.Helpers
    import QtQuick3D.AssetUtils
    
    import Qt3D.Extras 
    import Qt3D.Input 
    import Qt3D.Render 
    import QtQml.Models 
    import QtQuick.Scene3D 
    
    import PreemieScanner.Measurement 1.0
    import MeshviewerTrackball 1.0
    import PreemieScanner.Merge 1.0
    
    
      // Embed the 3D view within your original GUI
        Item {
            id: windowRoot
            width: parent.width
            height: parent.height
            anchors.fill: parent
            property url meshSource:  Merge.getWorkingDir() + "demo_head.ply"
            
    
            View3D {
                id: view3D
                anchors.fill: parent
                Layout.fillWidth: true
                Layout.fillHeight: true
    
             Entity {
                    id: root
                    property alias camera: camera
    
            
                    Camera {
                        id: camera
                        projectionType: CameraLens.PerspectiveProjection
                        fieldOfView: 45
                        nearPlane : 0.1
                        farPlane : 1000.0
                        position: Qt.vector3d( 100.0, -200.0, 0.0 )
                        upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
                        viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
                    }
             }
            environment: SceneEnvironment {
                id: env
                backgroundMode: SceneEnvironment.Color,"#303030"
                
                lightProbe: Texture {   
                    textureData: ProceduralSkyTextureData{}
                }
                InfiniteGrid {
                    visible: helper.gridEnabled
                    gridInterval: helper.gridInterval
                    }
              }
        }
    }
    
    johngodJ 1 Reply Last reply
    0
    • M MaverickHunterX93

      Hello,
      I get an error trying to run this code: Texture should be created from one of the subclasses. I do not understand this error nor do I know where i should start to fix it. Is there any way to just keep it as Texture and not change it to Texture2D?As when running the runtimeloader example code I do not get this error. Here is part of my code below but still generates the error.

      
      import QtQuick
      import QtQuick.Window
      import QtQuick.Controls
      import QtQuick.Layouts
      
      import Qt.labs.platform
      import QtCore
      import Qt3D.Core 
      import QtQuick3D
      import QtQuick3D.Helpers
      import QtQuick3D.AssetUtils
      
      import Qt3D.Extras 
      import Qt3D.Input 
      import Qt3D.Render 
      import QtQml.Models 
      import QtQuick.Scene3D 
      
      import PreemieScanner.Measurement 1.0
      import MeshviewerTrackball 1.0
      import PreemieScanner.Merge 1.0
      
      
        // Embed the 3D view within your original GUI
          Item {
              id: windowRoot
              width: parent.width
              height: parent.height
              anchors.fill: parent
              property url meshSource:  Merge.getWorkingDir() + "demo_head.ply"
              
      
              View3D {
                  id: view3D
                  anchors.fill: parent
                  Layout.fillWidth: true
                  Layout.fillHeight: true
      
               Entity {
                      id: root
                      property alias camera: camera
      
              
                      Camera {
                          id: camera
                          projectionType: CameraLens.PerspectiveProjection
                          fieldOfView: 45
                          nearPlane : 0.1
                          farPlane : 1000.0
                          position: Qt.vector3d( 100.0, -200.0, 0.0 )
                          upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
                          viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
                      }
               }
              environment: SceneEnvironment {
                  id: env
                  backgroundMode: SceneEnvironment.Color,"#303030"
                  
                  lightProbe: Texture {   
                      textureData: ProceduralSkyTextureData{}
                  }
                  InfiniteGrid {
                      visible: helper.gridEnabled
                      gridInterval: helper.gridInterval
                      }
                }
          }
      }
      
      johngodJ Offline
      johngodJ Offline
      johngod
      wrote on last edited by johngod
      #2

      @MaverickHunterX93 Hi

      You are mixing Quick3D with Qt3D which are two different libraries, afaik you can't mixed them, pick one. Entity is from Qt3D, other stuff you have are from Quick3D.

      M 1 Reply Last reply
      0
      • johngodJ johngod

        @MaverickHunterX93 Hi

        You are mixing Quick3D with Qt3D which are two different libraries, afaik you can't mixed them, pick one. Entity is from Qt3D, other stuff you have are from Quick3D.

        M Offline
        M Offline
        MaverickHunterX93
        wrote on last edited by
        #3

        @johngod Hi there,

        Thank you very much for your help. I have a specific goal in mind: I want to select points on a 3D mesh and print their coordinates on the mesh. Previously, I was able to achieve this with the Qt3D imports, but now I'm working with QtQuick3D because it allows me to load RGB information for extra details.

        My question is, do I need to work in two separate QML files to accomplish this

        johngodJ 1 Reply Last reply
        0
        • M MaverickHunterX93

          @johngod Hi there,

          Thank you very much for your help. I have a specific goal in mind: I want to select points on a 3D mesh and print their coordinates on the mesh. Previously, I was able to achieve this with the Qt3D imports, but now I'm working with QtQuick3D because it allows me to load RGB information for extra details.

          My question is, do I need to work in two separate QML files to accomplish this

          johngodJ Offline
          johngodJ Offline
          johngod
          wrote on last edited by
          #4

          @MaverickHunterX93 Hi
          Mixing the both libraries can get you into trouble even in separate files I think. Afaik Qt3D uses https://github.com/assimp/assimp under the wood to load the mesh's, quick3d uses a Qt utility called balsam https://doc.qt.io/qt-6/qtquick3d-tool-balsam.html to convert the comom formats like obj, fbx, ..., to a quick3d specific format.

          I want to select points on a 3D mesh and print their coordinates on the mesh

          How did you did that ? Can you replicate with quick3d?

          M 1 Reply Last reply
          1
          • johngodJ johngod

            @MaverickHunterX93 Hi
            Mixing the both libraries can get you into trouble even in separate files I think. Afaik Qt3D uses https://github.com/assimp/assimp under the wood to load the mesh's, quick3d uses a Qt utility called balsam https://doc.qt.io/qt-6/qtquick3d-tool-balsam.html to convert the comom formats like obj, fbx, ..., to a quick3d specific format.

            I want to select points on a 3D mesh and print their coordinates on the mesh

            How did you did that ? Can you replicate with quick3d?

            M Offline
            M Offline
            MaverickHunterX93
            wrote on last edited by
            #5

            @johngod Hi

            I used Qt3D Core ,Render, Extras and Input. MeshViewerTrackball is purely only for camera view to rotate the mesh for different angles. As you can see I use a lot of Qt3D QML types, for example Spheremesh as a point picker so I need the Qt3D module. I will look for other possibilities as I am sure there are alternatives for this.

            
                            Entity {
                                id: root
                                property alias camera: camera
            
                        
                                Camera {
                                    id: camera
                                    projectionType: CameraLens.PerspectiveProjection
                                    fieldOfView: 45
                                    nearPlane : 0.1
                                    farPlane : 1000.0
                                    position: Qt.vector3d( 100.0, -200.0, 0.0 )
                                    upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
                                    viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
                                }
            
                                MeshviewerTrackball {
                                    camera: camera
                                    windowSize: Qt.size(window.width, window.height)
                                }
            
                                RenderSettings {
                                    activeFrameGraph: ForwardRenderer {
                                        camera: camera
                                        clearColor: "transparent"
                                    }
                                    pickingSettings.pickMethod: PickingSettings.TrianglePicking
                                    pickingSettings.pickResultMode: PickingSettings.NearestPick
                                }
            
                                InputSettings {
                                    id: inputSettings
                                }
            
                                DirectionalLight {
                                    id: headLight
                                    worldDirection: camera.viewVector
                                }
            
                                ScreenRayCaster {
                                    id: screenRayCaster
                                    onHitsChanged: placePoint(hits)
                                }
            
                                Mesh {
                                    id: reconstructedMesh
                                    source: "file:///" + meshSource
                                }
            
                                PhongMaterial {
                                    id: reconstructedMeshMaterial
                                    ambient: "#A0A0BA"
                                }
            
                                Transform {
                                    id: reconstructedMeshTransform
                                }
            
                                components: [
                                    headLight, inputSettings, screenRayCaster, mouseHandler
                                ]
            
                                ListModel {
                                    id: pointPickModel
                                    onCountChanged: setUndoButtonStatus()
                                }
            
                                ListModel {
                                    id: removedPoints
                                    onCountChanged: setRedoButtonStatus()
                                }
            
                                Entity {
                                    id: rootEntity
                                    components: [reconstructedMesh, reconstructedMeshMaterial, reconstructedMeshTransform]
                                    NodeInstantiator {
                                        id: pointPickModelInstantiator
                                        model: pointPickModel
                                        delegate: Entity {
                                            id: sphereEntity
                                            components: [
                                                SphereMesh {
                                                    id: sphereMesh
                                                    radius: pointRadius
                                                },
                                                PhongMaterial {
                                                    id: materialSphere
                                                    ambient: "red"
                                                },
                                                Transform {
                                                    id: transformSphereMesh
                                                    translation: Qt.vector3d(x, y, z)
                                                }
                                            ]
                                        }
                                    }
                                }
            
            johngodJ 1 Reply Last reply
            0
            • M MaverickHunterX93

              @johngod Hi

              I used Qt3D Core ,Render, Extras and Input. MeshViewerTrackball is purely only for camera view to rotate the mesh for different angles. As you can see I use a lot of Qt3D QML types, for example Spheremesh as a point picker so I need the Qt3D module. I will look for other possibilities as I am sure there are alternatives for this.

              
                              Entity {
                                  id: root
                                  property alias camera: camera
              
                          
                                  Camera {
                                      id: camera
                                      projectionType: CameraLens.PerspectiveProjection
                                      fieldOfView: 45
                                      nearPlane : 0.1
                                      farPlane : 1000.0
                                      position: Qt.vector3d( 100.0, -200.0, 0.0 )
                                      upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
                                      viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
                                  }
              
                                  MeshviewerTrackball {
                                      camera: camera
                                      windowSize: Qt.size(window.width, window.height)
                                  }
              
                                  RenderSettings {
                                      activeFrameGraph: ForwardRenderer {
                                          camera: camera
                                          clearColor: "transparent"
                                      }
                                      pickingSettings.pickMethod: PickingSettings.TrianglePicking
                                      pickingSettings.pickResultMode: PickingSettings.NearestPick
                                  }
              
                                  InputSettings {
                                      id: inputSettings
                                  }
              
                                  DirectionalLight {
                                      id: headLight
                                      worldDirection: camera.viewVector
                                  }
              
                                  ScreenRayCaster {
                                      id: screenRayCaster
                                      onHitsChanged: placePoint(hits)
                                  }
              
                                  Mesh {
                                      id: reconstructedMesh
                                      source: "file:///" + meshSource
                                  }
              
                                  PhongMaterial {
                                      id: reconstructedMeshMaterial
                                      ambient: "#A0A0BA"
                                  }
              
                                  Transform {
                                      id: reconstructedMeshTransform
                                  }
              
                                  components: [
                                      headLight, inputSettings, screenRayCaster, mouseHandler
                                  ]
              
                                  ListModel {
                                      id: pointPickModel
                                      onCountChanged: setUndoButtonStatus()
                                  }
              
                                  ListModel {
                                      id: removedPoints
                                      onCountChanged: setRedoButtonStatus()
                                  }
              
                                  Entity {
                                      id: rootEntity
                                      components: [reconstructedMesh, reconstructedMeshMaterial, reconstructedMeshTransform]
                                      NodeInstantiator {
                                          id: pointPickModelInstantiator
                                          model: pointPickModel
                                          delegate: Entity {
                                              id: sphereEntity
                                              components: [
                                                  SphereMesh {
                                                      id: sphereMesh
                                                      radius: pointRadius
                                                  },
                                                  PhongMaterial {
                                                      id: materialSphere
                                                      ambient: "red"
                                                  },
                                                  Transform {
                                                      id: transformSphereMesh
                                                      translation: Qt.vector3d(x, y, z)
                                                  }
                                              ]
                                          }
                                      }
                                  }
              
              johngodJ Offline
              johngodJ Offline
              johngod
              wrote on last edited by
              #6

              @MaverickHunterX93 Hi
              Check the picking example https://doc.qt.io/qt-6/qtquick3d-picking-example.html
              it may help you.

              M 1 Reply Last reply
              0
              • johngodJ johngod

                @MaverickHunterX93 Hi
                Check the picking example https://doc.qt.io/qt-6/qtquick3d-picking-example.html
                it may help you.

                M Offline
                M Offline
                MaverickHunterX93
                wrote on last edited by
                #7

                Thank you, @johngod, for the information. Unfortunately, I couldn't find a way to enable picking on a RuntimeLoader type, which I think seems to be the only type that provides access to RGB information without the need for additional extensions. I'll need to set this aside for now. Your assistance has been greatly appreciated. Thank you for your help!

                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