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 / 3D Maths Equation

Author
Message
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 9th Sep 2004 03:29
A question for those more mathematically inclined than myself:

I am displaying a CSM map in my program, in the style of an RTS game. Looks sort of like Syndicate. The player can scroll the view around, looking down on the map birds-eye style. I have a mouse pointer that the player uses to select objects and issue commands to them.

Now, I need an equation to convert the position of the mouse on the screen into 3D coordinates, taking into account the floating camera location and different floor-heights around the map. To express this another way, if the mouse pointer were to simply 'become' a 3D object and 'fall' straight downward in 3D space toward the floor, I need a formula to obtain the coordinates of the spot the pointer impacts the floor.

I will need all three coordinates.

If it makes it easier to understand, I will be calling this formula when the mouse is clicked, and comparing the coordinates returned by the formula with the coordinates of all active objects to determine which one was clicked on. This would be a simple matter if the camera never moved, but taking into account that the camera could be anywhere (camera X and Z coordinates change as the player scrolls the view around RTS style, Z coordinate changes as the player zooms the view in and out) makes this a far more complex mathematical situation.

I know this whole concept is a difficult one to understand in writing, so the simplest way I can put it is if I had a top down RTS game with a camera that scrolls around the map like all RTS's, I need to determine the coordinates on the map the player has clicked, to compare those coordinates with the coordinates of the tanks on the map to determine which tank the player has selected.

Is anybody able to tackle this formula?
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 9th Sep 2004 04:51
Yes, there is RTS location code in my Vector Guide. Go and read that. The website http was given in the latest TGC newsletter.

Philip

What do you mean, bears aren't supposed to wear hats and a tie? P3.2ghz / 1 gig / GeForce FX 5900 128meg / WinXP home
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 9th Sep 2004 05:16 Edited at: 9th Sep 2004 05:16
tisk, tisk, Bear - thats twice


Agent, this is the link that lazy bear referred to:
http://www.kentaree-studios.com/tutorials/vectors/


DBP_NETLIB_v1.4.3 DarkTOPIA site coming soon!
Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 9th Sep 2004 05:17
lol

Bears are naturally lazy. He can't help it.

EZrotate!
Tokamak Physics Wrapper!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Sep 2004 10:10
for other ideas on how to do other parts in the rts, skim through my rts barebone demo in the code snippets board.

"eureka" - Archimedes
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 9th Sep 2004 10:18
Yes, Phaelax's tutorial is excellent.

Incidentally, I actually deliberately don't quote the http of the Guide. This is because I know Cattle does it for me. LOL

Philip

What do you mean, bears aren't supposed to wear hats and a tie? P3.2ghz / 1 gig / GeForce FX 5900 128meg / WinXP home
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 9th Sep 2004 11:09





DBP_NETLIB_v1.4.3 DarkTOPIA site coming soon!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Sep 2004 16:54
its not really a tutorial. its more like a big chunk of uncommented code. I should write a detailed tutorial though, and perhaps actually finish the game.

"eureka" - Archimedes
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 11th Sep 2004 08:33
Uncommented code scares me. You have to spend 50% of your time working out what on earth is going on.

Philip

What do you mean, bears aren't supposed to wear hats and a tie? P3.2ghz / 1 gig / GeForce FX 5900 128meg / WinXP home

Login to post a reply

Server time is: 2024-11-27 09:51:57
Your offset time is: 2024-11-27 09:51:57