   [.net] Drag 3d objects with mouse, I.E., convert 2d mouse coords to 3d coords
  Hiya.  I'm trying to figure out how to drag 3d objects with the mouse in the x/z plane, which basically boils down to converting 2d mouse coords to 3d coords.  I'm finding lots of confusing and conflicting articles about this, most not specific to C#, and none which actually seem to work.Can anybody point me to some resources?  I would like, in order of preference:1. C# code that I can plug directly into my app and FORGET about2. Code in another language which is fairly easy to convert to C#3. Long and complicated articles explaining the mathematical theory behind what I'm trying to do.  Thanks.   
  Are you using XNA?theTroll   ;  no, MDX 9   ;  This should help you out.Mouse Picking theTroll;  umm, not exactly.  I have picking implemented without a problem.  But I need to DRAG objects after picking them.  Picking gives me a ray with a direction that I can test against objects for intersections.  I need something that returns 3d coordinates from mouse coordinates.   ;  Umm. you can't directly.  The best you can get is a ray.  The problem is that there is no way to directly convert 2d into 3d because you are missing a dimension.  Example, you have a 3d view of some room.  There is a box in the center of the room.  You pick the box and drag it down and to the right.  So do you want to move the box down the y or closer to the camera on the z?  There is no direct way to know by just using the 2d dimensions.theTroll   ;  I got it.  Thanks for trying.  ummm....not to be a jerk...well, Ok, I'm a jerk....but if you don't know the answer to a posted question, why bother replying at all?  "you can't."  Only discourages others who may know the answer from replying. There are a thousand people who've experienced the same dilemma...one of them has an answer that they are willing to share...why waste your own time with questions, guesses, and answers that are off the mark?  Obviously you've never done what I needed to do...that's ok...I'll wait for somebody who has, or find them on another forum.  I mean, c'mon, you either know the answer or you don't!  Why take advice from somebody who doesn't know?   And of COURSE you can!  Obviously assumptions have to be made for the missing data...maybe if viewing from overhead, move along the X/Z plane, if viewing from the side, move along the X/Y plane.  "you can't" does not compute.;  I misread your original question, that is why I answered at first the way I did.Quote:Original post by danromeoI need something that returns 3d coordinates from mouse coordinates.The reason I answered the second way was because of what you asked.  You wanted to take a 2d coordinate and make a 3d one out of it.  You can't do that.  Not directly.  So how exactly do I not know what I am talking about?As for doing this, you are correct I have never done that.  Why?  BECAUSE YOU CAN'T.  Not the way you wanted to do it.Of course you can do a top down view and do it.  But that is not what you asked.  So don't blame me for YOU not asking the question you really wanted the answer to.theTroll;Quote:Original post by danromeoAnd of COURSE you can!  Obviously assumptions have to be made for the missing data...maybe if viewing from overhead, move along the X/Z plane, if viewing from the side, move along the X/Y plane.  "you can't" does not compute.Maybe you mean that you want vectors in world space for the directions of up/down and left/right relative to the camera? If you want to drag your object right, you can take the normalized Right vector, multiply it by a distance, and then add it to the position of your object.Getting those involves using your camera's up vector to get the Up vector and a cross product between the up and the camera's direction vector to get the Right vector.Asking for 3D coordinates doesn't make much sense because a coordinate is a point. You can't drag with a point, you drag in a direction.   ;  Not blaming anybody for anything, guy.I asked EXACTLY the question I needed an answer to.  <"YOU CAN'T"That's funny, because it works GREAT!  Maybe you meant "I can't"?  C'mon..."you can't" is a defeatist way of saying "I don't know" (or an arrogant way of saying "I don't know, so it must not be possible").  Again...if you don't know, why bother replying?   