Geom detection and visible sharp edge

Hello am working on a 3D tactical game and right now am on the combat section. Am trying to make the player able to see where he is going before he click by putting every square in front of im changing color as he pass over them whit is mouse.

But i have 2 problem right now : first, even if i succeed in creating translucent square for the player to walk on, the difference between them is not clear enough. I want to put black line all over my square shape to really show where they are. I just can’t find the method or any valid example of this anywhere, so if i miss something, just point it to me and i should be able to deal with it.

Then, on the “pass over” section i need more of an advice then anything else. I already know how to detect my square using the ray method, but am not so sure this is the best way. I could simply force the computer to calculate the mouse ray position everytime the player move is mouse but this seem to me a little bit extreme in terme of calculation. Am pretty new in term of optimisation and good pratice, so this is why i prefer to ask, rather then be force to work back on my code when i realise later on that i use to much of the CPU power.

Thank you in advance for any help

Beware early optimization. I’m not sure you can do much better than casting a ray when the mouse moves. It’s certainly the easiest. And if that’s the thing that slows your game down then you have other much larger problems.

Regarding the other, if you could explain better the type of effect you are trying to achieve then that would be helpful. And a picture is worth a thousand words for visual things like this.

1 Like

You can have thousands of rays before it becomes a problem, its a common way to e.g. have NPCs follow the terrain. Doing that with the mouse certainly is no problem, its basically the only way if you don’t have other data to derive this info from.

1 Like

Dont worry about rays, in most games for each npc there are two rays each frame. one downward and one where they aim.

1 Like

Perfect, thanks, il write to method and give it some test, il come back later to give you result.

pspeed : id realy like to put picture but am not realy sure how the picture hosting realy work and laziness/short time oblige, i decide to skip it . I have seen some site but if you could just give me where i should go i can put you some right aways

My only problem left is the shape one, how can i put the black line around my cube? Should i creat a new custom mesh on each and every of my cube or is there a better way?

for picture hosting just use imgur.com its working fine and you can get the driect link ot the image to include into the forum.

I would go with the appoach you mentiond for the beginning, and if it gets to slow or something later it can always still be changed then.
(You would wonder around 8 out of 10 places i did like that never needed to be redone for performance as they were quite fast enough)

1 Like

Well here are some picture, more to show the test result then anyting else. I found how to make it work, now all i need is to put my black line. Realy not sure how i will do that part, so if you have any advice, go for it

i try to make a JME symbol but o well… as it detect every movement of the mouse it was pretty hard xD

It might be easiest to just draw another piece of geometry instead of manipulating original one. With square grid, it is best to have world in grid units and then all the grid manipulation becomes really easy (and picking is as simple as round(x), round(z) or floor(x),floor(z) depending if you use half-unit offset).

A short demo for very similar thing from my old experiments
[video]Virtual Mat 'forcefield' selection marker - YouTube
In this case, I was using just flat squares for selection instead of cubes and square separation was done directly on board geometry - but as it was supposed to simulate boardgame, not ‘real world’, estetic requirements are probably different.

Well i do want a much more “realistic” point of view, first because i eventually want to put cover, height and stuff like that but also because right now i use the same enviroment i use in my real time part, as the tactical part only apper in the combat section. but this demo seem very interesting, and the idear of creating instead of changing my geom seem to me like a good one. For what is of the all the world becauming a grid well i don’t know. I have seen a lot of game like that but i fell like i don’t realy need it but i could still try it. Are any of your code available anywhere? I won’t lie i love exemple, it is always a good thing when you seek some information to have a exemple somewhere.