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. Qt 3D Billboarding
Forum Updated to NodeBB v4.3 + New Features

Qt 3D Billboarding

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 418 Views 1 Watching
  • 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.
  • G Offline
    G Offline
    guy incognito
    wrote on last edited by guy incognito
    #1

    I'm trying to implement billboarding for a QPlaneMesh in Qt 5.8 C++. So far, the plane more or less faces towards the camera when I move around, but often it's upside down. I tried different rotations with QQuaternions with no success.

    // camera
    Qt3DRender::QCamera* camera = view->camera();
    camera ->lens()->setPerspectiveProjection(90.0f, 16.0f/9.0f, 0.1f, 1000.0f);
    camera ->setPosition(QVector3D(2.0f, 2.0f, 2.0f));
    camera ->setUpVector(QVector3D(0, 1, 0));
    camera ->setViewCenter(QVector3D(0, 0, 0));
    
    // controls
    Qt3DExtras::QFirstPersonCameraController* camController = new Qt3DExtras::QFirstPersonCameraController(rootEntity);
    camController->setCamera(camera);
    
    // signal/slots
    QObject::connect(camera, &Qt3DRender::QCamera::positionChanged, plane, &Plane::rotate);
    
    // Plane::rotate
    void Plane::rotate(QVector3D target)
    {
        planeTransform->setRotation(QQuaternion::rotationTo(planeTransform->translation(), target));
    }
    

    So the plane gets rotated towars the position of the camera.
    Anyone got an idea how to improve things?

    1 Reply Last reply
    0

    • Login

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