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.

DarkBASIC Discussion / Problem with interaction

Author
Message
Deathstryke
17
Years of Service
User Offline
Joined: 26th Feb 2008
Location:
Posted: 29th Oct 2008 00:59
This may seem kind of babyish but how do you get a 3d object to follow the mouse but still keep the same Y coordinate?

There are 10 kinds of people. Those who understand binary and those who don't.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 29th Oct 2008 01:12
That's not babyish at all, probably the most difficult question anyone's asked for months!
I don't know how you'd do it
You're talking about some tricky trigonometry if you want to do it properly but you could probably cheat if the camera was static.

A small program that works is better than a large one that doesn't.

DBC Challenge Rank: Rookie
Deathstryke
17
Years of Service
User Offline
Joined: 26th Feb 2008
Location:
Posted: 29th Oct 2008 01:19
I though there would be a lot of people who could do that.

There are 10 kinds of people. Those who understand binary and those who don't.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 29th Oct 2008 01:32
DB isn't very helpful with converting 2D to 3D, there are commands to convert 3D to 2D but not the other way around annoyingly.

A small program that works is better than a large one that doesn't.

DBC Challenge Rank: Rookie
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 29th Oct 2008 04:42
Perhaps I misread the question, but can't you move the object based off of the MouseMoveX() and MouseMoveY() values?

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 29th Oct 2008 19:52
@Obese and BN2
True in both cases. If one looks at it like I think Obese is, then you have to compute a 3d vector directly into the screen at the mouse position. And if the camera rotates on any axes but y, the math can get very tricky... If one looks at the question like BN2, then you can move the 3d object relative to the camera based on MouseMoveX() and MouseMoveY. If you position the mouse at the 3d objects position after the move (assuming the pivot point of the object is it's center) then it appears as if the object is moving with the mouse. Again, as long as the camera angle is only y rotated there shouldn't be any problems. Here's a quick example of that:



If you don't click any mouse buttons, the object moves up and down. If you click the right mouse button, the object will move along z. I used trig for the z part just to show it, but it's just the trig representation of the newzvalue command so you could use either.

Enjoy your day.

Login to post a reply

Server time is: 2025-06-07 08:35:17
Your offset time is: 2025-06-07 08:35:17