OpenGL: scale then translate? and how?

前端 未结 3 1572
野的像风
野的像风 2020-12-02 14:42

I\'ve got some 2D geometry. I want to take some bounding rect around my geometry, and then render a smaller version of it somewhere else on the plane. Here\'s more or less t

3条回答
  •  感情败类
    2020-12-02 15:14

    Scale, just like Rotate, operates from the origin. so if you scale by half an object that spans the segment [10:20] (on axis X, e.g.), you get [5:10]. The object therefore was scaled, and moved closer to the origin. Exactly what you observed.

    This is why you apply Scale first in general (because objects tend to be defined around 0).

    So if you want to scale an object around point Center, you can translate the object from Center to the origin, scale there, and translate back.

    Side note, if you translate first, and then scale, then your scale is applied to the previous translation, which is why you probably had issues with this method.

提交回复
热议问题