Re: [Interest] Qt3D : QSceneLoader - determining scene level geometry bounding box

2022-08-08 Thread Mike Krus via Interest
please file a bug report


Mike

> On 8 Aug 2022, at 17:21, Nicholas Yue  wrote:
>
> Hi Mike,
>
> I have now tried calling updateImplicitBounds() but it returns false
>
> Is that indicating some underlying issue elsewhere?
>
> ```
> Status changed: Qt3DRender::QSceneLoader::Loading
> Status changed: Qt3DRender::QSceneLoader::Ready
>  Entity: Qt3DCore::QEntity(0x7ffaac004660, name = untitled.obj) Components: 
> QList(Qt3DCore::QTransform(0x7ffaac04c590))
> BoundingVolume:  "untitled.obj"
>Entity: Qt3DCore::QEntity(0x7ffaac019220, name = Suzanne) Components: 
> QList(Qt3DExtras::QPhongMaterial(0x7ffaac01bf30, name = DefaultMaterial), 
> Qt3DRender::QGeometryRenderer(0x7ffaac00c4d0), 
> Qt3DCore::QTransform(0x7ffaac045800))
> BoundingVolume:  "Suzanne"
> gr is Valid
> updateImplicitBounds returns FALSE
> ```
>
> ```
> void SceneWalker::walkEntity(Qt3DCore::QEntity *e, int depth)
> {
> Qt3DCore::QNodeVector nodes = e->childNodes();
> for (int i = 0; i < nodes.count(); ++i) {
> Qt3DCore::QNode *node = nodes[i];
> Qt3DCore::QEntity *entity = qobject_cast(node);
> if (entity) {
> QString indent;
> indent.fill(' ', depth * 2);
> qDebug().noquote() << indent << "Entity:" << entity << 
> "Components:" << entity->components();
> {
> // Question about BoundingVolume
> qDebug() << "BoundingVolume: " << entity->objectName();
> const QList myQGeometryRenderer 
> = entity->componentsOfType();
> if (!myQGeometryRenderer.isEmpty())
> {
> Qt3DRender::QGeometryRenderer *gr = myQGeometryRenderer[0];
> if (gr){
> qDebug() << "gr is Valid";
> if (gr->updateImplicitBounds()){
> QVector3D minPoint = gr->implicitMinPoint();
> QVector3D maxPoint = gr->implicitMaxPoint();
> qDebug() << "minPoint: " << minPoint;
> qDebug() << "maxPoint: " << maxPoint;
> }
> else
> qDebug() << "updateImplicitBounds returns FALSE";
> }
> }
> }
> walkEntity(entity, depth + 1);
> }
> }
> }
> ```
>
> On Sat, 6 Aug 2022 at 00:09, Mike Krus  wrote:
> the computations are done a background thread, you may have to wait 1 frame 
> before they are valid.
> Or call QBoundingVolume::updateImplicitBounds() before reading them.
>
> If it fails please submit a bug report with a small example
>
> Mike
>
> > On 5 Aug 2022, at 20:38, Nicholas Yue  wrote:
> >
> > Any insight ?
> >
> > On Wed, 3 Aug 2022 at 15:44, Nicholas Yue  wrote:
> > I have the following code
> >
> > ```
> > void SceneWalker::walkEntity(Qt3DCore::QEntity *e, int depth)
> > {
> > Qt3DCore::QNodeVector nodes = e->childNodes();
> > for (int i = 0; i < nodes.count(); ++i) {
> > Qt3DCore::QNode *node = nodes[i];
> > Qt3DCore::QEntity *entity = qobject_cast(node);
> > if (entity) {
> > QString indent;
> > indent.fill(' ', depth * 2);
> > qDebug().noquote() << indent << "Entity:" << entity << 
> > "Components:" << entity->components();
> >
> > {
> > // Question about BoundingVolume
> > qDebug() << "BoundingVolume: " << entity->objectName();
> > const QList 
> > myQGeometryRenderer = 
> > entity->componentsOfType();
> > if (!myQGeometryRenderer.isEmpty())
> > {
> > Qt3DRender::QGeometryRenderer *gr = myQGeometryRenderer[0];
> > QVector3D minPoint = gr->implicitMinPoint();
> > QVector3D maxPoint = gr->implicitMaxPoint();
> > qDebug() << "minPoint: " << minPoint;
> > qDebug() << "maxPoint: " << maxPoint;
> > }
> > }
> > walkEntity(entity, depth + 1);
> > }
> > }
> > }
> > ```
> >
> > But I got the (0,0,0) for both the min/max point
> >
> > ```
> > Status changed: Qt3DRender::QSceneLoader::Loading
> > Status changed: Qt3DRender::QSceneLoader::Ready
> >  Entity: Qt3DCore::QEntity(0x7f65dc004660, name = untitled.obj) Components: 
> > QList(Qt3DCore::QTransform(0x7f65dc04c590))
> >Entity: Qt3DCore::QEntity(0x7f65dc019220, name = Suzanne) Components: 
> > QList(Qt3DExtras::QPhongMaterial(0x7f65dc01bf30, name = DefaultMaterial), 
> > Qt3DRender::QGeometryRenderer(0x7f65dc00c4d0), 
> > Qt3DCore::QTransform(0x7f65dc045800))
> > BoundingVolume:  "Suzanne"
> > minPoint:  QVector3D(0, 0, 0)
> > maxPoint:  QVector3D(0, 0, 0)
> > BoundingVolume:  "untitled.obj"
> > ```
> >
> > I am using Qt 6.2.2 on Ubuntu
> >
> > Cheers
> >
> > On Wed, 3 Aug 2022 at 01:25, Mike Krus  wrote:
> > Hi
> >
> > once the scene is loaded (ie, the status is Ready, keeping in mind loading 
> > is asynchronous), you can use
> > QSceneLoader::entity() to get a loaded entity by name, and then 
> > QEntity::componentsOfType() to get the component.
> > Loaded entities are children of the entity that the QSceneLoader component 

