Selection of multiple units

Hi Everyone!

At first I'm completely new to jME and im just playing around with it atm. Maybe I'll write a simple strategy game in the future using jME,so i got one question. How would i select multiple units? You know just like in all the strategy games,you click on a point,keep the mouse button pressend and than drag a box. All units in the box get selected. Do i have to use findpick with every point in that box? or is there a better solution?


Structure your scene graph so that there is not alot to search for using pick.



the rest - you make up - store as array arrayset hashmap …

So i have to create a ray out of every single point in the box?

There's no other way?

mc__ said:

So i have to create a ray out of every single point in the box?
There's no other way?


or u can just cast four rays to define the vertices of the box. and get the units inside the area  :D

how would i do that?

on a second thougt, theres a better way to do that~



if u dont have a lot of units visible in one frame, just let each unit hold a screen coordinate varaible. and every time the unit moves, translate its wolrd coord into screen coord.



and mouse listener will help u find the four vertices of the box in screen coordinate system.



so now what u have is a bunch of points in ur screen coordinate system and all the vertices of the selection box also in screen coordinate system. then u can figure out how to calculate if the unit is in the box~ :smiley:

Sorry, I don't have the time to look it up right now, but you might want to search again - this has been discussed elsewhere on this forum. MrCoder suggested a solution involving converting 3d world to 2d screen coordinates fo your four selection rectangle corners and the units on screen. I think he even provided code exapmples!

hevee said:

Sorry, I don't have the time to look it up right now, but you might want to search again - this has been discussed elsewhere on this forum. MrCoder suggested a solution involving converting 3d world to 2d screen coordinates fo your four selection rectangle corners and the units on screen. I think he even provided code exapmples!


ha looks like im starting to think like mr.coder

guess thats a good news for me  :D