title: Calculating how visible an object is in a 3D-scene for use in game logic/AI
body: <p>I am starting a game project which will allow characters to hide in dark areas. Hiding in a dark corner should make it harder for other characters to see you.</p>
  
  <p>What I need is a way to calculate how the lighting conditions are where the character is located.</p>
  
  <p>The ideal would be to have a </p>
  
  <pre><code>double getLightFactor(GameCharacter observer, GameCharacter target)
  </code></pre>
  
  <p>since I suppose there could be lighting conditions where light falls so that different sides of the target is hit by different amounts of lights.
  But I would gladly settle for</p>
  
  <pre><code>double getLightFactor(GameCharacter target)
  </code></pre>
  
  <p>to get the light for a specific character regardless of where you are watching from or even</p>
  
  <pre><code>double getLightFactor(int x, int z)
  </code></pre>
  
  <p>to just get the light at a specific map point in the terrain.</p>
  
  <p>The method need to take into account that lighting conditions may change during gameplay, but since it is turn based some heavy calculations could be allowed. I intend to make it possible to use flashlights so they need to be taken into account as well (but they could be modeled and handled separately).</p>
  
  <p>I will be using Ogre3d to handle my scene, but I will happily accept generic solutions or even solutions for other engines (my choice of engine is not carved in stone).</p>
  
  <p>Ideas, papers or really anything relevant is very welcome!</p>