View Full Version : Move Stuff in 3D!
10-26-2003, 07:46 AM
I need a way to move objects by dragin it in a direction arrow (X, Y ,Z). No mather where I look at the object ( from any angle ) when I drag the arrow in a specific direction I want the object to move in the same direction, but! the arrow must move at the same speed as the mouse. If the tip of the mouse cursor is in the middle of the arrow at the begining of the translation, then it should be there at the and of the move as well. For those of you who have used "advanced" 3d modeling software, you most likely know what I want to achive. I have trying to confront this problem using gluUnprojet. But the closest I have come is a vector reprecenting the amount of movement in the world, but the value is much to small ... 6.879453 - 6.87620 (for example). When I click at points 10 units away from each other. Help please!!!
This is not an advanced topic and is borderline Opengl. Do a search (on this board and on Google) for raycasting. That'll get you started. Then you want to look into methods for tracking your mouse (eg. WM_MOUSEMOVE msgs).
Then it's just some trig/vector math for the direction/distance to move.
10-26-2003, 04:52 PM
I think you're on the right track. The way I have seen this done, is to grab the z value under the cursor from the GL Z-Buffer and get your unprojected point using that. This will kill your frame rate for realtime games, but if you are doing some editing (moving objects around), it should go unnoticed.
Alternatively, you can always trace a ray through your scene to find out eye ray hit if you have that capability. This is probably the best way to go, but its not always available.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.