Best option for 3D Viewer in Qt 5.0
-
I am writing an application that will let users pick stuff from a scrollable list of objects(represented as icons in the list). Then drop them to a 3D Viewer. Then the user clicks ‘Play’ and these objects move.
Its for a physics simulation where the objects to be added are in the list. So the interface is quite simple and I wanted to create it in QML. The simulation classes are in C++ (Bullet Physics). I am planning to make a 3D Viewer where the objects can be seen moving(following the laws of physics), as a QML Extension Plugin implemented in C++.
The interface is this:!http://s29.postimg.org/xk5owzohz/frame.png(Interface)!
The middle light gray area is where the 3D viewer will come in. The scene will be quite simple for now with max 15 to 20 objects scattered about.
I would like to know the best way to do this. Here are the options I have found so far:
-
Write a QQuickFramebufferObject based class: http://qt-project.org/doc/qt-5/qquickframebufferobject.html#details
This provides a FBO already and I have to implement the renderer in a QQuickFramebufferObject ::Renderer class: http://qt-project.org/doc/qt-5/qtquick-scenegraph-textureinsgnode-example.html -
Extend QQuickItem http://qt-project.org/doc/qt-5.0/qtquick/scenegraph-openglunderqml.html
But this means I have to deal with Qt's scene graph and also create a FBO for some reason. I am not sure if this will result in my rendering going into the correct area of the window(gray area) -
Extend from QQuickPaintedItem and implement paint()
-
Extend QDeclarativeItem which seems to be deprecated.
I would like to keep the drawing efficient and as fast as possible.
-
-
So there is a full featured example under : Qt5.2.1\5.2.1\msvc2012\examples\quick\scenegraph\textureinsgnode
It shows how to use the QQuickFramebufferObject and create a renderer etc. Studying it now.
Qt is absolutely awesome !!!!!
-
Please keep us/this thread updated!
-
Well I shoved in the 3D viewer(which I call a simviewer) now :
!http://s2.postimg.org/hl6zgn03t/frame.png(Sim Viewer)!
Code here:
https://code.google.com/p/rapid-concepts/source/browse/#svn/trunkBased it on : \Qt\Qt5.2.1\5.2.1\msvc2012\examples\quick\scenegraph\textureinsgnode
After adding the new C++ files, I got a linking error. It seems the files do get added to the project .pro file correctly, but qmake is not run automatically. So ran it and everything is good now :)
Also the new type has to be registered in main as a new qml meta type.
Qt is awesome !
-
Great work! I'll check it out later. :)