[Interest] [Qt3D] QGeometryRenderer can't be shared

Xavier Bigand flamaros.xavier at gmail.com
Fri Sep 30 15:34:38 CEST 2016


I took a look to the addComponent implementation and it seems normal that
my code doesn't work because a component is intended to be attached once.
So I don't understand the meaning of the shareable flag.

I'll try to share the geometry instead.

2016-09-30 15:20 GMT+02:00 Xavier Bigand <flamaros.xavier at gmail.com>:

> I am trying to share my QGeometryRenderer between many Entities, but the
> addComponent doesn't have any effect.
>
> When I load our models from files, I save the root entity node in a map,
> and after I clone the node tree when a previously model is in the map.
> I have no issue with the material component that is in the cloned tree,
> but the geometryRenderer isn't printed by my trace method (material and
> geometryRenderer components are at the same level on sub-entities).
>
> I set the shareable flag to true on the geometryRenderer.
>
> PS : for the material component I don't assign the same ptr to the cloned
> model, because I don't want to share the material all attributs. My
> material class have is own clone method to copy only the shareable
> attributs (maps, specular,...).
>
>
> Here is my cloning method :
>
>     void Model::cloneModel(Qt3DCore::QEntity* source, Qt3DCore::QEntity& destination)
>
>     {
>
>         QNodeVector sourceEntities = source->childNodes();
>
>
>         foreach (QNode* node, sourceEntities)
>
>         {
>
>             QEntity*    sourceSubEntity = dynamic_cast<QEntity*>(node);
>
>             QEntity*    subEntity = new QEntity(&destination);
>
>
>             H3D_ASSERT(sourceSubEntity != nullptr);
>
>
>             subEntity->setObjectName(sourceSubEntity->objectName());
>
>
>             QComponentVector    sourceComponents = sourceSubEntity->components();
>
>
>             foreach (QComponent* component, sourceComponents)
>
>             {
>
>                 QGeometryRenderer*  geometryRenderer = dynamic_cast<QGeometryRenderer*>(component);
>
>                 LightingMaterial*   material = dynamic_cast<LightingMaterial*>(component);
>
>
>                 if (geometryRenderer)
>
>                 {
>
>                     subEntity->addComponent(geometryRenderer);
>
>                     LOG_INFO("geometryRenderer %s %s", qPrintable(component->metaObject()->className()), qPrintable(component->objectName()));
>
>                 }
>
>                 else if (material)
>
>                 {
>
>                     LightingMaterial*   clonedMaterial = new LightingMaterial();
>
>
>                     clonedMaterial->clone(*material);
>
>                     subEntity->addComponent(clonedMaterial);
>
>                 }
>
>                 else if (dynamic_cast<QPhongMaterial*>(component))  // TODO to remove
>
>                 {
>
>                 }
>
>                 else if (dynamic_cast<QPhongAlphaMaterial*>(component))  // TODO to remove
>
>                 {
>
>                 }
>
>                 else
>
>                 {
>
>                     H3D_ASSERT_MSG(false, "Unsupported component type %s", qPrintable(component->metaObject()->className()));
>
>                 }
>
>             }
>
>         }
>
>     }
>
>
> I have this issue with Qt 5.7 and 5.8 build from the git branch.
>
> --
> Xavier
>



-- 
Xavier
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160930/2df76d51/attachment.html>


More information about the Interest mailing list