Load 3D model with Qt3D (Qt5.5)
-
Hi everybody
As the new Qt5.5 version is ready with some changes in Qt3D module, i'm trying to load a 3D model (i don't care the format: 3ds, obj, js ...) and rotate it. I already found many info about it like Assimp or GLC_LIB but i was wondering if with the new Qt3D release in Qt5.5 there is some easy way to do it, as this part of my application is really simple and i'm new on these concepts about QML, OpenGL, etc...
I already read many info about this and i'm a bit collapsed, so basically now i'm searching for a simple example to load a model and play with it.
Thanks in advance,
Amg -
You should take a look at the Qt3D Examples page. Object loading is done in e.g. assimp Example.
-
@Chris-Kawa Thanks for reply, i tried to open that example that comes when installing the Qt5.5 but i get this error when executing:
error: cannot find -lQt53D
The others examples work but they are not for loading models. Is it possible to open a model with assimp without using QML? Or, How can i insert qml into a qwidget in Qt5.5? I found:
#include <QDeclarativeView>
...but looks like was for Qt4.8 version, I tried with QQuickView from Qt5.5 without success...
-
Finaly i could add a js model (qml) to a widget. To do it i created a widget container and i inserted my QQuickView object on it. After i have to find out the way to export my own 3D model into a Three.js format.
But i'm still interested on the OpenGL Widget and on how to load a 3ds model with Assimp, for the moment i couldn't fix the error: "cannot find -lQt35D"
If someone has an idea or suggestion would be great!
Thanks! -
Hi,
Do you have that error from building one of the example ?
-
How did you install Qt 5.5 ?
-
I just downloaded the Qt5.5 version from:
http://download.qt.io/official_releases/qt/5.5/5.5.0/qt-opensource-linux-x64-5.5.0-2.run
...I executed the run file and that's it. But i realised that i cannot run the Qt3d examples, in most of them i get the same error and now i'm wondering if i need to install something else, I though not because Qt3D comes inside the Qt5.5 release, Isn't it?
-
@avmg The problem with the Assimp.cpp example is that it uses the setSource in QAbstractSceneLoader class which only allows one object to be loaded into the scene. When it's followed with another setSource it destroys the original object. This makes it unusable as is. QML does it with the Assimp example so it should be able to be done in C++. Question is, how?
-
Found it.
in the materials sample they use m_plant->mesh()->setSource(QUrl(QStringLiteral("qrc:/assets/houseplants/") + potNames[m_potShape] + QStringLiteral("-") + plantNames[m_plantType] + QStringLiteral(".obj")));.
This effectively load multiple 3d objects so they can be manipulated by Qt3D. The world of Qt3D is right again.