Qt3D:"Mesh is empty, nothing to load"消息
Qt3D: "Mesh is empty, nothing to load" message
我需要将几何体从预定义网格加载到自定义网格中。 我是这样做的:mesh->setGeometry(spheremesh->geometry(((;(完整源代码如下(
结果,我收到一条消息:
"Qt3D.Renderer.Jobs:虚拟Qt3DRender::QGeometry* Qt3DRender::MeshLoaderFunctor::operator(((( Mesh 是空的,什么都没有 加载">
但是代码正在工作。我的错误是什么?怎么做对?
谢谢大家!
主.cpp:
#include <QGuiApplication>
#include <Qt3DCore/QEntity>
#include <Qt3DCore/QTransform>
#include <Qt3DExtras/Qt3DWindow>
#include <Qt3DExtras/QSphereMesh>
#include <Qt3DExtras/QPhongMaterial>
#include <Qt3DExtras/QFirstPersonCameraController>
#include <Qt3DRender/QMesh>
#include <Qt3DRender/QCamera>
int main(int argc, char *argv[])
{
QGuiApplication application(argc, argv);
Qt3DExtras::Qt3DWindow window;
auto scene = new Qt3DCore::QEntity;
window.setRootEntity(scene);
auto entity = new Qt3DCore::QEntity(scene);
auto transform = new Qt3DCore::QTransform(entity);
transform->setTranslation(QVector3D(0.0f, 0.0f, -10.0f));
auto material = new Qt3DExtras::QPhongMaterial(entity);
material->setAmbient(QColor(245-30, 245-15, 245));
material->setDiffuse(QColor(125-30, 125-15, 125));
material->setSpecular(QColor(215-30, 255-15, 255));
auto spheremesh = new Qt3DExtras::QSphereMesh(entity);
spheremesh->setRadius(15.0);
spheremesh->setSlices(32);
spheremesh->setRings(32);
auto mesh = new Qt3DRender::QMesh(entity);
mesh->setGeometry(spheremesh->geometry());
entity->addComponent(transform);
entity->addComponent(material);
//entity->addComponent(spheremesh);
entity->addComponent(mesh);
auto camera = window.camera();
camera->lens()->setPerspectiveProjection(60.0f, static_cast<float>(window.width()) / window.height(), 0.1f, 1000.0f);
camera->setPosition(QVector3D(0.0f, 0.0f, 40.0f));
camera->setViewCenter(QVector3D(0.0f, 0.0f, 0.0f));
auto camController = new Qt3DExtras::QFirstPersonCameraController(scene);
camController->setCamera(camera);
window.show();
return application.exec();
}
qt3dsimpletest.pro:
QT += core 3dlogic 3dextras 3dinput
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES +=
main.cpp
HEADERS +=
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
我明白了。对于此任务,需要使用Qt3DRender::QGeometryRenderer类而不是Qt3DRender::QMesh。
相关文章:
- "error: no matching function for call to"构造函数错误
- 调用专用模板时出错"no matching function for call to [...]"
- C++ Singleton - Prevent ::instance() to variable
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- Visual Studio Code "undefined reference to `WinMain@16'"
- 使用 GCC 卸载的 OpenMP 卸载失败,并出现"Ptx assembly aborted due to errors"
- 如何解决"invalid conversion from 'char' to 'const char*'"
- 使用 MATLAB 编码器生成C++代码:编译错误"undefined reference to `rgb2gray_tbb_real64'"
- 尝试链接我的着色器时,我收到错误代码"error c5145 must write to gl_position"
- Python str to C++ to Python str
- 为什么创建友元类的实例会导致"undefined reference to"错误?
- System.InvalidCastException - SQL to C++ - safe_cast<float>
- 使用 cmake 的 Linux 终端上的"Conversion to non-scalar type is requested"错误
- "no matching function for call to 'Vector::Vector'"错误
- vector<vector<double>> to mxArray using memcpy
- Tensorflow c++ api undefined reference to 'tflite::D efaultErrorReporter()'
- Qt3D:"Mesh is empty, nothing to load"消息
- Qt 5.2 & iOS: "Nothing to be done"
- 日食C++ "Nothing to build"错误
- Make - nothing to do all(另一个人)