Re: [Interest] Qt3D : QSceneLoader - determining scene level geometry bounding box

2022-08-08 Thread Nicholas Yue
Hi Mike,

I have now tried calling updateImplicitBounds() but it returns false

Is that indicating some underlying issue elsewhere?

```
Status changed: Qt3DRender::QSceneLoader::Loading
Status changed: Qt3DRender::QSceneLoader::Ready
 Entity: Qt3DCore::QEntity(0x7ffaac004660, name = untitled.obj) Components:
QList(Qt3DCore::QTransform(0x7ffaac04c590))
BoundingVolume:  "untitled.obj"
   Entity: Qt3DCore::QEntity(0x7ffaac019220, name = Suzanne) Components:
QList(Qt3DExtras::QPhongMaterial(0x7ffaac01bf30, name = DefaultMaterial),
Qt3DRender::QGeometryRenderer(0x7ffaac00c4d0),
Qt3DCore::QTransform(0x7ffaac045800))
BoundingVolume:  "Suzanne"
gr is Valid
updateImplicitBounds returns FALSE
```

```
void SceneWalker::walkEntity(Qt3DCore::QEntity *e, int depth)
{
Qt3DCore::QNodeVector nodes = e->childNodes();
for (int i = 0; i < nodes.count(); ++i) {
Qt3DCore::QNode *node = nodes[i];
Qt3DCore::QEntity *entity = qobject_cast(node);
if (entity) {
QString indent;
indent.fill(' ', depth * 2);
qDebug().noquote() << indent << "Entity:" << entity <<
"Components:" << entity->components();
{
// Question about BoundingVolume
qDebug() << "BoundingVolume: " << entity->objectName();
const QList
myQGeometryRenderer =
entity->componentsOfType();
if (!myQGeometryRenderer.isEmpty())
{
Qt3DRender::QGeometryRenderer *gr = myQGeometryRenderer[0];
if (gr){
qDebug() << "gr is Valid";
if (gr->updateImplicitBounds()){
QVector3D minPoint = gr->implicitMinPoint();
QVector3D maxPoint = gr->implicitMaxPoint();
qDebug() << "minPoint: " << minPoint;
qDebug() << "maxPoint: " << maxPoint;
}
else
qDebug() << "updateImplicitBounds returns FALSE";
}
}
}
walkEntity(entity, depth + 1);
}
}
}
```

On Sat, 6 Aug 2022 at 00:09, Mike Krus  wrote:

