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 / Move 3D object left and right with mouse

Author
Message
Illusion Games
20
Years of Service
User Offline
Joined: 16th Feb 2004
Location:
Posted: 16th Feb 2004 18:41
I want to move an object left and right using the mouse. Does anyone know how to do this? I wrote some code using mousemovex() but it doesn't work like what is in my head. Do I need to translate the 2D mouse coordinates to 3D to make it work?
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 16th Feb 2004 19:33
Do you want to move the object relative to the screen or to world coordinates?

World coordinates are easy, mouse x to object position x and mouse y to object z for depth or object y for height. You just need a few tweaks for scale, offsets from the center of the screen, and to invert the mouse height.

Relative to the camera can be faked without haveing to dig into the math. Save the object's current orientation, point the object at the camera location, get the mouse movement, turn the object 90 degrees left/right, move the object by the mouse distance, and then rotate the object back to it's original facing.
--
TAZ

Illusion Games
20
Years of Service
User Offline
Joined: 16th Feb 2004
Location:
Posted: 16th Feb 2004 20:37
Thanks for the tips! I am using world coordinates so I think I will go ahead and us the tweaks for scale, offsets to center, etc...

I am pretty sure that will work. I thought it was more straightforward than that and that as a new user of the language that I was overlooking something even simpler.
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 16th Feb 2004 20:48 Edited at: 16th Feb 2004 20:50
Straightforward is relative. You know the mouse X and Y values and their ranges. You know how to position objects. You can use commands like SCREEN WIDTH()/2 to find the mouse X offset and SCREEN HEIGHT()/2 to find the Y offset. Subtract mouse y from the screen height to 'invert' it. All programming is just putting the little bits together to produce the desired effects.

This is dirt simple compared to lower level languages where you have to check for events and interrupts. The key to success is reading the help files often and getting a feel for all the things that the language is capable of. Before I wrote a line of DBP code, I read the manual from cover to cover.
--
TAZ

Login to post a reply

Server time is: 2024-09-21 21:14:41
Your offset time is: 2024-09-21 21:14:41