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 / 3D mouse collision

Author
Message
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 21st May 2009 21:51 Edited at: 21st May 2009 21:51
I am really breaking my head with this... I just can't think and imagine it anymore!

The Problem

I want the user to click the waypoint and then drag it.

The waypoint is a 3D object. So you have to calculate where it is when the mouse moves. The big problem is, that the waypoint will change it's distance from the camera when being moved over an uneven landscape.

The Numbers

I am doing my calculations with proportions. So lets say the distance the waypoint is away from the camera is y#. The mousex and y positions will be mx# and my#. Since I have a 800*600 resolution, they will be floats. (You will see later on.) px# and pz# will be the updated waypoint positions (return value).

I figured out, that if y#=400,

px#=(mx#*(640.0/800.0))-(640.0/2.0)
py#=0-((my#*(640.0/800.0))-(480.0/2.0))


Because the window is 800*600, you have to multiply the mouse position by (640/800) because if y#=400 in a 640*480 window, they would be correct.

Now what if y#=93.4837? How would I figure that out? I have really tried and I just didn't get it...

TheComet

Peachy, and the Chaos of the Gems

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 21st May 2009 23:01
Never mind, solved it...



TheComet

Peachy, and the Chaos of the Gems

Login to post a reply

Server time is: 2026-07-05 12:18:22
Your offset time is: 2026-07-05 12:18:22