Moving 3d objects with the mouse & picking
Hi guys. I really hope this topic hasnt been covered loads of times, I havnt had any luck searching anyway. I've got picking working using the mouse etc. But I'm really stuck in actually getting the selected object to move with the mouse directly under the mouse cursor, i.e. being able to pick up a toy off of the floor, then using the mouse, place the cursor over a toy chest and drop the toy in it. Or better yet, selecting a model in maya in the perspective window, and moving it around directly under the mouse cursor. I'm pretty sure that it's probably quite simple. I can write a Doom 3 model viewer with dot3 diffuse,specular, and attenuation, but ask me how the mathematics works, and I'm screwed :0) Anyway, I REALLY would appreciate any help, as it's very important to my project, and without it I cant really proceed. Thanks guys, Dan.
Actually I also want to know more about mouse picking..
I hope someone in this forum could help us...
I hope someone in this forum could help us...
Track the mouse coordinates, redraw the objects at the current mouse position every frame.
For speed modifications you can just track the mouse coordinates, and only move the object every 2-3 px move or however slow you want it.
For speed modifications you can just track the mouse coordinates, and only move the object every 2-3 px move or however slow you want it.
Hey. Thanks for the input, but it's not as simple as that. I'm working in 3D! I wish it was as simple as just tracking the mouse coordinates. Projection matrices, inverse transformation matrices, not to mention the extra dimension all add up to one massive headache :0)
I've been having some thoughts about this. The mouse is a 2d device right, so chances are I, and most other people interested in such a method would only be working with two axise (plural of axis anyone?). I would have thought anyway.
So for example, if you selected an object in 3D, and wanted to move it under the mouse cursor on the XY plane, that would first involve picking the object, and returning the XYZ triplet of the ray intersection with the object (no brainer I guess).
So whilst moving along the XY plane, the Z is not going to change. So we can store the intersection as the "Cursor" 3D point initially. So I think, that when we move the mouse cursor, we need to calculate the new XY position of the 3D Mouse point. What we have to process this information is:
1: The start position of the ray
2: The Z distance of the object intersection
3: The directional Vector which the ray is facing
So, if any mathematicians are out there (lots I hope - You can tell I'm not), is there a way of Solving the X & Y position, given a directional Vector and a Z Distance?
I'm probably WAY off here, but any input would be most appreciated!
Cheers guys.
I've been having some thoughts about this. The mouse is a 2d device right, so chances are I, and most other people interested in such a method would only be working with two axise (plural of axis anyone?). I would have thought anyway.
So for example, if you selected an object in 3D, and wanted to move it under the mouse cursor on the XY plane, that would first involve picking the object, and returning the XYZ triplet of the ray intersection with the object (no brainer I guess).
So whilst moving along the XY plane, the Z is not going to change. So we can store the intersection as the "Cursor" 3D point initially. So I think, that when we move the mouse cursor, we need to calculate the new XY position of the 3D Mouse point. What we have to process this information is:
1: The start position of the ray
2: The Z distance of the object intersection
3: The directional Vector which the ray is facing
So, if any mathematicians are out there (lots I hope - You can tell I'm not), is there a way of Solving the X & Y position, given a directional Vector and a Z Distance?
I'm probably WAY off here, but any input would be most appreciated!
Cheers guys.
o__o I never thought you needed any vector math persay. Why don't you just put 0 in as a filler for the z value since you're not going to be changing any Z coord?
Hmm...if you want to move around in Z, you might want to consider using the mouse wheel/middle button. Only thing I could see to make it a 3D device by itself. Other options are using the keyboard to switch it to Z-val modifications.
Well...hmm, now that I rethink this(this is an edit), you might have some problems with clipping if you do that. Something I don't have much experience with to say the least.
Hmm...if you want to move around in Z, you might want to consider using the mouse wheel/middle button. Only thing I could see to make it a 3D device by itself. Other options are using the keyboard to switch it to Z-val modifications.
Well...hmm, now that I rethink this(this is an edit), you might have some problems with clipping if you do that. Something I don't have much experience with to say the least.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement