Skip to main content
GameDev.net gamedev.net
🔒 Locked

Cursor problem

Started by CAPE Mar 29, 2007 at 5:51 AM 1 replies 550+ views
Original Post
CAPE
CAPE
Well, here comes a question i think have been asked a couple of time, and i have checked some old artickles and threads on the subject, but i can't really find the solution to my problem. Well, I need to place out objects on my heightmap with my cursor, and i get this problem that when I pick upp a object and starts moving around, the objects dosn't follow the cursor correct, like if I move the cursor one pixle on the screen, the object move like 10 pixles on the screen. And when i zoom out enough, the cursor can move 10 pixles, and my object just 1 pixle. I know, the way i transfer my cursor on the screen isn't the same thing as moving objects in the worldspace, but I can't figure out how to do the algorithm to get the correct translation. I want my picked object to follow my corsor on the screen, so that the object always stays under the cursor. It is easier for the user to move around objects in the tool then. So, if anyone out there have struggled with this problem before, or know how to fix this, please wright me an answer.
David Gustavsson
Developer on "Hello space"
IndieDB
TheAdmiral
TheAdmiral
How about this.

Each time the user moves the mouse, during an object-move event, you unproject the mouse's position to a ray in world space, and perform a ray-mesh intersection test to find out which piece of terrain lies under the mouse. This will be the object's new position (or at least the new x & z positions).

Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.
CAPE
CAPE
I have alredy tried this, but this works only if the user is looking on the terrain in a topview. As soon as the camera is to low, and the user is looking at the object from the side, there will be no terrain in the back to compaer with. And also, if the object is supposed to be flying, or for some other reason is airborn, it will create a unpleasing offset to the cursor and the object.
But you are right, this will solve the problem at hand, but not in a satisfying way.
David Gustavsson
Developer on "Hello space"
IndieDB

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.