In one of the rendering scenarios I have my camera focused at the tip of an arrow. I scale the arrow and the camera focus gets changed. How should I calculate the required translation value for the arrow to counter the translation happened due to scaling and keep the camera focus unchanged ? (I cannot alter the camera variables)
Assuming the red circle to be the camera focus point. The second frame is showing the desired behavior.
Asked
Active
Viewed 141 times
0

proton
- 658
- 1
- 7
- 26
2 Answers
2
If you translate your camera to the origin, scale it, then translate it back (translate by scaled amount) that should place your camera at the right spot. Scaling things when not at the origin tends to make them move away from the origin, since their position gets scaled as well as everything else.

Fonix
- 11,447
- 3
- 45
- 74
-
"(translate by scaled amount)" if i am scaling in y with 'Sy', what is the mathematical equation for the translation in y direction ? – proton Feb 27 '13 at 13:43
-
to scale in just the Y you should have a scale vector <1,y,1> then multiply it with whatever you are scaling (if its not a 3 dimensional vector you are scaling just pad the other components with 1 as well) – Fonix Feb 27 '13 at 13:58
-
Why would you want to scale the second translation? If you translate a point from (50, 50) to the origin, scaling will leave it at the origin and you need to translate it back to (50, 50). – beaker Feb 28 '13 at 17:18
-
if the tip of the arrow was at (50,50) then you scale it to say (60,60), if you translate back to (50,50) then you have lost your focus point – Fonix Mar 01 '13 at 07:07
-
That's why you're translating it to the origin, correct? You translate the point from (50, 50) to (0, 0), apply the scaling (which leaves (0, 0) at (0, 0)) and then translate back to (50, 50). Your focus point stays at (50, 50). – beaker Mar 03 '13 at 14:59
0
What do you call "camera focus"? Is that something you have created? or something inside OpenGL?
I would apply the transformation from that specific point. The center of scale, i mean. That way you would mantain the position.

Darkgaze
- 2,280
- 6
- 36
- 59
-
I mean, the translation depends on where you choose your center of scale! – Darkgaze Feb 27 '13 at 12:36
-
If you use glScale, then you wont be able to change the center of scale. You should rewrite the method by using a transformation matrix: http://en.wikipedia.org/wiki/Transformation_matrix – Darkgaze Feb 27 '13 at 12:38
-
It is something I have created. I only need to keep the arrow tip at the same position.Hope you got the idea... – proton Feb 27 '13 at 12:44
-
Then you have to apply a custom transformation using the center of the transformation in that specific point. – Darkgaze Feb 28 '13 at 16:28