> the computations are done a background thread, you may have to wait 1
> frame before they are valid.
> Or call QBoundingVolume::updateImplicitBounds() before reading them.
>
> If it fails please submit a bug report with a small example
>
> Mike
>
> > On 5 Aug 2022, at 20:38, Nicholas Yue  wrote:
> >
> > Any insight ?
> >
> > On Wed, 3 Aug 2022 at 15:44, Nicholas Yue 
> wrote:
> > I have the following code
> >
> > ```
> > void SceneWalker::walkEntity(Qt3DCore::QEntity *e, int depth)
> > {
> > Qt3DCore::QNodeVector nodes = e->childNodes();
> > for (int i = 0; i < nodes.count(); ++i) {
> > Qt3DCore::QNode *node = nodes[i];
> > Qt3DCore::QEntity *entity = qobject_cast *>(node);
> > if (entity) {
> > QString indent;
> > indent.fill(' ', depth * 2);
> > qDebug().noquote() << indent << "Entity:" << entity <<
> "Components:" << entity->components();
> >
> > {
> > // Question about BoundingVolume
> > qDebug() << "BoundingVolume: " << entity->objectName();
> > const QList
> myQGeometryRenderer =
> entity->componentsOfType();
> > if (!myQGeometryRenderer.isEmpty())
> > {
> > Qt3DRender::QGeometryRenderer *gr = myQGeometryRenderer[0];
> > QVector3D minPoint = gr->implicitMinPoint();
> > QVector3D maxPoint = gr->implicitMaxPoint();
> > qDebug() << "minPoint: " << minPoint;
> > qDebug() << "maxPoint: " << maxPoint;
> > }
> > }
> > walkEntity(entity, depth + 1);
> > }
> > }
> > }
> > ```
> >
> > But I got the (0,0,0) for both the min/max point
> >
> > ```
> > Status changed: Qt3DRender::QSceneLoader::Loading
> > Status changed: Qt3DRender::QSceneLoader::Ready
> >  Entity: Qt3DCore::QEntity(0x7f65dc004660, name = untitled.obj)
> Components: QList(Qt3DCore::QTransform(0x7f65dc04c590))
> >Entity: Qt3DCore::QEntity(0x7f65dc019220, name = Suzanne) Components:
> QList(Qt3DExtras::QPhongMaterial(0x7f65dc01bf30, name = DefaultMaterial),
> Qt3DRender::QGeometryRenderer(0x7f65dc00c4d0),
> Qt3DCore::QTransform(0x7f65dc045800))
> > BoundingVolume:  "Suzanne"
> > minPoint:  QVector3D(0, 0, 0)
> > maxPoint:  QVector3D(0, 0, 0)
> > BoundingVolume:  "untitled.obj"
> > ```
> >
> > I am using Qt 6.2.2 on Ubuntu
> >
> > Cheers
> >
> > On Wed, 3 Aug 2022 at 01:25, Mike Krus  wrote:
> > Hi
> >
> > once the scene is loaded (ie, the status is Ready, keeping in mind
> loading is asynchronous), you can use
> > QSceneLoader::entity() to get a loaded entity by name, and then
> QEntity::componentsOfType() to get the component.
> > Loaded entities are children of the entity that the QSceneLoader
> component was assigned to, and components and
> > entities are all QObjects so you can use the normal tree traversal
> techniques that work with any QObject to find
> > objects by type or name.
> >
> >
> > Mike
> >
> > > On 3 Aug 2022, 

Re: [Interest] Qt3D : QSceneLoader - determining scene level geometry bounding box

2022-08-05 Thread Nicholas Yue
Any insight ?

On Wed, 3 Aug 2022 at 15:44, Nicholas Yue  wrote:

