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 Professional Discussion / Creating box at mouse position.

Author
Message
medsouz
16
Years of Service
User Offline
Joined: 10th May 2010
Location:
Posted: 12th May 2010 02:34
I made this with my small knowledge of DarkBASIC. It is part of a loop, I want it to when the mouse is clicked place a box in the exact position of the mouse but it places the object far away from the mouse for some reason...

Can anyone help?


Sixty Squares
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 12th May 2010 04:22
The problem is that the mouse coordinates are 2D, while the coordinates for POSITION OBJECT are 3D. To convert 2D to 3D, have a look at the PICK SCREEN and GET PICK VECTOR X/Y/Z commands. I'm not an expert on those, especially with varying camera angles, but searching for "3D Mouse" or "Pick Screen" should bring up a lot of results
Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 12th May 2010 05:03
I think I recently answered a similar question. Here's the example I posted for the other person:



Copy+Paste that into a new window and run it to see if it's the kind of thing that you're looking for. WASD moves/turns the camera and the scroll wheel changes the distance.

There's quite a bit of complex math, and I haven't looked into simple alternatives, so there's probably something better for your needs out there. The person I gave this to was interested in the math aspect of it.

That thread is here.

medsouz
16
Years of Service
User Offline
Joined: 10th May 2010
Location:
Posted: 12th May 2010 22:19
Could someone give me a quick lesson on how to achieve this in a short and simple way? I'm a beginner and know very little about Basic.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 31st May 2010 13:32 Edited at: 31st May 2010 13:41
There are tutorials about vectors out there - bing or google dbpro tutorials - you'll find some great and easy to understand stuff out there.

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 31st May 2010 18:06
Quote: "Could someone give me a quick lesson on how to achieve this in a short and simple way? I'm a beginner and know very little about Basic."


Sixty Squares already told you the quickest way though ^^.

first you use
pick screen mousex(), mousey(), Distance#

To get the world coordinates afterwards you use
WorldX# = camera position x() + get pick vector x()
WorldY# = camera position y() + get pick vector y()
WorldZ# = camera position z() + get pick vector z()

And that's that.

Cheers!
Sven B

Login to post a reply

Server time is: 2026-07-26 01:26:11
Your offset time is: 2026-07-26 01:26:11