Texture should be created from one of the subclasses
-
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 } } } }
-
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.
-
@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
-
@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?
-
@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) } ] } } }
-
@MaverickHunterX93 Hi
Check the picking example https://doc.qt.io/qt-6/qtquick3d-picking-example.html
it may help you. -
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!