Jump to content

  • Log In with Google      Sign In   
  • Create Account


Translation Gizmo


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 BornToCode   Members   -  Reputation: 915

Like
0Likes
Like

Posted 25 September 2012 - 01:07 AM

In my 3D editor i have an Translation gizmo that display the direction which an object is facing. If you select the x axis for example and moved the mouse in the direction of the gizmo it follows that direction. Now the problem that i am having is that if i perform an yaw of 180 degress and the x axis ends up facing the left direction. When i select it and moved the mouse left it end up mirroring instead of moving to the left. I have found that out that my mouse coordinate which i am using as a scale factor to determines whether i moved left or right never changed. So when the x axis values end up been (-1,0,0) for example and when i move my mouse left. it takes the new mouse position and subtract from the old one, i end up with -1 for the mouse as well so when i multiply the mouse delta by the left axis it ends up flipping the axis back to positive. So what i am looking for is a way i can convert my mouse to be in the same space as my camera/object. So to sum it up, i am looking for a way for my gizmos to translate in teh direction that the arrow is pointing too no matter what the orientation of the object or the camera. If anyone can help, i would greatly appreciate it.

Thanks

Sponsor:

#2 slicer4ever   Crossbones+   -  Reputation: 3398

Like
0Likes
Like

Posted 25 September 2012 - 05:31 AM

In my 3D editor i have an Translation gizmo that display the direction which an object is facing. If you select the x axis for example and moved the mouse in the direction of the gizmo it follows that direction. Now the problem that i am having is that if i perform an yaw of 180 degress and the x axis ends up facing the left direction. When i select it and moved the mouse left it end up mirroring instead of moving to the left. I have found that out that my mouse coordinate which i am using as a scale factor to determines whether i moved left or right never changed. So when the x axis values end up been (-1,0,0) for example and when i move my mouse left. it takes the new mouse position and subtract from the old one, i end up with -1 for the mouse as well so when i multiply the mouse delta by the left axis it ends up flipping the axis back to positive. So what i am looking for is a way i can convert my mouse to be in the same space as my camera/object. So to sum it up, i am looking for a way for my gizmos to translate in teh direction that the arrow is pointing too no matter what the orientation of the object or the camera. If anyone can help, i would greatly appreciate it.

Thanks


not certain if i understand you correctly, so i might be way off, but:

if the objects exist on a flat plane, then you could use glUnProject to map your mouse screen coordinates into object space(i'd probably shoot a ray from the front->back of the depth buffer, and get the point on the flat plane that the ray intersects with.) from this, you can simply point the object at the mouse using basic triginometry.

of course this is assuming that the object's rotation is working in 2D(even if it's a 3D application), if you can rotate by all axis's, then i'd probably map the mouse to whichever major axis you are attempting to rotate by.

hope this helps=-)
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#3 BornToCode   Members   -  Reputation: 915

Like
0Likes
Like

Posted 25 September 2012 - 10:01 AM

Let me see if i can make it clearer. In tools such as Unity 3D or 3D max for example when you translate your object they always follow the translation gizmo direction. So for example the x axis of the gizmos points to the right and you select that axis and move your mouse to the right the object will move right. Now let's say we rotate that object by 180 degress around the Y Axis, now all the x axis no longer faces the right it will face the left. Now to solve that problem that is easy all i do is take whatever the current right axis and add it to my position.But the problem is i need to multiply that right axis by some form of delta so it knows to move either left or right. The delta that i am using is based of the mouse coordinate changes every frame. So if your mouse is position at for example 100,100 and you move right and the mouse becomes 101,100, then the delta for x will be =1 and y=0 . The same would happen if you move in the opposite direction and get x=-1 and y=0.I used this delta factor to mupliply my right axis with so it know wheneter to move left or right. Now the problem is this when the right axis end up been at -1,0,0 and then i move my mouse left i will get a delta of x=-1. So when i multiply this delta by the right axis it ends up flipping the x back to positive and then when i add this right axis to my position it moves the object right instead of left. What i need is a way to convert that mouse coordinate not only to the object frame of reference also the camera frame of reference as well. Because the same issue will occur as the camera changes orientation, the axis will change as well.

#4 BornToCode   Members   -  Reputation: 915

Like
0Likes
Like

Posted 25 September 2012 - 05:57 PM

Forget it. I fix it. Just in case someone in the future runs into the same issue. What i did to fix it. is convert my mouse (x,y,0) to 3d camera space, then convert my object to camera space as well. Then use the delta from the mouse to camera space




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS