Load 3d files with Qt3D



  • Hi i've build Qt3D for my Qt version (4.7.4 mingW), and i succefull compiled my small app. Now i want to load my 3D files, but the only file format i can load is .3ds For every other file formats like .blend, .obj, or .smd and maybe other file formats it give me error like :

    "Asset importer error: Failed to open file" for obj files
    "Asset importer error: Failed to open SMD/VTA" file for smd files
    "Asset importer error: BLEND" for blend file

    why it do this, ive tried to use assetviwer example it can also load only 3ds format..
    There is a solution??

    Thanks in advance!!



  • In the mean while, i see that the same fill could be open in other system path and in the other not.. still don't understand.



  • I fanally understand what is going wrong: it seems that

    QGLAbstractScene *loadScene(const QString& fileName, const QString& format = QString(),const QString& options = QString());

    don't like file path with space on names... i must convert the path to URL with QUrl..

    so the function used is this

    QGLAbstractScene *loadScene(const QUrl& url, const QString& format = QString(), const QString& options = QString());

    now the problem is that it load the file as i want... but it also try to connect to internet and give me this error..

    Error in network reply:
    Network request failed. Texture not loaded.



  • Try @QGLAbstractScene::loadScene(QLatin1String("file.3ds"));@

    If that don't work add the file to a qrc file
    and try @QGLAbstractScene::loadScene(QLatin1String(":/file.3ds"));@

    You don't really need the Option and Format arguments.



  • Hi thanks for the reply!! but..
    the file that i want to open aren't in the exe directory but located in other place... so the user can open a file and view it. However i've tried to use QLatin1String insetad of the QString passed by QFileDialog::getOpenFile(); i've tried also to add the file to the qrc to see if the can't be opened because are protected or similar but it do the same thing. It don't like space int names!!



  • It is very hard to help you because you don't give us a whole lot to go by.

    Can give us more log details, show us your code specifically how you implemented qfiledialog and the loadscene function.

    Also try to print the string from Qfiledialog spits out and see what it says, because i suspect that might be the culprit.

    You might need to add:
    @ QString modelsDir = QDir::toNativeSeparators(QDir::homePath());@
    as shown here.
    http://qt-project.org/forums/viewthread/16150

    It may also be bugs which has been fixed in later versions of QT4 and QT3D:qt4.
    An upgrade wouldn't hurt.



  • this the code:

    @void GlViewer::importMesh()
    {

    QString filter = tr("All supported formats (%1)").arg(QGLAbstractScene::supportedFormats().join(" "));

    QString file = QFileDialog::getOpenFileName(this,tr("Open 3D Model"),currentDir,filter);
    if (file!="")
    {
    if ((m_mesh = QGLAbstractScene::loadScene(QUrl(file),"","ShowWarnings")))
    {

          importedMesh = m_mesh->mainNode();
          update();
          emit reportStatus(tr("Mesh imported sucefully!"),3000);//1 s
          currentDir = QFileInfo(file).absolutePath();
        }
      else
        {
          emit reportStatus(tr("Failed"),3000);
          QMessageBox::warning(this,tr("Mesh importing"),tr("Failed to import the mesh"));
        }
    }
    

    }
    @

    and this is how QFileDialog return the path:
    C:\Users\Luca\Documents\QT\3D_Mate_qt3dversion\Resource\Headband low.smd
    the path is how a windows user see it in the adress bar...
    as you can see the the file have a space on it's name.

    and this is the full log of the importing mesh without converting it to a url:

    Info, T3020: Load C:/Users/Luca/Documents/QT/3D_Mate_qt3dversion/Resource/Headband Low.smd
    Debug, T3020: Assimp 2.0.863 x86 gcc debug singlethreaded
    Info, T3020: Found a matching importer for this file format
    Info, T3020: Import root directory is 'C:/Users/Luca/Documents/QT/3D_Mate_qt3dversion/Resource'
    Warn, T3020: Error: could not open subsequent file:C:/Users/Luca/Documents/QT/3D_Mate_qt3dversion/Resource/Headband Low.smd--La sintassi del nome del file, della directory o del volume non è corretta.
    Skipping one or more lines with the same contents
    Warn, T3020: Error: could not open subsequent file:C:\Users\Luca\Documents\QT\3D_Mate_qt3dversion\Resource\Headband Low.smd--La sintassi del nome del file, della directory o del volume non è corretta.
    Asset importer error: Failed to open SMD/VTA file C:/Users/Luca/Documents/QT/3D_Mate_qt3dversion/Resource/Headband Low.smd.

    I will try your suggestion! and i'll let you know!
    Thanks



  • tried it but don't work... However do you now where i can find the latest source for Qt 4.8 ?? the last one is about one years ago...


  • Moderators

    The source of Qt 4.8.4 is available from "download page":http://qt-project.org/downloads#qt-lib
    For Windows you need to download the zip-file because of line endings.
    There is also a link given to Git for getting version after the official releases.



  • i know this... I mean the last source of Qt3D for Qt 4.8.4.... sorry for the disambiguation.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.