Alexey Vanzhula Posted August 26, 2015 Share Posted August 26, 2015 I have origin and direction (perpendicular to camera) from mouse pointer. I want to transform the direction somehow to intersect it with global X axis. http://i.imgur.com/tr7s0I4.png Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted August 26, 2015 Author Share Posted August 26, 2015 (edited) It works well for free moving in screen space with using of dot product. But I dont understand how to transform the mouse pointer direction to X or any other axis... Another simple example of what i want to gethttps://youtu.be/UlRcRHgyAwY Edited August 26, 2015 by Alexey Vanzhula Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted August 27, 2015 Share Posted August 27, 2015 Maybe I misunderstand, but it sounds like your just overthinking it. What I would do is snap the object to the corresponding axis. i.e. project from camera origin by camera direction at the XY plane, then set Y to zero. Thus it sticks flat to the Y axis, and is projected at the X axis. Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted August 27, 2015 Author Share Posted August 27, 2015 (edited) Thanx for the right direction So, my solution is: 1. Move in XY plane P = p - d * (dot(p - p1, n) / dot(d, n)) Where: p - pointer position d - pointer direction p1 - position of plane normal n - normal to plane 2. Then set Y to 0 if need Edited August 27, 2015 by Alexey Vanzhula Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted August 27, 2015 Share Posted August 27, 2015 Yeah, that looks about right. Might be p+d*scalar though And to nitpick a little more, I should have said intersect with XY plane, not project. intuitively projection sounds right but its not the same. Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted August 27, 2015 Author Share Posted August 27, 2015 (edited) And to nitpick a little more, I should have said intersect with XY plane, not project. intuitively projection sounds right but its not the same Yes, but it works as I need Edited August 27, 2015 by Alexey Vanzhula Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted August 29, 2015 Author Share Posted August 29, 2015 p+d*scalar yes, it is Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.