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. How to rotate 3d models rendered in Qt5.7?

How to rotate 3d models rendered in Qt5.7?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.1k 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.
  • PoortiP Offline
    PoortiP Offline
    Poorti
    wrote on last edited by
    #1

    Hi All,

    I am a newbie in Qt. Learning and exploring, I came across a sample application to load 3d models following the assimp-cpp sample in Qt5.7.
    Previously, using the Qt5.6 version, I could load the model and could rotate it by (rt-mouse-click + drag) and move it by (left-mouse-click + drag).

    However, I see that I am just able to move the model in 5.7 version.
    How can I make it rotate as well.
    Here is the snippet as in assimp-cpp,

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

    Anything I can add here?

    1 Reply Last reply
    0
    • m.sueM Offline
      m.sueM Offline
      m.sue
      wrote on last edited by
      #2

      You will probably have to replace QFirstPersonCameraController by QOrbitCameraController.

      PoortiP 1 Reply Last reply
      1
      • m.sueM m.sue

        You will probably have to replace QFirstPersonCameraController by QOrbitCameraController.

        PoortiP Offline
        PoortiP Offline
        Poorti
        wrote on last edited by Poorti
        #3

        @m.sue
        That did the trick!!
        Thanks a tonne!!!

        1 Reply Last reply
        0

        • Login

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