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. Qt3D 2.0 change object pivot
Qt 6.11 is out! See what's new in the release blog

Qt3D 2.0 change object pivot

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.6k 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.
  • C Offline
    C Offline
    cRooked
    wrote on last edited by
    #1

    Hey there community,

    currently I am trying to make a scene where I import an car object into my scene and where i can oben doors etc.

    So i stripped my model into a few models.. like doors, wheels and so on

    Now that i have imported these models into my scene I want to animate them. And here starts the problem.

    For example: I have set in Blender the pivot/origin of a door so that i can rotate it and get an opening effect. But the pivot point is not exported into the .obj file, but reset to (0, 0, 0).
    When I export my model as .fbx file, the origin is exported fine.

    Is there any possiblity to set the pivot point of a mesh in qml/qt3d or is there a module for importing fbx files? As far as I know Qt3D 2.0 only supports .obj files.
    In Qt3D 1.0 there was support for more formats than just .obj.

    I am using Qt 5.5

    Kind regards,

    cRooked

    1 Reply Last reply
    1
    • C Offline
      C Offline
      cRooked
      wrote on last edited by
      #2

      nobody? i could really need some help

      1 Reply Last reply
      0
      • CarlitoC Offline
        CarlitoC Offline
        Carlito
        wrote on last edited by
        #3

        Hi cRooked

        usually applying a rotation matrix rotates somewhat around the origin / or an axis that goes through the origin.

        So a workaround might be to translate the part to the origin, rotate it, and translate it back. (you still need to know the coordinates of the pivot though):

        Qt3D::QTranslateTransform *TranslateToOrigin = new Qt3D::QTranslateTransform();
        TranslateToOrigin->setTranslation(QVector3D(-x_pos, -y_pos, -z_pos));
        
        Qt3D::QRotateTransform *doorRotation = new Qt3D::QRotateTransform();
        doorRotation->setAxis( door_hinge_axis ); // axis as a QVector3D..
        doorRotation->setAngleDeg(openingAngle);
        
        Qt3D::QTranslateTransform *TranslateBack = new Qt3D::QTranslateTransform();
        TranslateBack->setTranslation(QVector3D(x_pos, y_pos, z_pos));
        
        // ... some code
        
        Qt3D::QTransform *doorGeoTransforms = new Qt3D::QTransform();
        
        doorSwingOpenTransforms-->addTransform(TranslateToOrigin);
        doorSwingOpenTransforms-->addTransform(doorRotation);
        doorSwingOpenTransforms-->addTransform(TranslateBack);
        
        door_Entity->addComponent(doorGeoTransforms); 
        

        i'm sure this workaround could be optimized a bit, using just negative translate as translateBack or the like ...

        hope this helps.
        Cheers!

        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