Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (482)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (550)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Mouse Control On A 3D Map  (Read 860 times)
0 Members and 1 Guest are viewing this topic.
Offline Olix

Junior Newbie





« Posted 2008-08-08 17:10:03 »

Hi there,

Since my last topic in this forum on openGL, my game project progressed quite far. It didn't have any... well, game mechanics, as such, but you could place and destroy buildings, and character placed on the map could path find around the place fairly efficently. The problem is, as I didn't really have any kind of plan when I started the project, the code is pretty hacked up. I decided to start again from scratch, this time with a much better design and a better idea of what I wanted the game to do. I also decided to make it 3d.

The game is a city builder game, so the "3d" aspect is going to be purely visual, the mechanics are going to be more or less the same. I might have a pop at doing interesting fractal generated terrain, but there is essentially only going to be one Z level for the purpose of game mechanics. I think I'll be able to handle the graphical side of it with a bit of work, but there is one problem to which I have no solution: How to deal with mouse input.

More precisely, how to work out where the cursor is relative to the map. It was pretty easy with the isometric system I had before - I just added the mouse position to a couple of variables that represented the view area's relation to the map. For a 3d map though, where the user is going to be able to rotate, zoom in and out (etc) the view, I don't really have any idea how to get the mouse's position, and thus I won't be able to have the player manipulate stuff with the mouse.

Could anyone give a hint on this subject?
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #1 - Posted 2008-08-08 22:14:10 »

Basically what you do is plot out a ray trace that is dependent upon the current camera viewpoint. Say, for example, the camera is pointing directly downwards. That means, when the user clicks the mouse, you're going to see if the mouse at that X and Y position intercepts anything in a line along the Z axis that goes directly downwards. In other words, you're plotting collision along a line using the axis that you don't have, and the line's equation is determined by the camera position. Make sense?

See my work:
OTC Software
Offline bobjob

JGO Knight


Medals: 10
Projects: 4


David Aaron Muhar


« Reply #2 - Posted 2008-08-09 01:12:11 »

are you using openGL? or something else? can you show a demo/screenshot of your app, so i can get a visual of what you are doing.

it shouldnt be that hard to do.

My Projects
Games, Webcam chat, Video screencast, PDF tools.

Javagaming.org with chat room
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (14 views)
2014-08-22 19:31:30

atombrot (28 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (61 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!