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. Qt3D to load scenes

Qt3D to load scenes

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 2.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.
  • J Offline
    J Offline
    Jjcasmar
    wrote on last edited by
    #1

    Hi,

    I'm trying to use Qt3D to load some scene files that I need to work with, but I'm not sure how to do this.

    I dont need graphics support, I just need to load the scenes and modify some data for some other purposes. I have tried to create a simple Qt3D scene which contains a QSceneLoader object. I've also created an engine and Input and Render aspects but nothing happens.

    Here is some code:

    FracturablePart *JesusIOFile::fromFile(const QString &filename)
    {
        if (filename.endsWith(".obj"))
        {
            Qt3DCore::QAspectEngine *engine = new Qt3DCore::QAspectEngine;
            Qt3DInput::QInputAspect *inputAspect = new Qt3DInput::QInputAspect;
            Qt3DRender::QRenderAspect *renderAspect = new Qt3DRender::QRenderAspect;
    
            engine->registerAspect(inputAspect);
            engine->registerAspect(renderAspect);
    
            Qt3DRender::QSceneLoader *loader = new Qt3DRender::QSceneLoader;
            loader->setSource(filename);
    
            Qt3DCore::QEntity *loaderEntity = new Qt3DCore::QEntity;
            loaderEntity->addComponent(loader);
    
            engine->setRootEntity(Qt3DCore::QEntityPtr(loaderEntity));
            connect(loader, &Qt3DRender::QSceneLoader::statusChanged,
                    this, &JesusIOFile::onSceneLoaderStatusChanged);
    
            engine->startTimer(0, Qt::TimerType::CoarseTimer);
        }
    
        return nullptr;
    }
    
    void JesusIOFile::onSceneLoaderStatusChanged(Qt3DRender::QSceneLoader::Status status)
    {
        std::cout << "Status :" << status << std::endl;
    }
    
    

    Any ideas if this is even possible in Qt3D?

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

      Hi,
      have you tried loader->setSource(QUrl::fromLocalFile(fileName))?
      Maybe place the connect before the setSource. Did you add a QPhongMaterial somewhere else?
      -Michael.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jjcasmar
        wrote on last edited by
        #3

        QPhongMaterial? What for?

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

          Hi,
          when I read Qt3D I always think of 3D-surfaces to visualize.
          -Michael.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jjcasmar
            wrote on last edited by
            #5

            That's what I want to know, if there is anyway to use Qt3D for batch manipulation of 3D scenes. If they are going to add physical simulation, AI and all that stuff, there should be a way to run it in batch...

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

              3D-surface - for me - means, I need a shader i.e. a phong material. "physical simulation, AI and all that stuff" is not part of the current Qt3D, at least AFAIK.

              1 Reply Last reply
              0
              • J Offline
                J Offline
                Jjcasmar
                wrote on last edited by
                #7

                I just need the geometry data in the scene, meshes, vertex and triangles, no visualization. What I want to do is not even important for the question...

                Anyway, I have tried to use a Qt3DWindow to get the normal behavior and the QSceneLoader is giving an error and I don't know why...

                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