> I have the following code
>
> ```
> void SceneWalker::walkEntity(Qt3DCore::QEntity *e, int depth)
> {
> Qt3DCore::QNodeVector nodes = e->childNodes();
> for (int i = 0; i < nodes.count(); ++i) {
> Qt3DCore::QNode *node = nodes[i];
> Qt3DCore::QEntity *entity = qobject_cast *>(node);
> if (entity) {
> QString indent;
> indent.fill(' ', depth * 2);
> qDebug().noquote() << indent << "Entity:" << entity <<
> "Components:" << entity->components();
>
> {
> // Question about BoundingVolume
> qDebug() << "BoundingVolume: " << entity->objectName();
> const QList
> myQGeometryRenderer =
> entity->componentsOfType();
> if (!myQGeometryRenderer.isEmpty())
> {
> Qt3DRender::QGeometryRenderer *gr = myQGeometryRenderer[0];
> QVector3D minPoint = gr->implicitMinPoint();
> QVector3D maxPoint = gr->implicitMaxPoint();
> qDebug() << "minPoint: " << minPoint;
> qDebug() << "maxPoint: " << maxPoint;
> }
> }
> walkEntity(entity, depth + 1);
> }
> }
> }
> ```
>
> But I got the (0,0,0) for both the min/max point
>
> ```
> Status changed: Qt3DRender::QSceneLoader::Loading
> Status changed: Qt3DRender::QSceneLoader::Ready
>  Entity: Qt3DCore::QEntity(0x7f65dc004660, name = untitled.obj)
> Components: QList(Qt3DCore::QTransform(0x7f65dc04c590))
>Entity: Qt3DCore::QEntity(0x7f65dc019220, name = Suzanne) Components:
> QList(Qt3DExtras::QPhongMaterial(0x7f65dc01bf30, name = DefaultMaterial),
> Qt3DRender::QGeometryRenderer(0x7f65dc00c4d0),
> Qt3DCore::QTransform(0x7f65dc045800))
> BoundingVolume:  "Suzanne"
> minPoint:  QVector3D(0, 0, 0)
> maxPoint:  QVector3D(0, 0, 0)
> BoundingVolume:  "untitled.obj"
> ```
>
> I am using Qt 6.2.2 on Ubuntu
>
> Cheers
>
> On Wed, 3 Aug 2022 at 01:25, Mike Krus  wrote:
>
>> Hi
>>
>> once the scene is loaded (ie, the status is Ready, keeping in mind
>> loading is asynchronous), you can use
>> QSceneLoader::entity() to get a loaded entity by name, and then
>> QEntity::componentsOfType() to get the component.
>> Loaded entities are children of the entity that the QSceneLoader
>> component was assigned to, and components and
>> entities are all QObjects so you can use the normal tree traversal
>> techniques that work with any QObject to find
>> objects by type or name.
>>
>>
>> Mike
>>
>> > On 3 Aug 2022, at 00:14, Nicholas Yue  wrote:
>> >
>> > Thank you Mike.
>> >
>> > Follow up question:
>> >
>> > Given a
>> >
>> > ```
>> > Qt3DRender::QSceneLoader *sceneLoader;
>> > ```
>> >
>> > How do we get at this QGeometryRenderer object to be able to call the
>> impliciteMinPoint (), impliciteMaxPoint () properties ?
>> >
>> > Cheers
>> >
>> > On Tue, 2 Aug 2022 at 05:56, Mike Krus  wrote:
>> > Hi
>> >
>> > if you are using Qt6, then yes.
>> >
>> > For a specific object, QGeometryRenderer derives from QBoundingVolume
>> which has impliciteMinPoint and impliciteMaxPoint properties.
>> >
>> > If you’re interested in the bounding volume of a portion of the scene
>> graph, all a QBoundingVolume component at the root and the
>> > same properties will be updated.
>> >
>> > In Qt5, the QGeometry node associated with each render has similar
>> min/max properties (note that they only valid if the mesh uses all the
>> geometry).
>> >
>> > Hope this helps,
>> >
>> > Mike
>> >
>> >
>> > > On 1 Aug 2022, at 16:05, Nicholas Yue  wrote:
>> > >
>> > > Hi,
>> > >
>> > >   I am diving into the geometry scene via QSceneLoader.
>> > >
>> > >   Using the following code as a starting point, I wish to place the
>> camera such that it automatically accommodates scenes of different sizes.
>> > >
>> > >   One way I am thinking of doing is to base on the scene geometry
>> bounding box.
>> > >
>> > >   Is there a method or API which I can call to query the entire scene
>> geometry bounding box ? Or do I have to walk the entire scene to build that
>> up by querying the bounding box for every geometry in the scene ?
>> > >
>> > >   Any sample code I can view to get me going ?
>> > >
>> > > ```
>> > >
>> /
>> > > **
>> > > ** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
>> > > ** Contact: https://www.qt.io/licensing/
>> > > **
>> > > ** This file is part of the Qt3D module of the Qt Toolkit.
>> > > **
>> > > ** $QT_BEGIN_LICENSE:BSD$
>> > > ** Commercial License Usage
>> > > ** Licensees holding valid commercial Qt licenses may use this file in
>> > > ** accordance with the commercial license agreement provided with the
>> > > ** Software or, alternatively, in accordance with the terms contained
>> in
>> > > ** a written agreement between you and The Qt Company. For licensing
>> terms
>> > > ** and conditions see 

Re: [Interest] Qt3D : QSceneLoader - determining scene level geometry bounding box

2022-08-03 Thread Nicholas Yue
I have the following code

```
void SceneWalker::walkEntity(Qt3DCore::QEntity *e, int depth)
{
Qt3DCore::QNodeVector nodes = e->childNodes();
for (int i = 0; i < nodes.count(); ++i) {
Qt3DCore::QNode *node = nodes[i];
Qt3DCore::QEntity *entity = qobject_cast(node);
if (entity) {
QString indent;
indent.fill(' ', depth * 2);
qDebug().noquote() << indent << "Entity:" << entity <<
"Components:" << entity->components();

{
// Question about BoundingVolume
qDebug() << "BoundingVolume: " << entity->objectName();
const QList
myQGeometryRenderer =
entity->componentsOfType();
if (!myQGeometryRenderer.isEmpty())
{
Qt3DRender::QGeometryRenderer *gr = myQGeometryRenderer[0];
QVector3D minPoint = gr->implicitMinPoint();
QVector3D maxPoint = gr->implicitMaxPoint();
qDebug() << "minPoint: " << minPoint;
qDebug() << "maxPoint: " << maxPoint;
}
}
walkEntity(entity, depth + 1);
}
}
}
```

But I got the (0,0,0) for both the min/max point

```
Status changed: Qt3DRender::QSceneLoader::Loading
Status changed: Qt3DRender::QSceneLoader::Ready
 Entity: Qt3DCore::QEntity(0x7f65dc004660, name = untitled.obj) Components:
