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 / Problem with mousemoving.

Author
Message
Regnuar
15
Years of Service
User Offline
Joined: 25th Dec 2008
Location:
Posted: 1st Feb 2009 22:37
Hi!

how i can move object in Z axis when moving mouse in Y axis?
here goes the code if someone can add the code snippet with some document.




regards, Jukka Korhonen
Regnuar
15
Years of Service
User Offline
Joined: 25th Dec 2008
Location:
Posted: 1st Feb 2009 23:03
sorry for double posting...

i tried something like this, but it doesn't work correctly.

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 2nd Feb 2009 12:21 Edited at: 2nd Feb 2009 12:23
Hi Regnuar,

I think you want to make the cube move like in an RTS. In that case, I'm afraid you're confusing 2D coördinates with 3D coördinates. To convert 2D screen coördinates to 3D world coördinates, you should use the pick screen command. It calculates a world position at a given screen coördinate at a distance of x units.

Assuming that the whole world is of height 0:


This little code positions object 1 under the mouse.
If you add different heights, you will have to find the intersection of the ray between (cam x, cam y, cam z) and (get pick vector x() + cam x, get pick vector y() + cam y, get pick vector z() + cam z) with the world object/matrix. If you are using matrices this might become a bit of a pain. If you use objects, you can use intersect object() or Sparky's collision DLL to find the distance.

Login to post a reply

Server time is: 2024-11-24 14:47:30
Your offset time is: 2024-11-24 14:47:30