Hello again ;]
I have some issues that might be simple to solve, and I need some enlightenment. I’d appreciate tips or the full code, if you feel there is no problem to share this…
I use a Shadow Projector pointing straight down to simulate a shadow casted by a Cloud. The fieldOfView increases accordingly to the cloud size.
What I need is:
1- Calculate how much % (percent) of the terrain is covered by Shadows;
2- Increase a variable while the player stands inside the shadowed area.
Right now, terrain size is:
Terrain Width: 500
Terrain Length: 500
The terrain area seems to be 250000m²
An approach I’m having is to use trigonometry to calculate the area of a particular shadow and then, sum up with the other shadows. With the shadow area I then calculate how much that area represents of the terrain area. In my tests, I couldn’t get it right. The code is this:
shadowArea = (2projector.farClipPlaneMathf.Tan(projector.fieldOfViewMathf.PI/180)) * (2projector.farClipPlaneMathf.Tan(projector.fieldOfViewMathf.PI/180));
Is it right or there is a more clever approach?
You can have a better idea of what I’m talking about by playing my project below:
http://mcgd.noads.biz/blog/?page_id=5
Controls:
Move: W A S D
Blow: Right Click