Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / moving an object with a mouse

Author
Message
PAGAN_old
18
Years of Service
User Offline
Joined: 28th Jan 2006
Location: Capital of the Evil Empire
Posted: 12th Dec 2009 03:11 Edited at: 12th Dec 2009 03:12
i know this is something easy but i cant find anything on the forum that explains this, i fugured out how to recognize if a certain object is clicked or not, now i need to move that object with the mouse.

so how about it?

dont hate people who rip you off,cheat and get away with it, learn from them
PAGAN_old
18
Years of Service
User Offline
Joined: 28th Jan 2006
Location: Capital of the Evil Empire
Posted: 12th Dec 2009 17:44
to clarify, moving object with a mouse the same way most level editors have it. i am making a simple level editor, I got mo objects to rotate by pressing the right mouse and rotationg them around y axis, mouse wheel to scale them but actually moving the objects with the mouse is the tricky part i cant get the hang of.

dont hate people who rip you off,cheat and get away with it, learn from them
PAGAN_old
18
Years of Service
User Offline
Joined: 28th Jan 2006
Location: Capital of the Evil Empire
Posted: 12th Dec 2009 23:42
if it helps here is my code, i am making a level editor. I did search the forums quite a but but havent found anything like what i am trying to do, i put comments in the code so its clear what i need help with





dont hate people who rip you off,cheat and get away with it, learn from them
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 13th Dec 2009 00:17
If you have a ground object, you can pick it using the mouse coordinates and then add the pick vector coordinates to the camera coordinates to find the absolute 3D coord of the mouse position.

Something like this, IIRC:


PAGAN_old
18
Years of Service
User Offline
Joined: 28th Jan 2006
Location: Capital of the Evil Empire
Posted: 13th Dec 2009 01:27
Thanks a lot! this is exactly what i needed, really had no idea how to do this.

dont hate people who rip you off,cheat and get away with it, learn from them
PAGAN_old
18
Years of Service
User Offline
Joined: 28th Jan 2006
Location: Capital of the Evil Empire
Posted: 14th Dec 2009 04:57 Edited at: 14th Dec 2009 05:24
As i moved from moving somple boxes to my models, i ran into a problem. My mouse keeps loosing the object very easily, especially if its a complex or a small object. and sometimes it just behaves in a strange way. if i click on the object, it would jerk it away from the mouse and sometimes it just wouldnt move the object at all. it differs from the angle of the camera.

i am making small a world editor type thingy and i import terrains into this program along with other models, that could be part of the problem. but i think its the pick object command. Part of the problem may be that the terrain is getting in the way sometimes. Mybe there is a way to make thepickobject command completley ignotre the terrain so it will not loose sight of te object

is there a way to make the pick object function more stable like so the object would be completley attached to the mouse instead of just follow it.

here is the stripped down code with the function that has this.






space+mouselook is to look around, w,s to go forward backward and shift plus mousewheel(while mouse over the object) to move it up or down, pain mouswheel to scale it

now i am not sure if this is the problem because in this stripped down version, i cant notice it as much, if anyone want to take a closer look, i can upload my entire program with a few models.

dont hate people who rip you off,cheat and get away with it, learn from them

Login to post a reply

Server time is: 2024-11-24 23:37:33
Your offset time is: 2024-11-24 23:37:33