Я новичок в qt3d и пытаюсь узнать, что делают эти вещи, поэтому возник следующий вопрос:
Когда программа отображает нормаль и когда диффузное TextureImage QNormalDiffuseMapMaterial?
In следующий код, red.png - это большое красное изображение, а green.png - это большое зеленое изображение, и я уверен, что пути в порядке.
#include <QGuiApplication>
#include <Qt3DCore/QEntity>
#include <Qt3DCore/QTransform>
#include <Qt3DExtras/Qt3DWindow>
#include <Qt3DExtras/QCuboidMesh>
#include <Qt3DExtras/QNormalDiffuseMapMaterial>
#include <Qt3DRender/QCamera>
#include <Qt3DRender/QTextureImage>
Qt3DCore::QEntity* createScene(){
auto rootEntity = new Qt3DCore::QEntity;
auto cuboid = new Qt3DCore::QEntity(rootEntity);
auto cuboidMesh = new Qt3DExtras::QCuboidMesh;
auto cuboidTransform = new Qt3DCore::QTransform;
auto cuboidMaterial = new Qt3DExtras::QNormalDiffuseMapMaterial;
cuboidMaterial->setAmbient(QColor::fromRgbF(0.5, 0.5, 0.5));
auto normalCuboidImage = new Qt3DRender::QTextureImage;
auto diffuseCuboidImage = new Qt3DRender::QTextureImage;
normalCuboidImage->setSource(QUrl::fromLocalFile(":/images/green.png"));
diffuseCuboidImage->setSource(QUrl::fromLocalFile(":/images/red.png"));
cuboidMaterial->normal()->addTextureImage(normalCuboidImage);
cuboidMaterial->diffuse()->addTextureImage(diffuseCuboidImage);
cuboid->addComponent(cuboidMesh);
cuboid->addComponent(cuboidTransform);
cuboid->addComponent(cuboidMaterial);
return rootEntity;
}
int main(int argc, char *argv[]){
QGuiApplication app(argc, argv);
Qt3DExtras::Qt3DWindow window;
auto scene = createScene();
window.setRootEntity(scene);
window.camera()->setPosition(QVector3D(10.0f, 10.0f, 10.0f));
window.camera()->setViewCenter(QVector3D(0, 0, 0));
window.show();
return app.exec();
}
Я вижу только большой красный куб, но нет ничего зеленого. Так когда же используется обычный TextureImage?
Я использую Qt 5.14.1 для windows.