Re: [Interest] Qt3D widget

2020-09-04 Thread Florian Blume
I actually succeeded in implementing a Qt3D widget.

It can be found here: https://github.com/florianblume/qt3d-widget.

Unfortunately, I had to use Qt3D's internal classes so it kind of feels
a bit unstable because it might break with certain Qt versions.
I would have liked to leave all processing loops to Qt3D internally but
now have to drive them myself, which also feels a bit not so nice.

Anyways, I hope some other people can make use of it, too!

Best,
Florian

On 02.09.20 12:01, Florian Blume wrote:
> Hey,
>
> thanks for your quick answer!
>
> I actually had the version you described first running. I obtained the
> rendered image using QRenderCapture and then displayed it on the quad.
>
> I also already had the second idea that you described but thought it
> should be possible to obtain the texture from Qt3D and use it in OpenGL
> that's why I hadn't
> investigated this any further.
>
> Unfortunately, it's pretty difficult to run the aspect engine manually.
> I tried to place a processFrame() call in paintGL() - and even placed a
> doRender() call to
> the AbstractRenderer of the QRenderAspectPrivate after it like this:
>
> d->m_aspectEngine->processFrame();
>
> glClearColor(1.0, 1.0, 1.0, 1.0);
> glDisable(GL_BLEND);
> glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
>
> Qt3DRender::QRenderAspectPrivate *dRenderAspect =
> static_cast
>    
> (Qt3DRender::QRenderAspectPrivate::get(d->m_renderAspect));
> Qt3DRender::Render::AbstractRenderer *renderer = dRenderAspect->m_renderer;
> renderer->doRender(true);
>
> Without the doRender() call it gets stuck the second time processFrame()
> is called - in
> Qt3DRender::Render::VSyncFrameAdvanceService::waitForNextFrame() where it
> tries to acquire a semaphore (which apparently doesn't have any more
> work ready).
>
> With the doRender() call it gets stuck in a similar place - but in the
> first call to paintGL in Qt3DRender::Render::Renderer::isReadyToSubmit()
> where it again tries to
> acquire a semaphore.
>
> I also don't understand whether it's enough that QOpenGLWidget binds a
> framebuffer before calling paintGL, it looks like in Scene3DRenderer
> this is enough to make
> Qt3D draw to that framebuffer.
>
> As you can see there are a lot of open questions which are difficult to
> answer. Do you have any suggestions where/how to look for answers?
> Obviously in the code itself,
> which is also difficult.
>
> Any help is appreciated,
> Florian
>
>
> On 01.09.20 18:28, Mike Krus wrote:
>> Hi
>>
>> Qt 3D source code has an example of how to use render capture in the manual 
>> tests.
>>
>> However this is probably not the right way to do it as 1/ it would require 
>> another FBO on top of the one QOpenGLWidget uses already; 2/ it transfers 
>> the image to the CPU which is not needed here.
>>
>> Think the way to do it is to do something similar to what is done for 
>> Scene3D:
>> - setup Qt 3D engine to be in manual mode (rather than using the simulation 
>> loop)
>>   by calling QAspectEngine::setRunMode(QAspectEngine::Manual)
>> - use QOpenGLWidget and in the paintGL method call 
>> QAspectEngine::processFrame()
>>   to have Qt 3D draw
>>
>> There’s of course lots of other stuff to setup. Might need a dummy offscreen 
>> surface to handle sizing, handling of the context, and a fair amount more.
>>
>> Mike
>>
>>> On 1 Sep 2020, at 16:51, Florian Blume  wrote:
>>>
>>> Hi,
>>>
>>> I'm trying to implement a Qt3D widget since createWindowContainer is not
>>> suitable for me (always draws the Qt3DWindow on top of everything).
>>> I've already asked a Stackverflow question
>>> (https://stackoverflow.com/questions/63686309/use-qt3d-offscreen-rendered-texture-in-opengl)
>>> because I ran into
>>> several issues trying to display an offscreen texture that I render to
>>> with Qt3D in a QOpenGLWidget (it simply doesn't display anything).
>>>
>>> Has anyone some other solution regarding a Qt3D widget?
>>>
>>> Best regards,
>>> Florian
>>> ___
>>> Interest mailing list
>>> Interest@qt-project.org
>>> https://lists.qt-project.org/listinfo/interest
>> —
>> Mike Krus | mike.k...@kdab.com | Senior Software Engineer
>> KDAB (UK) Ltd., a KDAB Group company
>> Tel: UK Office +44 1625 809908   Mobile +44 7833 491941
>> KDAB - The Qt Experts, C++, OpenGL Experts
>>
>>
> ___
> Interest mailing list
> Interest@qt-project.org
> https://lists.qt-project.org/listinfo/interest

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Qt3D widget

2020-09-02 Thread Florian Blume
Hey,

thanks for your quick answer!

I actually had the version you described first running. I obtained the
rendered image using QRenderCapture and then displayed it on the quad.

I also already had the second idea that you described but thought it
should be possible to obtain the texture from Qt3D and use it in OpenGL
that's why I hadn't
investigated this any further.

Unfortunately, it's pretty difficult to run the aspect engine manually.
I tried to place a processFrame() call in paintGL() - and even placed a
doRender() call to
the AbstractRenderer of the QRenderAspectPrivate after it like this:

d->m_aspectEngine->processFrame();

glClearColor(1.0, 1.0, 1.0, 1.0);
glDisable(GL_BLEND);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

Qt3DRender::QRenderAspectPrivate *dRenderAspect =
static_cast
   
(Qt3DRender::QRenderAspectPrivate::get(d->m_renderAspect));
Qt3DRender::Render::AbstractRenderer *renderer = dRenderAspect->m_renderer;
renderer->doRender(true);

Without the doRender() call it gets stuck the second time processFrame()
is called - in
Qt3DRender::Render::VSyncFrameAdvanceService::waitForNextFrame() where it
tries to acquire a semaphore (which apparently doesn't have any more
work ready).

With the doRender() call it gets stuck in a similar place - but in the
first call to paintGL in Qt3DRender::Render::Renderer::isReadyToSubmit()
where it again tries to
acquire a semaphore.

I also don't understand whether it's enough that QOpenGLWidget binds a
framebuffer before calling paintGL, it looks like in Scene3DRenderer
this is enough to make
Qt3D draw to that framebuffer.

As you can see there are a lot of open questions which are difficult to
answer. Do you have any suggestions where/how to look for answers?
Obviously in the code itself,
which is also difficult.

Any help is appreciated,
Florian


On 01.09.20 18:28, Mike Krus wrote:
> Hi
>
> Qt 3D source code has an example of how to use render capture in the manual 
> tests.
>
> However this is probably not the right way to do it as 1/ it would require 
> another FBO on top of the one QOpenGLWidget uses already; 2/ it transfers the 
> image to the CPU which is not needed here.
>
> Think the way to do it is to do something similar to what is done for Scene3D:
> - setup Qt 3D engine to be in manual mode (rather than using the simulation 
> loop)
>   by calling QAspectEngine::setRunMode(QAspectEngine::Manual)
> - use QOpenGLWidget and in the paintGL method call 
> QAspectEngine::processFrame()
>   to have Qt 3D draw
>
> There’s of course lots of other stuff to setup. Might need a dummy offscreen 
> surface to handle sizing, handling of the context, and a fair amount more.
>
> Mike
>
>> On 1 Sep 2020, at 16:51, Florian Blume  wrote:
>>
>> Hi,
>>
>> I'm trying to implement a Qt3D widget since createWindowContainer is not
>> suitable for me (always draws the Qt3DWindow on top of everything).
>> I've already asked a Stackverflow question
>> (https://stackoverflow.com/questions/63686309/use-qt3d-offscreen-rendered-texture-in-opengl)
>> because I ran into
>> several issues trying to display an offscreen texture that I render to
>> with Qt3D in a QOpenGLWidget (it simply doesn't display anything).
>>
>> Has anyone some other solution regarding a Qt3D widget?
>>
>> Best regards,
>> Florian
>> ___
>> Interest mailing list
>> Interest@qt-project.org
>> https://lists.qt-project.org/listinfo/interest
> —
> Mike Krus | mike.k...@kdab.com | Senior Software Engineer
> KDAB (UK) Ltd., a KDAB Group company
> Tel: UK Office +44 1625 809908   Mobile +44 7833 491941
> KDAB - The Qt Experts, C++, OpenGL Experts
>
>

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] Qt3D widget

2020-09-01 Thread Florian Blume
Hi,

I'm trying to implement a Qt3D widget since createWindowContainer is not
suitable for me (always draws the Qt3DWindow on top of everything).
I've already asked a Stackverflow question
(https://stackoverflow.com/questions/63686309/use-qt3d-offscreen-rendered-texture-in-opengl)
because I ran into
several issues trying to display an offscreen texture that I render to
with Qt3D in a QOpenGLWidget (it simply doesn't display anything).

Has anyone some other solution regarding a Qt3D widget?

Best regards,
Florian
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] real time data input in Qt3D scene

2018-02-02 Thread Florian Blume
What excatly are you trying to achieve? That the position of the sphere
is updated when data is incoming as the QVector3D?

Then you simply have to set the translation on the sphereTransform to
the vector and the scene will be updated.


On 31.01.2018 15:02, Dimitrios Anagnostakis wrote:
>
> Hi all,
>
>  
>
> I’m trying to make a scene in Qt3D which shows an STL object model and
> a 3D point which is updated with real time data from a tracking software.
>
>  
>
> What I have so far is to display the object and a 3d sphere as a 3d
> point. Below is my code:
>
> The position of the sphere is set using the
> sphereTransform->setTranslation(QVector3D(-1.0f,10.0f,7.0f));
>
>  
>
> How can I set this to be updated directly by the incoming data which
> is in the form of QVector3d with x, y and z?
>
>  
>
> Thank you in advance for any help.
>
>  
>
> Regards, Dimis.
>
>  
>
> In the scenemodifier.cpp:
>
>  
>
> SceneModifier::SceneModifier(Qt3DCore::QEntity*rootEntity)
>     :m_rootEntity(rootEntity)
> {
>  
> LoadSTL();
> displayPoints();
>  
> }
>
>  
>
>  
>
> voidSceneModifier::LoadSTL()
>
> {
>
>     QUrldata=QUrl::fromLocalFile("C:/Qt/Examples/stylus_tip/block1.stl");
>
>     Qt3DRender::QMesh*partMesh=newQt3DRender::QMesh;
>
>     partMesh->setSource(data);
>
>  
>
>     //PartTransform
>
>     Qt3DCore::QTransform*partTransform=newQt3DCore::QTransform();
>
>     //partTransform->setScale(4.0f);
>
>     //partTransform->setTranslation(QVector3D(5.0f,-4.0f,0.0f));
>
>  
>
>     //Partmaterial
>
>    
> Qt3DExtras::QPhongMaterial*partMaterial=newQt3DExtras::QPhongMaterial();
>
>     partMaterial->setDiffuse(QColor(0,200,255));
>
>  
>
>     //part(STLmodel)
>
>     m_partEntity=newQt3DCore::QEntity(m_rootEntity);
>
>     m_partEntity->addComponent(partMesh);
>
>     m_partEntity->addComponent(partMaterial);
>
>     m_partEntity->addComponent(partTransform);
>
> }
>
>  
>
> voidSceneModifier::displayPoints()
>
> {
>
>     //Sphereshapedata
>
>     Qt3DExtras::QSphereMesh*sphereMesh=newQt3DExtras::QSphereMesh();
>
>     sphereMesh->setRadius(0.75f);;
>
>  
>
>     //Spheremeshtransform
>
>     Qt3DCore::QTransform*sphereTransform=newQt3DCore::QTransform();
>
>     sphereTransform->setTranslation(QVector3D(-1.0f,10.0f,7.0f));
>
>     sphereTransform->setScale(1.3f);
>
>  
>
>     //Spherematerial
>
>    
> Qt3DExtras::QPhongMaterial*sphereMaterial=newQt3DExtras::QPhongMaterial();
>
>     sphereMaterial->setDiffuse(QColor(250,250,0));
>
>  
>
>     //Sphere
>
>     m_sphereEntity=newQt3DCore::QEntity(m_rootEntity);
>
>     m_sphereEntity->addComponent(sphereMesh);
>
>     m_sphereEntity->addComponent(sphereMaterial);
>
>     m_sphereEntity->addComponent(sphereTransform);
>
>  
>
> }
>
>  
>
> In the main:
>
>  
>
> intmain(intargc,char*argv[])
> {
>     QApplicationa(argc,argv);
>  
>     Qt3DExtras::Qt3DWindowview;
>  
>     Qt3DCore::QEntity*rootEntity=newQt3DCore::QEntity;
>  
>     Qt3DRender::QCamera*camera=view.camera();
>     camera->lens()->setPerspectiveProjection(45.0f,16.0f/9.0f,0.1f,1000.0f);
>     camera->setPosition(QVector3D(0,0,320.0f));
>     camera->setUpVector(QVector3D(0,1,0));
>     camera->setViewCenter(QVector3D(0,0,0));
>  
>     
> Qt3DExtras::QOrbitCameraController*camController=newQt3DExtras::QOrbitCameraController(rootEntity);
>     camController->setCamera(camera);
>  
>     Qt3DCore::QEntity*lightEntity=newQt3DCore::QEntity(rootEntity);
>     Qt3DRender::QPointLight*light=newQt3DRender::QPointLight(lightEntity);
>     light->setColor("white");
>     light->setIntensity(1);
>     lightEntity->addComponent(light);
>  
>     Qt3DCore::QTransform*lightTransform=newQt3DCore::QTransform(lightEntity);
>     lightTransform->setTranslation(QVector3D(50,-50,-150.0f));
>     lightEntity->addComponent(lightTransform);
>  
>     Qt3DCore::QEntity*lightEntity2=newQt3DCore::QEntity(rootEntity);
>     Qt3DRender::QPointLight*light2=newQt3DRender::QPointLight(lightEntity2);
>     light2->setColor("white");
>     light2->setIntensity(1);
>     lightEntity2->addComponent(light2);
>  
>     
> Qt3DCore::QTransform*lightTransform2=newQt3DCore::QTransform(lightEntity2);
>     lightTransform2->setTranslation(QVector3D(-50,50,150.0f));
>     lightEntity2->addComponent(lightTransform2);
>  
>    SceneModifier*modifier=newSceneModifier(rootEntity);
>  
>    view.setRootEntity(rootEntity);
>    view.show();
>  
>     returna.exec();
> }
>
>  
>
> The display is:
>
>  
>
>  
>
>  
>
>
>
> ___
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] Qt3D - Render to QImage

2018-01-05 Thread Florian Blume
If you're still interested into rendering to

QImage you can look at the following example:

https://github.com/Sonnentierchen/Qt3D-OfflineRenderer

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] Qt3D Rendering offscreen

2018-01-05 Thread Florian Blume
I've got a working example running that renders the scene completely
offline. See here: https://github.com/Sonnentierchen/Qt3D-OfflineRenderer.
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest