Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Make QLightEntity follow QCamera
chris2401 last edited by A Former User
I know how to assign a camera and a light entity that can be placed at the camera's starting position, as shown in the basic qt3d examples:
Qt3DCore::QEntity *lightEntity = new Qt3DCore::QEntity(rootEntity); Qt3DRender::QPointLight *light = new Qt3DRender::QPointLight(lightEntity); light->setColor("white"); light->setIntensity(1); lightEntity->addComponent(light); Qt3DCore::QTransform *lightTransform = new Qt3DCore::QTransform(lightEntity); lightTransform->setTranslation(cameraEntity->position()); lightEntity->addComponent(lightTransform);
What I cant find is how I can make the light position change dynamically when I hover around with the camera through the QCameraOrbitControllerClass. The reason why I want to do this is because the plane class is not lighted on both sides when I draw it (the side that is not covered by light is black).
lluull last edited by
Hi, i will really interest in this topic me too :)
Also, do is possible to customise the QCameraOrbitControllerClass (assign button, invert rotation axis etc...)
QCamerais an entity itself, so you could either attach the light to the camera, or parent both entities - the one you create for the light and the one you create for the light to the same parent entity; then moving the parent entity should propagate the transformation to the child entities.
lluull last edited by
thx for the answer,
but, i have already try this (parenting the light to the viewport camera, but this don't give the expected result.
the light move in fact but in a strange behavior, look like inverted position when we are close the target and look like mostly not moving when we are far to the target.
overall, i have a solution using Qt3DLogic::QFrameAction and connecting the triggered signal.
the light is perfectly following the camera.
ps: i keep loving to know how customize the QCameraOrbitControllerClass (buttons and axis)
look like inverted position when we are close the target and look like mostly not moving when we are far to the target.
What inverted position do you mean?
As for the second part, distance from target is a big factor if you consider the geometry.
i keep loving to know how customize the QCameraOrbitControllerClass (buttons and axis)
No clue, I played a little bit with Qt3D in its infancy, but then there was no orbit controller class at all ...
chris2401 last edited by
@kshegunov I think you are right. By just putting the lightentity into the camera:
Qt3DCore::QEntity *lightEntity = new Qt3DCore::QEntity(basicCamera);
It seems to move dynamically. Now I have to set some other things but that might have to do just with how I want my objects to show :)