• Advertisement

Archived

This topic is now archived and is closed to further replies.

how to translate, rotate & scale shape with mouse???

This topic is 5152 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All, I loaded a shape from a .x file and now I want to interact it with mouse. The situation is like that I want to translate, scale & rotate it with the mouse. Like suppose I choose the option from menu to scale or translate or rotate, now when I click on the shape & drag the mouse it should work accordingly. At the moment, I''m only concerating on Translation and here comes the original problem. I determine the click on the shape (by picking), now when I drag the mouse, how to calculate the new cordinates??? If I get the new cordinates & subtract them from previous (for horizontal movement), the difference turns out to be very small & that is not making any particular difference. After that, I just added a factor of 2.0f (hardcoded), now it works a little well, but if I move mouse very fast, then the shape get left behind then the mouse I would like to ask how to do that. Any help, refrence or pointer in this matter will be higly appricated & thanx in advace. Regards, Ejaz.

Share this post


Link to post
Share on other sites
Advertisement
Going solely on a thought experiment.. I''d say that when you click on a shape and drag the object, it should move with the mouse, right? If you get the difference in mouse motion, and project the final point onto a plane perpendicular to the screen, then you should get the distance to translate by how much that point has moved on the final plane. Now, this plane would have to be at the depth in screen space where the mouse picked the first polygon.

Share this post


Link to post
Share on other sites
Thanx for the suggestion dear, I''ll try it...hope it will work...

Regards,

Ejaz.

Share this post


Link to post
Share on other sites
I think, that u have a problem to transform mouse coordinates into GL coordinates, read this article:
http://nehe.gamedev.net/data/articles/article.asp?article=13
I had the same problem,with the mouse and my 3D cube.I wonted to move it thrugh the scene,but device coordinate(windows coord)doesn''t correspond to the GL coordinte and I solved it with article 13

Share this post


Link to post
Share on other sites

  • Advertisement