QList(Qt3DCore::QTransform(0x7f65dc04c590))
   Entity: Qt3DCore::QEntity(0x7f65dc019220, name = Suzanne) Components:
QList(Qt3DExtras::QPhongMaterial(0x7f65dc01bf30, name = DefaultMaterial),
Qt3DRender::QGeometryRenderer(0x7f65dc00c4d0),
Qt3DCore::QTransform(0x7f65dc045800))
BoundingVolume:  "Suzanne"
minPoint:  QVector3D(0, 0, 0)
maxPoint:  QVector3D(0, 0, 0)
BoundingVolume:  "untitled.obj"
```

I am using Qt 6.2.2 on Ubuntu

Cheers

On Wed, 3 Aug 2022 at 01:25, Mike Krus  wrote:

> Hi
>
> once the scene is loaded (ie, the status is Ready, keeping in mind loading
> is asynchronous), you can use
> QSceneLoader::entity() to get a loaded entity by name, and then
> QEntity::componentsOfType() to get the component.
> Loaded entities are children of the entity that the QSceneLoader component
> was assigned to, and components and
> entities are all QObjects so you can use the normal tree traversal
> techniques that work with any QObject to find
> objects by type or name.
>
>
> Mike
>
> > On 3 Aug 2022, at 00:14, Nicholas Yue  wrote:
> >
> > Thank you Mike.
> >
> > Follow up question:
> >
> > Given a
> >
> > ```
> > Qt3DRender::QSceneLoader *sceneLoader;
> > ```
> >
> > How do we get at this QGeometryRenderer object to be able to call the
> impliciteMinPoint (), impliciteMaxPoint () properties ?
> >
> > Cheers
> >
> > On Tue, 2 Aug 2022 at 05:56, Mike Krus  wrote:
> > Hi
> >
> > if you are using Qt6, then yes.
> >
> > For a specific object, QGeometryRenderer derives from QBoundingVolume
> which has impliciteMinPoint and impliciteMaxPoint properties.
> >
> > If you’re interested in the bounding volume of a portion of the scene
> graph, all a QBoundingVolume component at the root and the
> > same properties will be updated.
> >
> > In Qt5, the QGeometry node associated with each render has similar
> min/max properties (note that they only valid if the mesh uses all the
> geometry).
> >
> > Hope this helps,
> >
> > Mike
> >
> >
> > > On 1 Aug 2022, at 16:05, Nicholas Yue  wrote:
> > >
> > > Hi,
> > >
> > >   I am diving into the geometry scene via QSceneLoader.
> > >
> > >   Using the following code as a starting point, I wish to place the
> camera such that it automatically accommodates scenes of different sizes.
> > >
> > >   One way I am thinking of doing is to base on the scene geometry
> bounding box.
> > >
> > >   Is there a method or API which I can call to query the entire scene
> geometry bounding box ? Or do I have to walk the entire scene to build that
> up by querying the bounding box for every geometry in the scene ?
> > >
> > >   Any sample code I can view to get me going ?
> > >
> > > ```
> > >
> /
> > > **
> > > ** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
> > > ** Contact: https://www.qt.io/licensing/
> > > **
> > > ** This file is part of the Qt3D module of the Qt Toolkit.
> > > **
> > > ** $QT_BEGIN_LICENSE:BSD$
> > > ** Commercial License Usage
> > > ** Licensees holding valid commercial Qt licenses may use this file in
> > > ** accordance with the commercial license agreement provided with the
> > > ** Software or, alternatively, in accordance with the terms contained
> in
> > > ** a written agreement between you and The Qt Company. For licensing
> terms
> > > ** and conditions see https://www.qt.io/terms-conditions. For further
> > > ** information use the contact form at https://www.qt.io/contact-us.
> > > **
> > > ** BSD License Usage
> > > ** Alternatively, you may use this file under the terms of the BSD
> license
> > > ** as follows:
> > > **
> > > ** "Redistribution 

Re: [Interest] Qt3D : QSceneLoader - determining scene level geometry bounding box

2022-08-03 Thread Mike Krus via Interest
Hi

once the scene is loaded (ie, the status is Ready, keeping in mind loading is 
asynchronous), you can use
QSceneLoader::entity() to get a loaded entity by name, and then 
QEntity::componentsOfType() to get the component.
Loaded entities are children of the entity that the QSceneLoader component was 
assigned to, and components and
entities are all QObjects so you can use the normal tree traversal techniques 
that work with any QObject to find
objects by type or name.


Mike

