NOTE: I dont know in witch forum to post this, I'm sorry if i post it in the wrong one.

I had to make a project a few months back for my school, that required me to create 3 3D objects (cube, sphere and so on) and apply some transformation on them (translation, scaling etc).

Now the in the project i select with my mouse from a menu the object and click somewhere in the workspace to create it. What i want is something like this: while i dont click a second time i can scale the object. My problem is, i don't know how to check in which direction is the mouse moving in comparison with the center of the object. If i move the mouse away then the i make the object bigger and if i move it close to the center then i make it smaller.
Is there a simple way to check this?

Thank you and sorry for my english,

Edited by maximchris

5 Years
Discussion Span
Last Post by myk45


If i understand you correctly, this is what you want:

You want to scale an object based on the mouse drag. i.e if the mouse is moved away from the object, you scale it more, and when you move closer to it, scale it less. Is that what you want?

Now, i have a few clarifications i need:

1) What Graphics API are you using?
2) The windowing toolkit(glut, SDL)?

irrespective of what you are using, here is a general idea that maybe helpful:

1) Take the position of the mouse click( in screen space ). This is your initial click. Let it be (Xo, Yo)
2) Obtain current mouse position. let it be (Xc, Yc)
3) Find (Xc - Xo) and (Yc - Yo).
4) Now, using the absolute value of this difference, you can scale the object.

For eg: If (Xc - Xo) = 100, scale by 3 times
If (Xc - Xo) = 0, scale by 1 time(retain size. So, as you drag, you scale max upto 3 times)

So, as you drag, depending on the distance, you vary the scale.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.