1

I have a 4x4 transformations matrix for object like

0.866,   0,     0.5,       0,
-0.5,      0,     0.866,   0,
0,         -1,     0,          0,
0,          0,     0,          0

Or matrix like (Qt Transform matrix)

How apply 4x4 matrix to this construction:

Qt3D::QScaleTransform *torusScale = new Qt3D::QScaleTransform();
Qt3D::QTranslateTransform *torusTranslation = new Qt3D::QTranslateTransform();
Qt3D::QRotateTransform *torusRotation = new Qt3D::QRotateTransform();
Qt3D::QTransform *torusTransforms = new Qt3D::QTransform();

torusScale->setScale3D(QVector3D(2.0f, 2.0f, 2.0f));
torusTranslation->setTranslation(QVector3D(1.7f, 1.7f, 0.0f));
torusRotation->setAngleDeg(25.0f);
torusRotation->setAxis(QVector3D(0, 1, 0));

torusTransforms->addTransform(torusRotation);
torusTransforms->addTransform(torusTranslation);
torusTransforms->addTransform(torusScale);
Community
  • 1
  • 1
Evgy
  • 386
  • 1
  • 3
  • 10

1 Answers1

0

You need to create a Qt3DCore::QEntity, add your QTorusMesh as a component and also add your torusTransforms (Qt3DCore::QTransform) as a component of the QEntity:

torusEntity = new Qt3DCore::QEntity(root_entity);
torusEntity->addComponent(torusMesh);
torusEntity->addComponent(torusMaterial);
torusEntity->addComponent(torusTransforms);

Now about the QMatrix4x4, you can instantiate a Qt3DCore::QTransform and set its internal matrix by calling the setMatrix SLOT, which receives a QMatrix4x4:

torusTransforms->setMatrix(my_matrix);

For a running example from the Qt docs look at: https://doc.qt.io/qt-5/qt3d-basicshapes-cpp-example.html, more specifically the scene modifier implementation.

seenukarthi
  • 8,241
  • 10
  • 47
  • 68
  • There is no setMatrix method in Qt3D (qt5) – Evgy Apr 10 '16 at 17:14
  • There is no setMatrix method in (Qt3D::QTransform) instance. |C:\Qt\Qt5.5.1\Examples\Qt-5.5\qt3d\basicshapes-cpp\scenemodifier.cpp:87: ошибка: 'class Qt3D::QTransform' has no member named 'setMatrix' torusTransforms->setMatrix(qmat); – Evgy Apr 10 '16 at 17:42