Hiding spatials in the foreground

Hi guys,



So my game is a Diablo style action RPG. I’ve got the overhead camera working, and it follows the player’s model (Oto for now), which follows mouse clicks. Problem is, the walls in the foreground of my maze are getting in the way.



Can anyone think of a good solution to hide them or set them to be translucent if they are in the way?



What I thought of doing is attaching a control to them that shoots a ray towards the camera. If there is something behind them but nothing between them and the camera, then they must be hidden. The advantage is this also means I wont accidentally hide things I dont want to hide - monsters etc. However, I dont like the idea of attaching a control to every spatial. It also would probably cause complications if I wanted to use GeometryBatchFactory.Optimize().



So… ideas? Should I add render code to shoot out some rays from the camera, and to hide the closest spatial if there are two or more spatials intersected, and the closest spatial does not have a custom control (movement control etc) attached to it? What would happen if I had use GeometryBatchFactory.Optimize() - would my entire level disappear?



I’m going to start playing around to see what I can come up with, just wanted to know if anyone else had some experience or thoughts with this.

Cull them: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:scenegraph_for_dummies

Hello!



I did a bit a long time ago on this subject:



http://hub.jmonkeyengine.org/groups/graphics/forum/topic/jme3-revisiting-the-player-obscuring-problem



http://hub.jmonkeyengine.org/groups/graphics/forum/topic/walls-imparing-view-of-player-tricky-jme3/



A lot of this depends on your situation, how you want to achieve the effect, and your plans for the complexity of your level. If the floor is always a constant and never runs into a situation where the player might be obscured (Stairs, ledges) then you probably don’t even need to worry about that. If you don’t care about walls popping in and out of view then culling will be fine.



The worst of this is a ‘walls’ geometry and a ‘floor’ geometry or even a ‘level geometry’ as it might make things more difficult.



I’ve been away from working with my project for a while, but I could probably still field your questions on this with some more information as I’ve thought about this problem extensively in the past. It was probably one of the most complicated things I was trying to get right back then.



Cheers!

~FlaH

Thanks tehflah, those are some interesting reads.



I played a bit of Torchlight to see how they handle it, some things I noticed:



The camera is a little more overhead than mine.



A lot of the levels make it impossible to reach the bottom edge - there is often inaccessible stuff rendered beneath, like a background of sorts. On other levels, the walls obscure a part of the floor, but the player model is highlighted and visible through the wall when behind it. Not sure how they do that. Any ideas on how to make a model shine through? Alpha values? Suppose that could be done with a single ray.



Attached are some screenshots of how things look currently:





Walls visible.







Walls culled.



Currently the walls are boxes. Yes not great performance wise, I do use the GeometryBatchFactory but still not a great idea. Anyway, I’m going to change that to a mesh, or meshes, that have their normals pointing inwards except for on top, where the normals will be pointing upwards. So a little bit on top will be visible to the player. Will this obscure anything behind it? Maybe I’ll test that out quick.



The other thing I need to do is work on this background idea, instead of just blackness.



Playing Torchlight makes me realize how far behind I am!