Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

Transformation Problems

Started by s3mt3x Feb 2, 2006 at 5:58 AM 0 replies 250+ views
Original Post
s3mt3x
s3mt3x
Hi Guys, Just wondering how I would achive the following. I'm fairly new to opengl so please forgive me if it's simple. To cut a long story short i'm constructing a simple modelling program - I want to be able to move along the local camera axis a particular distance according to user input from the mouse. This is all well and good and I have acheived this so far - however, the scene's translation is not based on the current view matrix - it is based on a fixed amount and therefore when I zoom in close to objects, the translation is much larger than when I am zoomed out - so my question would be - how can I convert a particular distance in pixels (i.e. a mouse drag) into the appropriate translation based on the current view transform - the end result being that no matter where I am in the scene, the geometry under the mouse is translated the same distance as the mouse. I hope this is clear enough, if not let me know and any help would be more than appreciated. Kind Regards, Chris
haegarr
haegarr
First, you have to define an input plane. That plane could be always in front of and parallel to the camera, so it may be the view plane. So you can move and object/the camera by the amount the mouse is moved when projected onto that input plane. This is necessary if you start dealing with perspective projection, since the mouse is moved in a 2D plane cutting a view pyramid in that case. So get the both mouse points, project them (e.g. as a ray) onto the input plane, compute the difference vector from them, transform the vector into global space, and apply it as translation. Due to the projection onto the input plane you consider the camera's zoom and other "optics", and due to the transformation into global space you consider the camera's orientation.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.