> On 3 Aug 2022, at 00:14, Nicholas Yue  wrote:
>
> Thank you Mike.
>
> Follow up question:
>
> Given a
>
> ```
> Qt3DRender::QSceneLoader *sceneLoader;
> ```
>
> How do we get at this QGeometryRenderer object to be able to call the 
> impliciteMinPoint (), impliciteMaxPoint () properties ?
>
> Cheers
>
> On Tue, 2 Aug 2022 at 05:56, Mike Krus  wrote:
> Hi
>
> if you are using Qt6, then yes.
>
> For a specific object, QGeometryRenderer derives from QBoundingVolume which 
> has impliciteMinPoint and impliciteMaxPoint properties.
>
> If you’re interested in the bounding volume of a portion of the scene graph, 
> all a QBoundingVolume component at the root and the
> same properties will be updated.
>
> In Qt5, the QGeometry node associated with each render has similar min/max 
> properties (note that they only valid if the mesh uses all the geometry).
>
> Hope this helps,
>
> Mike
>
>
> > On 1 Aug 2022, at 16:05, Nicholas Yue  wrote:
> >
> > Hi,
> >
> >   I am diving into the geometry scene via QSceneLoader.
> >
> >   Using the following code as a starting point, I wish to place the camera 
> > such that it automatically accommodates scenes of different sizes.
> >
> >   One way I am thinking of doing is to base on the scene geometry bounding 
> > box.
> >
> >   Is there a method or API which I can call to query the entire scene 
> > geometry bounding box ? Or do I have to walk the entire scene to build that 
> > up by querying the bounding box for every geometry in the scene ?
> >
> >   Any sample code I can view to get me going ?
> >
> > ```
> > /
> > **
> > ** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
> > ** Contact: https://www.qt.io/licensing/
> > **
> > ** This file is part of the Qt3D module of the Qt Toolkit.
> > **
> > ** $QT_BEGIN_LICENSE:BSD$
> > ** Commercial License Usage
> > ** Licensees holding valid commercial Qt licenses may use this file in
> > ** accordance with the commercial license agreement provided with the
> > ** Software or, alternatively, in accordance with the terms contained in
> > ** a written agreement between you and The Qt Company. For licensing terms
> > ** and conditions see https://www.qt.io/terms-conditions. For further
> > ** information use the contact form at https://www.qt.io/contact-us.
> > **
> > ** BSD License Usage
> > ** Alternatively, you may use this file under the terms of the BSD license
> > ** as follows:
> > **
> > ** "Redistribution and use in source and binary forms, with or without
> > ** modification, are permitted provided that the following conditions are
> > ** met:
> > **   * Redistributions of source code must retain the above copyright
> > ** notice, this list of conditions and the following disclaimer.
> > **   * Redistributions in binary form must reproduce the above copyright
> > ** notice, this list of conditions and the following disclaimer in
> > ** the documentation and/or other materials provided with the
> > ** distribution.
> > **   * Neither the name of The Qt Company Ltd nor the names of its
> > ** contributors may be used to endorse or promote products derived
> > ** from this software without specific prior written permission.
> > **
> > **
> > ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> > ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> > ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
> > ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
> > ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> > ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> > ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> > ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> > ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> > ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> > ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
> > **
> > ** $QT_END_LICENSE$
> > **
> > /
> >
> > #include 
> > #include 
> >
> > #include 
> > #include 
> > #include 
> > #include 
> > #include 
> > #include 
> > #include 
> > #include 
> > // #include 
> > #include "MyCameraController.h"
> > #include "TrackballCameraController.h"
> >
> > class SceneWalker : public 

Re: [Interest] Qt3D : QSceneLoader - determining scene level geometry bounding box

2022-08-02 Thread Nicholas Yue
Thank you Mike.

Follow up question:

Given a

```
Qt3DRender::QSceneLoader *sceneLoader;
```

How do we get at this QGeometryRenderer object to be able to call the
impliciteMinPoint (), impliciteMaxPoint () properties ?

Cheers

On Tue, 2 Aug 2022 at 05:56, Mike Krus  wrote:

> Hi
>
> if you are using Qt6, then yes.
>
> For a specific object, QGeometryRenderer derives from QBoundingVolume
> which has impliciteMinPoint and impliciteMaxPoint properties.
>
> If you’re interested in the bounding volume of a portion of the scene
> graph, all a QBoundingVolume component at the root and the
> same properties will be updated.
>
> In Qt5, the QGeometry node associated with each render has similar min/max
> properties (note that they only valid if the mesh uses all the geometry).
>
> Hope this helps,
>
> Mike
>
>
> > On 1 Aug 2022, at 16:05, Nicholas Yue  wrote:
> >
> > Hi,
> >
> >   I am diving into the geometry scene via QSceneLoader.
> >
> >   Using the following code as a starting point, I wish to place the
> camera such that it automatically accommodates scenes of different sizes.
> >
> >   One way I am thinking of doing is to base on the scene geometry
> bounding box.
> >
> >   Is there a method or API which I can call to query the entire scene
> geometry bounding box ? Or do I have to walk the entire scene to build that
> up by querying the bounding box for every geometry in the scene ?
> >
> >   Any sample code I can view to get me going ?
> >
> > ```
> >
> /
> > **
> > ** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
> > ** Contact: https://www.qt.io/licensing/
> > **
> > ** This file is part of the Qt3D module of the Qt Toolkit.
> > **
> > ** $QT_BEGIN_LICENSE:BSD$
> > ** Commercial License Usage
> > ** Licensees holding valid commercial Qt licenses may use this file in
> > ** accordance with the commercial license agreement provided with the
> > ** Software or, alternatively, in accordance with the terms contained in
> > ** a written agreement between you and The Qt Company. For licensing
> terms
> > ** and conditions see https://www.qt.io/terms-conditions. For further
> > ** information use the contact form at https://www.qt.io/contact-us.
> > **
> > ** BSD License Usage
> > ** Alternatively, you may use this file under the terms of the BSD
> license
> > ** as follows:
> > **
> > ** "Redistribution and use in source and binary forms, with or without
> > ** modification, are permitted provided that the following conditions are
> > ** met:
> > **   * Redistributions of source code must retain the above copyright
> > ** notice, this list of conditions and the following disclaimer.
> > **   * Redistributions in binary form must reproduce the above copyright
> > ** notice, this list of conditions and the following disclaimer in
> > ** the documentation and/or other materials provided with the
> > ** distribution.
> > **   * Neither the name of The Qt Company Ltd nor the names of its
> > ** contributors may be used to endorse or promote products derived
> > ** from this software without specific prior written permission.
> > **
> > **
> > ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> > ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> > ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
> > ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
> > ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> > ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> > ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> > ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> > ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> > ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> > ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
> > **
> > ** $QT_END_LICENSE$
> > **
> >
> /
> >
> > #include 
> > #include 
> >
> > #include 
> > #include 
> > #include 
> > #include 
> > #include 
> > #include 
> > #include 
> > #include 
> > // #include 
> > #include "MyCameraController.h"
> > #include "TrackballCameraController.h"
> >
> > class SceneWalker : public QObject
> > {
> > public:
> > SceneWalker(Qt3DRender::QSceneLoader *loader) : m_loader(loader) { }
> >
> > void onStatusChanged();
> >
> > private:
> > void walkEntity(Qt3DCore::QEntity *e, int depth = 0);
> >
> > Qt3DRender::QSceneLoader *m_loader;
> > };
> >
> > void SceneWalker::onStatusChanged()
> > {
> > qDebug() << "Status changed:" << m_loader->status();
> > if (m_loader->status() != Qt3DRender::QSceneLoader::Ready)
> > return;
> >
> > // The QSceneLoader instance is a component of an entity. The loaded
> scene
> >

Re: [Interest] Qt3D : QSceneLoader - determining scene level geometry bounding box

2022-08-02 Thread Mike Krus via Interest
Hi

if you are using Qt6, then yes.

For a specific object, QGeometryRenderer derives from QBoundingVolume which has 
impliciteMinPoint and impliciteMaxPoint properties.

If you’re interested in the bounding volume of a portion of the scene graph, 
all a QBoundingVolume component at the root and the
same properties will be updated.

In Qt5, the QGeometry node associated with each render has similar min/max 
properties (note that they only valid if the mesh uses all the geometry).

Hope this helps,

Mike


> On 1 Aug 2022, at 16:05, Nicholas Yue  wrote:
>
> Hi,
>
>   I am diving into the geometry scene via QSceneLoader.
>
>   Using the following code as a starting point, I wish to place the camera 
> such that it automatically accommodates scenes of different sizes.
>
>   One way I am thinking of doing is to base on the scene geometry bounding 
> box.
>
>   Is there a method or API which I can call to query the entire scene 
> geometry bounding box ? Or do I have to walk the entire scene to build that 
> up by querying the bounding box for every geometry in the scene ?
>
>   Any sample code I can view to get me going ?
>
> ```
> /
> **
> ** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
> ** Contact: https://www.qt.io/licensing/
> **
> ** This file is part of the Qt3D module of the Qt Toolkit.
> **
> ** $QT_BEGIN_LICENSE:BSD$
> ** Commercial License Usage
> ** Licensees holding valid commercial Qt licenses may use this file in
> ** accordance with the commercial license agreement provided with the
> ** Software or, alternatively, in accordance with the terms contained in
> ** a written agreement between you and The Qt Company. For licensing terms
> ** and conditions see https://www.qt.io/terms-conditions. For further
> ** information use the contact form at https://www.qt.io/contact-us.
> **
> ** BSD License Usage
> ** Alternatively, you may use this file under the terms of the BSD license
> ** as follows:
> **
> ** "Redistribution and use in source and binary forms, with or without
> ** modification, are permitted provided that the following conditions are
> ** met:
> **   * Redistributions of source code must retain the above copyright
> ** notice, this list of conditions and the following disclaimer.
> **   * Redistributions in binary form must reproduce the above copyright
> ** notice, this list of conditions and the following disclaimer in
> ** the documentation and/or other materials provided with the
> ** distribution.
> **   * Neither the name of The Qt Company Ltd nor the names of its
> ** contributors may be used to endorse or promote products derived
> ** from this software without specific prior written permission.
> **
> **
> ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
> ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
> ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
> **
> ** $QT_END_LICENSE$
> **
> /
>
> #include 
> #include 
>
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> // #include 
> #include "MyCameraController.h"
> #include "TrackballCameraController.h"
>
> class SceneWalker : public QObject
> {
> public:
> SceneWalker(Qt3DRender::QSceneLoader *loader) : m_loader(loader) { }
>
> void onStatusChanged();
>
> private:
> void walkEntity(Qt3DCore::QEntity *e, int depth = 0);
>
> Qt3DRender::QSceneLoader *m_loader;
> };
>
> void SceneWalker::onStatusChanged()
> {
> qDebug() << "Status changed:" << m_loader->status();
> if (m_loader->status() != Qt3DRender::QSceneLoader::Ready)
> return;
>
> // The QSceneLoader instance is a component of an entity. The loaded scene
> // tree is added under this entity.
> QVector entities = m_loader->entities();
>
> // Technically there could be multiple entities referencing the scene 
> loader
> // but sharing is discouraged, and in our case there will be one anyhow.
> if (entities.isEmpty())
> return;
> Qt3DCore::QEntity *root = entities[0];
> // Print the tree.
> walkEntity(root);
>
> // To access a given node (like a named mesh in the scene), use 
> QObject::findChild().
> // The scene 

[Interest] Qt3D : QSceneLoader - determining scene level geometry bounding box

2022-08-01 Thread Nicholas Yue
Hi,

  I am diving into the geometry scene via QSceneLoader.

  Using the following code as a starting point, I wish to place the camera
such that it automatically accommodates scenes of different sizes.

  One way I am thinking of doing is to base on the scene geometry bounding
box.

  Is there a method or API which I can call to query the entire scene
geometry bounding box ? Or do I have to walk the entire scene to build that
up by querying the bounding box for every geometry in the scene ?

  Any sample code I can view to get me going ?

```
/
**
** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt3D module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
**   * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
**   * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
**   * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
/

#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
// #include 
#include "MyCameraController.h"
#include "TrackballCameraController.h"

class SceneWalker : public QObject
{
public:
SceneWalker(Qt3DRender::QSceneLoader *loader) : m_loader(loader) { }

void onStatusChanged();

private:
void walkEntity(Qt3DCore::QEntity *e, int depth = 0);

Qt3DRender::QSceneLoader *m_loader;
};

void SceneWalker::onStatusChanged()
{
qDebug() << "Status changed:" << m_loader->status();
if (m_loader->status() != Qt3DRender::QSceneLoader::Ready)
return;

// The QSceneLoader instance is a component of an entity. The loaded
scene
// tree is added under this entity.
QVector entities = m_loader->entities();

// Technically there could be multiple entities referencing the scene
loader
// but sharing is discouraged, and in our case there will be one anyhow.
if (entities.isEmpty())
return;
Qt3DCore::QEntity *root = entities[0];
// Print the tree.
walkEntity(root);

// To access a given node (like a named mesh in the scene), use
QObject::findChild().
// The scene structure and names always depend on the asset.
Qt3DCore::QEntity *e = root->findChild(QStringLiteral("PlanePropeller_mesh")); // toyplane.obj
if (e)
qDebug() << "Found propeller node" << e << "with components" <<
e->components();
}

void SceneWalker::walkEntity(Qt3DCore::QEntity *e, int depth)
{
Qt3DCore::QNodeVector nodes = e->childNodes();
for (int i = 0; i < nodes.count(); ++i) {
Qt3DCore::QNode *node = nodes[i];
Qt3DCore::QEntity *entity = qobject_cast(node);
if (entity) {
QString indent;
indent.fill(' ', depth * 2);
qDebug().noquote() << indent << "Entity:" << entity <<
"Components:" << entity->components();
walkEntity(entity, depth + 1);
}
}
}

int main(int ac,