Hi
I'm currently working on a game much like X-Com / Jagged Alliance, but in full 3D. It features 2 groups fighting each other on a multi-level map, sometimes flat, sometimes 'hilly', sometimes buildings.
For this, I need to calculate how much (in percent) of an object (one of the fighters) is visible (not obscured by anything else) from another object (another fighter). Theoretically, it would be enough to know if it's A: totally obscured B: up to half obscured C: more than half obscured D: totally obscured.
Yet, I'm not sure how to do it. Creating a lot of rays between the objects and checking if they hit something other than the target seems very brute-force-ish, and probably not highly correct. I've thought about creating a camera that's not displayed on the screen, but that only lets me check if the target is seen, and not how much of it - at least as far as I know.
Maybe someone can point me in the right direction?
Casting 4-5 rays to figure out A-D does not seem that brute-force-ish to me - at least it sounds like an easy option and is most probably cheaper than rendering to an offscreen buffer and compute the visible area…
irrisor said:
Casting 4-5 rays to figure out A-D does not seem that brute-force-ish to me :) - at least it sounds like an easy option and is most probably cheaper than rendering to an offscreen buffer and compute the visible area...
The problem in this case is generating these 4 - 5 rays. The combattants aren't simple geometrical figures, but the rays should be evenly distributed... :/
Nodwick said:
The combattants aren't simple geometrical figures
what about using boundings for this?
irrisor said:
Nodwick said:
The combattants aren't simple geometrical figures
what about using boundings for this?
I've already thought about using bounding, but I think that may lead to wrong results in some cases.
For example, if a human fighter has one hand raised above his head, while the other hand is pointing at an enemy, the bounding box is far greater than the miniature, and his enemy may see part of the box while the fighter is really hidden behind a wall.
The best idea I've yet had is calculating a ray from the origin to the center of every triangle in the TriMesh. While this may result in a LOT of checks for ray-object intersections, it would give a very exact result. But I think it may be too slow for use, even in a turn-based game.
the most exact way, and easiest, would be to use an occlusion query(ARB_occlusion_query / NV_occlusion_query)…if it was incorporated into jME and if the card supports it
so for now, you would have to go directly at the opengl calls…
http://msi.unilim.fr/~porquet/glexts/GL_ARB_occlusion_query.txt.html
http://www.codesampler.com/oglsrc/oglsrc_7.htm#ogl_occlusion_query
http://www.gamedev.net/reference/programming/features/occlusionculling/
MrCoder said:
the most exact way, and easiest, would be to use an occlusion query(ARB_occlusion_query / NV_occlusion_query)...if it was incorporated into jME and if the card supports it :)
so for now, you would have to go directly at the opengl calls...
http://msi.unilim.fr/~porquet/glexts/GL_ARB_occlusion_query.txt.html
http://www.codesampler.com/oglsrc/oglsrc_7.htm#ogl_occlusion_query
http://www.gamedev.net/reference/programming/features/occlusionculling/
Thanks for the idea, I'll look at the links you supplied. Hopefully, that won't get too complicated ;)