Hello,
I want to use Qt3D to do a 3D graph visualizer. I'm at the very beginning, studying if Qt3D could be a good option for me.
Among other, I want to print the names of the nodes in the 3D view (next to the nodes). These names should always face the camera, even if the camera moves. I have the feeling that Qt3DExtras::QText2DEntity is the class I should use. Unfortunately, its documentation is very succinct, and I can't find better example than what is shown here: https://blog.qt.io/blog/2017/05/24/qt3d/ (scroll to "Text Support").
I don't think I want to use the other mentioned text class (QExtrudedText...) as I don't want 3D text.
I tried this in C++:
auto *text2d = new Qt3DExtras::QText2DEntity(_rootEntity);
text2d->setText("LOL!!!");
text2d->setHeight(3);
text2d->setWidth(3);
text2d->setColor(Qt::green);
text2d
->setFont
(QFont("Courier New",
10));
auto *text2d = new Qt3DExtras::QText2DEntity(_rootEntity);
text2d->setText("LOL!!!");
text2d->setHeight(3);
text2d->setWidth(3);
text2d->setColor(Qt::green);
text2d->setFont(QFont("Courier New", 10));
To copy to clipboard, switch view to plain text mode
Unfortunately, nothing appears. From this video, it seems that the QText2DEntity class embed a mesh and a material, so I'm not supposed to add it (?): https://youtu.be/YP8alTWV_BI?t=17m38s
I also tried in QML, even if I want a C++ solution in the end (just to test). I changed the "simple-qml" example from Qt3D to this:
import QtQuick 2.2 as QQ2
import Qt3D.Core 2.0
import Qt3D.Render 2.0
import Qt3D.Input 2.0
import Qt3D.Extras 2.9
Entity {
id: sceneRoot
Camera {
id: camera
projectionType: CameraLens.PerspectiveProjection
fieldOfView: 45
aspectRatio: 16/9
nearPlane : 0.1
farPlane : 1000.0
position: Qt.vector3d( 0.0, 0.0, -40.0 )
upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
}
OrbitCameraController {
camera: camera
}
components: [
RenderSettings {
activeFrameGraph: ForwardRenderer {
clearColor: Qt.rgba(0, 0.5, 1, 1)
camera: camera
}
},
// Event Source will be set by the Qt3DQuickWindow
InputSettings { }
]
Text2DEntity {
id: text
text: "Hello World"
width: 20
height: 10
color: Qt.red
}
}
import QtQuick 2.2 as QQ2
import Qt3D.Core 2.0
import Qt3D.Render 2.0
import Qt3D.Input 2.0
import Qt3D.Extras 2.9
Entity {
id: sceneRoot
Camera {
id: camera
projectionType: CameraLens.PerspectiveProjection
fieldOfView: 45
aspectRatio: 16/9
nearPlane : 0.1
farPlane : 1000.0
position: Qt.vector3d( 0.0, 0.0, -40.0 )
upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
}
OrbitCameraController {
camera: camera
}
components: [
RenderSettings {
activeFrameGraph: ForwardRenderer {
clearColor: Qt.rgba(0, 0.5, 1, 1)
camera: camera
}
},
// Event Source will be set by the Qt3DQuickWindow
InputSettings { }
]
Text2DEntity {
id: text
text: "Hello World"
width: 20
height: 10
color: Qt.red
}
}
To copy to clipboard, switch view to plain text mode
But I have the same problem: nothing appears...
What am I doing wrong? Do you have any inputs on this class?
Thanks for any help
Bookmarks