[Interest] [QT3d] Does anyone have any idea how to position a light in C++?

Sean Harmer sh at theharmers.co.uk
Sat Jun 11 17:07:11 CEST 2016


Hi,


On 11/06/2016 14:00, Pierre Chicoine wrote:
> Oleg
>
> Wow. Thank you. It works.
>
> It was the setparent that made it work. That is, instead of placing it 
> into the Instantiation of the the entity class.
>
> I'm using 5.7rc on Linux Kubuntu
>
> Pierre
>
> //parentistherootentity
> Qt3DCore::QEntity*pLightEntity=newQt3DCore::QEntity();//hangoffofroot
> Qt3DRender::QPointLight*pQPointLight=newQt3DRender::QPointLight();
> Qt3DCore::QTransform*pLightQTransform=newQt3DCore::QTransform();
> pLightQTransform->setTranslation(QVector3D(0,0,300));
> LightEntity->addComponent(pLightQTransform);
> pLightEntity->addComponent(pQPointLight);
> pLightEntity->setParent(this); <<<< setting the parent last and this 
> way made it work. Thanks again

That should be fixed on the 5.7.0 branch. If you find it is still an 
issue, please file a JIRA.

Cheers,

Sean

>
> On Sat, Jun 11, 2016 at 5:47 AM, Oleg Evseev <ev.mipt at gmail.com 
> <mailto:ev.mipt at gmail.com>> wrote:
>
>     I've just tested following in my app instead of directional light
>     sun entity and this works:
>
>
>     QEntity*en=newQEntity();
>
>     QPointLight*l=newQPointLight();
>
>     l->setColor("red");
>
>     Qt3DCore::QTransform*t=newQt3DCore::QTransform();
>
>     t->setTranslation(QVector3D(15.0f,0.0f,0.0f));
>
>     en->addComponent(t);
>
>     en->addComponent(l);
>
>     en->setParent(this);
>
>     I've tried to add this(my scene main entity) directly in entity
>     creator and it is still works (but you could try set parent latter
>     - there was bug in qt 3d relevant to this lately (before 5.7.0)).
>
>     I use almost last commit 5.7.0 from git.
>
>     --
>     Regards, Oleg.
>
>
>     2016-06-11 15:09 GMT+03:00 Pierre Chicoine
>     <pierrechicoine606 at gmail.com <mailto:pierrechicoine606 at gmail.com>>:
>
>         Oleg
>
>         Thanks for the reply.
>
>         Here's the code I hung off of the root entity. Didn't work.
>         Maybe I'm translating from QML improperly. ??
>
>         //parentistherootentity
>
>         Qt3DCore::QEntity*pLightEntity=newQt3DCore::QEntity(parent);//hangoffofroot
>
>         Qt3DRender::QPointLight*pQPointLight=newQt3DRender::QPointLight();
>
>         pLightEntity->addComponent(pQPointLight);
>
>         //pQPointLight->setColor(QColor::fromRgbF(1.0,1.0,1.0,1.0));
>
>         //pQPointLight->setIntensity(4);
>
>         //pQPointLight->setEnabled(true);
>
>         Qt3DCore::QTransform*pLightQTransform=newQt3DCore::QTransform();
>
>         pLightEntity->addComponent(pLightQTransform);
>
>         pLightQTransform->setTranslation(QVector3D(0,0,300));
>
>
>         On Sat, Jun 11, 2016 at 4:11 AM, Oleg Evseev
>         <ev.mipt at gmail.com <mailto:ev.mipt at gmail.com>> wrote:
>
>             Create new entity with transform and light components, add
>             this entity to the root entity to light the whole scene.
>             One light with one transform.
>
>             Run the "lights" example and you'll understand the principle.
>
>             Or you can "pack" several of such entities (with lights
>             and theirs own transforms) into one entity (and add it to
>             the root entity) with one transform to
>             [strike]rule[/strike] transform them all simultaneously.
>             It's up to you.
>
>             I've not tested all of this, but this is how it works
>             looking on examples.
>
>             Regards, Oleg.
>
>
>             2016-06-11 14:01 GMT+03:00 Pierre Chicoine
>             <pierrechicoine606 at gmail.com
>             <mailto:pierrechicoine606 at gmail.com>>:
>
>                 With a point light, did you mean add a point light and
>                 transform to every entity or to the root entity to
>                 light the whole scene with one transform?
>
>                 Thanks for the reply Oleg.
>
>                 On Jun 11, 2016 3:52 AM, "Oleg Evseev"
>                 <ev.mipt at gmail.com <mailto:ev.mipt at gmail.com>> wrote:
>
>                     Do you mean point light?
>                     Example "lights" is not what are you looking for?
>
>                     This is in qml but obviously it is not so hard to
>                     write it in c++ just add components QTransform and
>                     QPointLight to the QEntity and it will work (I think).
>
>                     Regards, Oleg.
>
>                     2016-06-11 13:43 GMT+03:00 Pierre Chicoine
>                     <pierrechicoine606 at gmail.com
>                     <mailto:pierrechicoine606 at gmail.com>>:
>
>                         Am I missing something simple. I can't seem to
>                         position a light in QT3D
>                         Any ideas anyone?
>
>
>                         _______________________________________________
>                         Interest mailing list
>                         Interest at qt-project.org
>                         <mailto:Interest at qt-project.org>
>                         http://lists.qt-project.org/mailman/listinfo/interest
>
>
>
>
>
>
>
> _______________________________________________
> 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/20160611/d4f431f8/attachment.html>


More information about the Interest mailing list