Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Rendered 3d model is dark in Qt5.7
QtWS25 Last Chance

Rendered 3d model is dark in Qt5.7

Scheduled Pinned Locked Moved Solved General and Desktop
qt3dqt3dwindowassimp-cppqt5.7
2 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Poorti
    wrote on 26 Aug 2016, 11:53 last edited by
    #1

    Hi All,

    I am a newbie in Qt, learning and exploring, I came across the assimp-cpp example in Qt5.6
    It worked well and I was able to load a model using it.

    Then, I upgraded my version to 5.7
    Tried the same sample inside its sdk.

    I see that the rendered model is somewhat dark..
    How do we add brightness to the view?
    There is this difference I see in all the examples.
    Here is the code from the sample,

    int main(int ac, char **av)
    {
        QApplication app(ac, av);
        Qt3DExtras::Qt3DWindow view;
        view.defaultFramegraph()->setClearColor(Qt::black);
    
        // Root entity
        Qt3DCore::QEntity *sceneRoot = new Qt3DCore::QEntity();
    
        // Scene Camera
        Qt3DRender::QCamera *camera = view.camera();
        camera->setProjectionType(Qt3DRender::QCameraLens::PerspectiveProjection);
        camera->setAspectRatio(view.width() / view.height());
        camera->setUpVector(QVector3D(0.0f, 1.0f, 0.0f));
        camera->setViewCenter(QVector3D(0.0f, 1.1f, 0.0f));
        camera->setPosition(QVector3D(0.0f, 2.5f, 2.0f));
        camera->setNearPlane(0.001f);
        camera->setFarPlane(100.0f);
    
        // For camera controls
        Qt3DExtras::QFirstPersonCameraController *camController = new Qt3DExtras::QFirstPersonCameraController(sceneRoot);
        camController->setCamera(camera);
    
        // Scene loader
        Qt3DCore::QEntity *sceneLoaderEntity = new Qt3DCore::QEntity(sceneRoot);
        Qt3DRender::QSceneLoader *sceneLoader = new Qt3DRender::QSceneLoader(sceneLoaderEntity);
        SceneWalker sceneWalker(sceneLoader);
        QObject::connect(sceneLoader, &Qt3DRender::QSceneLoader::statusChanged, &sceneWalker, &SceneWalker::onStatusChanged);
        sceneLoaderEntity->addComponent(sceneLoader);
    
        QStringList args = QCoreApplication::arguments();
        QUrl sourceFileName;
        if (args.count() <= 1) {
            QWidget *container = new QWidget();
            QFileDialog dialog;
            dialog.setFileMode(QFileDialog::AnyFile);
            sourceFileName = dialog.getOpenFileUrl(container, QStringLiteral("Open a scene file"));
        } else {
            sourceFileName = QUrl::fromLocalFile(args[1]);
        }
    
        if (sourceFileName.isEmpty())
            return 0;
    
        sceneLoader->setSource(sourceFileName);
    
        view.setRootEntity(sceneRoot);
        view.show();
    
        return app.exec();
    }
    

    What can I add here to add the brightness?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      m.sue
      wrote on 26 Aug 2016, 14:00 last edited by
      #2

      What you see is the "default" light. AFAIK you can get no pointer to the default light to change its position, color, intensity or the like. If you want to have control you will have to add your own light to the root entity which then replaces the "default" light by some internal magic.

      So you do something like this:

      m_pLight=new Qt3DRender::QPointLight();
      Qt3DCore::QEntity *pLightEntity=new Qt3DCore::QEntity(m_pRootEntity);
      pLightEntity->addComponent(m_pLight);
      m_pLight->setIntensity(m_fLightPower);

      1 Reply Last reply
      2

      2/2

      26 Aug 2016, 14:00

      • Login

      • Login or register to search.
      2 out of 2
      • First post
        2/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved