Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将QMatrix4x4应用于网格对象,如QT中的QTorusMesh?_Qt_Opengl_Rotation_Mesh - Fatal编程技术网

如何将QMatrix4x4应用于网格对象,如QT中的QTorusMesh?

如何将QMatrix4x4应用于网格对象,如QT中的QTorusMesh?,qt,opengl,rotation,mesh,Qt,Opengl,Rotation,Mesh,我有一个4x4变换矩阵,用于类似对象 0.866,0,0.5,0, -0.5,0,0.866,0, 0,-1,0,0, 0,0,0,0 或类似矩阵的() 如何将4x4矩阵应用于此结构: Qt3D::QScaleTransform *torusScale = new Qt3D::QScaleTransform(); Qt3D::QTranslateTransform *torusTranslation = new Qt3D::QTranslateTransform(); Qt3D::QRotate

我有一个4x4变换矩阵,用于类似对象

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

或类似矩阵的()

如何将4x4矩阵应用于此结构:

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);

您需要创建一个
Qt3DCore::QEntity
,将
QTorusMesh
添加为组件,并将
torusTransforms
Qt3DCore::QTransform
)添加为QEntity的组件:

torusEntity = new Qt3DCore::QEntity(root_entity);
torusEntity->addComponent(torusMesh);
torusEntity->addComponent(torusMaterial);
torusEntity->addComponent(torusTransforms);
关于QMatrix4x4,您可以实例化Qt3DCore::QTransform并通过调用setMatrix插槽设置其内部矩阵,该插槽接收QMatrix4x4:

torusTransforms->setMatrix(my_matrix);

有关Qt文档的运行示例,请查看:,更具体地说是场景修改器实现。

您需要创建
Qt3DCore::QEntity
,将
QTorusMesh
添加为组件,并将
torusTransforms
Qt3DCore::QTTransform
)添加为QEntity的组件:

torusEntity = new Qt3DCore::QEntity(root_entity);
torusEntity->addComponent(torusMesh);
torusEntity->addComponent(torusMaterial);
torusEntity->addComponent(torusTransforms);
关于QMatrix4x4,您可以实例化Qt3DCore::QTransform并通过调用setMatrix插槽设置其内部矩阵,该插槽接收QMatrix4x4:

torusTransforms->setMatrix(my_matrix);

有关Qt文档的运行示例,请参见:,更具体地说是场景修改器实现。

Qt3D(qt5)中没有setMatrix方法,(Qt3D::QTTransform)实例中没有setMatrix方法|C:\Qt\Qt5.5.1\Examples\Qt-5.5\qt3d\basicshapes cpp\scenemodifier.cpp:87:öббба:类qt3d::QTransform'没有名为“setMatrix”的成员torusTransforms->setMatrix(qmat);Qt3D(qt5)中没有setMatrix方法,(Qt3D::QTTransform)实例中没有setMatrix方法|C:\Qt\Qt5.5.1\Examples\Qt-5.5\qt3d\basicshapes cpp\scenemodifier.cpp:87:öббба:类qt3d::QTransform'没有名为“setMatrix”的成员torusTransforms->setMatrix(qmat);