How to Scale a QMesh around the origin with QML

Viewed 404

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

2 Answers

If you want to transform objects you need to use the Rotation-Scale-Transformation order (in short : RST)

If you want to transform a coordinate systems you do it the other way around : TSR.

Order really matters.

If you load the stl file and the origin is already what you want, then you can rotate the object, scale and then translate it. If the origin is not what you want, you will need to transform it to the "initial position" you desire. If you are the one generating the stl file, you can use the software that produced that stl file to put it in the right "start position".

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

Related