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

- 1,096
- 2
- 10
- 21
-
I'm Sorry but i think i didnt explain good my problem. what i meant is that i want to scale my STL mesh along a certain point, other than along the face's normals. I'll try to find a good graphical representation of what i mean and reply ASAP. – Saffist3r Oct 16 '19 at 11:54
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

- 1,096
- 2
- 10
- 21
-
I want to do the exact same operation of this question but with Qt Actually [link](https://stackoverflow.com/questions/22954255/how-to-strechscale-mesh-on-the-world-axis) – Saffist3r Oct 16 '19 at 15:18
-
can you show the code you already tried? The code example I gave you does exactly the same as your link. Did you try it? – Eddy Alleman Oct 16 '19 at 15:22
-
It's a Spingbox and when its value changed it does the scaling. ` on_ValueChanged: { var vec = Qt.vector3d(_value.x / 100.0, _value.y / 100.0, _value.z / 100.0); mainview.selectedEntity.transform.scale3D = vec; ` – Saffist3r Oct 16 '19 at 15:37
-
1You are using a spinbox? and when the value of the spinbox changes you want the stl object to scale with the same amount for x, y and z? That is what you code does. If you want to scale them differently, you will probably need more than 1 spinbox. – Eddy Alleman Oct 16 '19 at 15:48
-
Actually there is 3 Spinboxes according to X,Y,Z when their value changes my STL object scales according to the values, the problem is that i want the scale to be done arround the origin of my coordinates System not the origin of the STL. – Saffist3r Oct 16 '19 at 15:51
-
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 – Eddy Alleman Oct 16 '19 at 15:58
-
Hello again Eddy, i did what you told me i translated my object to the origin scaled it and then retranslated back to the same point, i have the same result, the scaling is always around the STL faces normals. – Saffist3r Oct 17 '19 at 12:45
-
can you show all the code where your transforms are used? Even better would be to make a small compilable example with only the relevant parts. – Eddy Alleman Oct 17 '19 at 13:38