Search code examples
c++qtqmlqt3d

How to Scale a QMesh around the origin with QML


I'm using QML to display an STL file. I want to make modifications on the file and display it in the scene ( Translation, Rotation, and Scaling) i made the first two but for the scaling i want to scale around the origin (x=0,y=0,z=0). How can i proceed ?

The original Mesh Original Size What i want to do : What i want


Solution

  • You want to scale around the origin (x=0,y=0,z=0) with a scale factor which is different for y?

    you can accomplish this as followed:

    Transform {
         ...
        scale3D:  Qt.vector3d(1, 0.5, 1)
    }
    

    EDIT : if the origin of your STL file is not the same as your coordinate system: in that case translate your object to the origin of your coordinate system, do the scaling and then translate it back as I suggested in my first answer. To get the amount of translation needed you can query the boundingvolume, minExtent and maxExtent