[Interest] Subclassing of QEntity

Igor Mironchik igor.mironchik at gmail.com
Mon Apr 10 09:57:38 CEST 2017


Hello.

Got it!!!

I had:

void

LeafPrivate::init()

{

m_mesh=newLeafMesh(q);

q->addComponent(m_mesh);

m_material=newQPhongMaterial(q);

//m_material->setAmbient(Qt::darkGreen);

m_material->setDiffuse(Qt::darkGreen);

//m_material->setSpecular(Qt::darkGreen);

q->addComponent(m_material);

m_transform=newQt3DCore::QTransform(q);

m_transform->setTranslation(m_endBranchPos);

q->addComponent(m_transform);

}

//

//Leaf

//

Leaf::Leaf(constQVector3D&startBranchPos,

constQVector3D&endBranchPos,Qt3DCore::QNode*parent)

:Qt3DCore::QEntity(parent)

,d(newLeafPrivate(startBranchPos,endBranchPos,this))

{

d->init();

}


And I changed it to:

void

LeafPrivate::init()

{

m_mesh=newLeafMesh;

q->addComponent(m_mesh);

m_material=newQPhongMaterial;

//m_material->setAmbient(Qt::darkGreen);

m_material->setDiffuse(Qt::darkGreen);

//m_material->setSpecular(Qt::darkGreen);

q->addComponent(m_material);

m_transform=newQt3DCore::QTransform;

m_transform->setTranslation(m_endBranchPos);

q->addComponent(m_transform);

}

//

//Leaf

//

Leaf::Leaf(constQVector3D&startBranchPos,

constQVector3D&endBranchPos,Qt3DCore::QNode*parent)

:Qt3DCore::QEntity(parent)

,d(newLeafPrivate(startBranchPos,endBranchPos,this))

{

d->init();

}


I.e. I removed parent when creating componets and add components to 
entity. If I add component with this parent to this enity and create 
entity dynamically then transformation doesn't applies. I don't know 
about other components, but QTransform doesn't work in such use case.

10.04.2017 10:34, Igor Mironchik пишет:
>
>
> 10.04.2017 9:55, Igor Mironchik пишет:
>> Hi,
>>
>>
>> 09.04.2017 21:32, Sean Harmer пишет:
>>> Hi,
>>>
>>> Sounds odd. Can you file a JIRA and a test case please?
>>
>> Sorry, I missed - the problem is not in it. But the problem exists 
>> yet. What it can be?
>>
>> I increase the scale of new entities but they isn't seen.
>
> I'm sure in one moment. If I create new enitites dynamically and with 
> normal scale they seen. But changing the transformation doesn't affect.
>
> I just do d->m_transform->setScale( someScale ). And I'm sure I call 
> this. But scaling doesn't change in my application on dynamically 
> created entities.
>
> Tha is why I didn't see child entities, because I strated them with 
> 0.0 scale and then in time increase it, but transformation changes 
> don't apply on my entity.
>
> I can't reproduce it in small example, but I'm trying.
>
> What can you suggest me?
>>
>>>
>>> Thanks,
>>>
>>> Sean
>>>
>>> On 09/04/2017 17:05, Igor Mironchik wrote:
>>>> Hi,
>>>>
>>>>
>>>> 09.04.2017 18:54, Igor Mironchik пишет:
>>>>> Hi,
>>>>>
>>>>>
>>>>> 09.04.2017 18:43, Igor Mironchik пишет:
>>>>>> Hi,
>>>>>>
>>>>>> What should I know when subclassing QEntity?
>>>>>>
>>>>>> I subclassed, in c_tor() gave parent node to c_tor() of QEntity. All
>>>>>> is ok. If I populate scene before first rendering - everything is
>>>>>> fine - I see all entities.
>>>>>>
>>>>>> But if I dynamically populate the scene then I see only that 
>>>>>> entities
>>>>>> that were created before setRootEntity() call.
>>>>>>
>>>>>> What strangle is that I see all entities, even that that were
>>>>>> populated dynamicaly but my subclassed entities...
>>>>>>
>>>>>> What I miss? Maybe I have to do something when subclassing QEntity?
>>>>>
>>>>> I have to say that my dynamic entites start with scaling 0.0f and 
>>>>> then
>>>>> in timer event scale grows. Scale really grows, I chcked. But I don't
>>>>> see my dynamic entities...
>>>>
>>>> This is exactly the problem. If entity starts with 0.0f scaling 
>>>> then it
>>>> won't be visible if you set scale to even 100.0f later... Start scale
>>>> should be greater than zero...
>>>>
>>>> _______________________________________________
>>>> Interest mailing list
>>>> Interest at qt-project.org
>>>> http://lists.qt-project.org/mailman/listinfo/interest
>>>
>>
>

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


More information about the Interest mailing list