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 / converting mouse position to 3d space

Author
Message
Soy Cocktail
20
Years of Service
User Offline
Joined: 23rd Dec 2003
Location:
Posted: 15th Jun 2004 09:52
im trying to make an object appear on a matrix where i click, i got that to work but i also want the camera to move and stil work which it dosent. found some examples that work and are what im looking for, but i dont understand them.

http://darkbasicpro.thegamecreators.com/?m=forum_view&t=27536&b=6
and
http://darkbasicpro.thegamecreators.com/?m=forum_view&t=25904&b=6

it does something along the line od creating a vector3 at the position of the camera pointing where the mouse is to the matrix or something. i dont understand what vectors and what vector2 3 and 4 are and the difrence.
Bishop
21
Years of Service
User Offline
Joined: 18th Dec 2002
Location: In my favorite chair...
Posted: 15th Jun 2004 23:42
well, usually mousecoords to 3dcoords work on a fixed camera angle.....when the angle changes, the perspective changes so you have to adjust them according to how much the angle moved.....it would probably be a difficult code to get it to work with any csmera angle


Bish

"When you were born, you cried and the world rejoiced. Live so when you die, the world cries and you rejoice."
Soy Cocktail
20
Years of Service
User Offline
Joined: 23rd Dec 2003
Location:
Posted: 16th Jun 2004 04:10
the one philip posted here http://darkbasicpro.thegamecreators.com/xt/view_code.php?i=3904 works how i would like mine to but i dont understand the part with the vectors, they are somehow used too make a line from the camera to the ground and move the object to that point
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th Jun 2004 06:27
The pick vectors create a direction vector, basically showing where the camera and mouse are pointing to. Then using a bit of trig, cast a line of a calculated length to find that ending point of impact with the ground, basically.

vector2 is a vector with 2 components, usually X and Y components.
vector3 has 3 components, added Z to it. Another way to look at a vector type is like this:



now obviously you'd have to rename the data type if using this approach, as vector2 and vector3 are already taken.

"eureka" - Archimedes
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 16th Jun 2004 22:23
I also want to do this, but want to do it in DB Classic. I know how to do trig, I went through Trigonomentry and Calculus. You should be able to do it manually without built in vector commands, right?

Also, doesn't it all depend on the camera fov? If you widen the fov then you see more on screen. I will try to figure this out as soon as I finish up some other stuff...

Xander Moser of Bolt Software
Firewall: Your Computer's First Defense - Real Time Strategy game
[href][/href]
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 17th Jun 2004 09:44
correct, the fov is a variable.

Don't know who the original author was, but here's code for DBC.



"eureka" - Archimedes
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 17th Jun 2004 23:40
Search for mouse in the code snippet section and there will be several threads worth reading.
--
TAZ

History did not begin with PONG. -- Greg Costikyan

Game Beavers

Login to post a reply

Server time is: 2024-11-26 21:40:20
Your offset time is: 2024-11-26 21:40:20