Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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 1306 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: 12
Projects: 4

David A M

« 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.
Pages: [1]
  ignore  |  Print  

EgonOlsen (74 views)
2018-06-10 19:43:48

EgonOlsen (55 views)
2018-06-10 19:43:44

EgonOlsen (75 views)
2018-06-10 19:43:20

DesertCoockie (255 views)
2018-05-13 18:23:11

nelsongames (154 views)
2018-04-24 18:15:36

nelsongames (154 views)
2018-04-24 18:14:32

ivj94 (895 views)
2018-03-24 14:47:39

ivj94 (156 views)
2018-03-24 14:46:31

ivj94 (808 views)
2018-03-24 14:43:53

Solater (172 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!