I am working on a top down strategy game (the player controls a number of units).
One thing I am trying to do is give each unit a view Frustum.
Hence you can only see an enemy unit if it’s in the view of one of your units.
I want the visibility calculation to take obstacles and terrain into account (if something is in the way, your unit can’t see the enemy unit).
Q1) Does the following approach make sense (best approach / flaws?):
Build 2 scenes (two root nodes).
The first (Complete) scene has the entire world as it really is.
The second (Local) scene has the world minus all enemy units.
I will use the “Complete” scene to calculate which enemy units are visible ** then add these units to the “Local” scene.
Next position the camera above an area of the Local scene and render it to the player.
Q2) Can I use the rendering pipeline to calculate visibility.
Per question 1 I need to know which enemy units a friendly unit can see.
I don’t need to do a full render just calculate if the enemy is in the view Frustum and if there is anything blocking (possibly partially blocking) the view.
This logic appears to be the same as the graphics pipeline used for doing the main render, so:
- Can I reuse some of the graphics pipeline?
- Does it make sense to do this (is it overkill)?
Q3) Optimizations
Because it is a strat I am thinking about implementing a grid system, both for the terrain and for placing units.
If I was to do this are there any other optimizations I can make ?
For example I could model the “complete” scene using only cubes (each grid location is either occupied or it isn’t).
How much would this help with performance ?
TIA