Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Make QLightEntity follow QCamera

Make QLightEntity follow QCamera

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt3dqcameraqlightentity
6 Posts 3 Posters 2.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chris2401
    wrote on 16 Feb 2017, 18:13 last edited by A Former User
    #1

    Hi,

    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).

    K 1 Reply Last reply 18 Feb 2017, 14:52
    0
    • L Offline
      L Offline
      lluull
      wrote on 18 Feb 2017, 13:23 last edited by
      #2

      Hi, i will really interest in this topic me too :)

      Also, do is possible to customise the QCameraOrbitControllerClass (assign button, invert rotation axis etc...)

      thx.

      1 Reply Last reply
      0
      • C chris2401
        16 Feb 2017, 18:13

        Hi,

        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).

        K Offline
        K Offline
        kshegunov
        Moderators
        wrote on 18 Feb 2017, 14:52 last edited by
        #3

        Well QCamera is 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.

        Read and abide by the Qt Code of Conduct

        C 1 Reply Last reply 20 Feb 2017, 10:57
        1
        • L Offline
          L Offline
          lluull
          wrote on 18 Feb 2017, 16:20 last edited by
          #4

          Hi,
          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.

          thx.

          ps: i keep loving to know how customize the QCameraOrbitControllerClass (buttons and axis)

          thx again.

          K 1 Reply Last reply 19 Feb 2017, 13:53
          0
          • L lluull
            18 Feb 2017, 16:20

            Hi,
            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.

            thx.

            ps: i keep loving to know how customize the QCameraOrbitControllerClass (buttons and axis)

            thx again.

            K Offline
            K Offline
            kshegunov
            Moderators
            wrote on 19 Feb 2017, 13:53 last edited by
            #5

            @lluull said in Make QLightEntity follow QCamera:

            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 ...

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            0
            • K kshegunov
              18 Feb 2017, 14:52

              Well QCamera is 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.

              C Offline
              C Offline
              chris2401
              wrote on 20 Feb 2017, 10:57 last edited by
              #6

              @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 :)

              1 Reply Last reply
              0

              1/6

              16 Feb 2017, 18:13

              • Login

              • Login or register to search.
              1 out of 6
              • First post
                1/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved