Advertisement

3d mouse co-ordinates - Dungeon Keeper style :-)

Started by July 04, 2001 05:49 AM
17 comments, last by WoolyUK 23 years, 7 months ago
Hi all, What is the best (or any?) way to work out the 3d co-ordinates of the mouse pointer please? In my game you can zoom in/out, roate 360 etc in a overheard view. I need to be able to click on a certain part of the world and know the x,y,z position of it. Basically Im making a dungeon keeper style game so I need to be able to detect mouse clicks and then, for example, destroy the selected part of a wall. Here is a screenshot so you can better understand what I mean: http://www.buffalo-g.com/wooly/dungeongl.jpg How could I click a part of the wall or floor and determine its position in the world please? I have looked at the picking part of Nehe''s tutorial, but as the camera doesnt move in his, it doesn''t really help me :-( Any help/advice/tips/links etc would be *GREATLY* appreciated! Thanks alot! Adam
How about making an invisible line that shoots from the 2d position of the mouse and detects the first wall?
Advertisement
Thanks for replying

but what happens when I change/rotate/zoom the view? It wont work then will it? and what happens if I dont want the "first" brick?

Thanks!
Adam
how about moving the mouse cursor along the x, z axis'?

instead of using the mouse curor itself, use a textured polygon or something, and use the x position of the polygon as the mouse's x position, and the z position of the polygon as the mouse's y position. and the polygon's height as the height of your walls, then just check on a mouse click to see whether the mouse cursor polygon is within one of the walls

???

just a thought. prolly not the best tho.

Scott


MODIFICATIONS: Wow... I just suck at typing...


Email
Website

"If you try and don't succeed, destroy all evidence that you tried."

Edited by - wojtos on July 4, 2001 1:01:08 PM

Edited by - wojtos on July 4, 2001 1:08:26 PM
But would that work in isometric view?

Wooly: U need to fin a way to calculate the direction to shoot the beam, then it should work fine when rotating, zooming and moving
well, (please tell me if i''m wrong), I''m assuming (prolly shouldn''t) that Mr. WoolyUK is using a camera to look around... Maybe using gluLookAt() and with rotating and translating, that doesn''t make the current coordinates change, he''s simply looking somewhere else.

Scott

Email
Website

"If you try and don''t succeed, destroy all evidence that you tried."
Advertisement
But that doesn''t matter if u use a shooting beam from the mouse
oh.

Email
Website

"If you try and don''t succeed, destroy all evidence that you tried."
picking in OGL picks whatever is drawn under the cursor. Why would that make a problem? Even if the camera rotates you still pick whatever is under your cursor(isn''t that your target???)
Let's say @ is the camera, ^ is the cursor and # is a block and / and \ are the edges of the field of view and -- is a ray going from the camera through the cursor to the map and . is nothingness. I'm sure my little diagram will get screwed up by the forum stuff but anyways:

.../...--.....
../..--....###
./.-^......###
@--........##.
.\.........###
..\...........
...\..........

Just use line-polygon collision with a line going from the camera through the cursor and find out what it hits.

-David-

Edited by - david20321 on July 4, 2001 8:28:19 PM

This topic is closed to new replies.

Advertisement