62 using System.Collections.Generic;
    84     public static bool reset = 
false;
    87     private const float diagCoef = 0.707106781186548f; 
   115         float lowerNine     =   density[i-1, j-1, k-1]  +   density[i, j-1, k-1]    +   density[i+1, j-1, k-1]  + 
   116                                 density[i-1, j-1, k]    +   density[i, j-1, k]      +   density[i+1, j-1, k]    + 
   117                                 density[i-1, j-1, k+1]  +   density[i, j-1, k+1]    +   density[i+1, j-1, k+1]  ; 
   120         float middleEight   =   density[i-1, j, k-1]    +   density[i, j, k-1]      +   density[i+1, j, k-1]    + 
   121                                 density[i-1, j, k]      +   0f                      +   density[i+1, j, k]      + 
   122                                 density[i-1, j, k+1]    +   density[i, j, k+1]      +   density[i+1, j, k+1]    ; 
   125         float upperNine     =   density[i-1, j+1, k-1]  +   density[i, j+1, k-1]    +   density[i+1, j+1, k-1]  + 
   126                                 density[i-1, j+1, k]    +   density[i, j+1, k]      +   density[i+1, j+1, k]    + 
   127                                 density[i-1, j+1, k+1]  +   density[i, j+1, k+1]    +   density[i+1, j+1, k+1]  ; 
   129         float result = lowerNine + middleEight + upperNine;
   137         float lowerNine     =   cornerCoef  * density[i-1, j-1, k-1]    +   diagCoef    * density[i, j-1, k-1]  +   cornerCoef  * density[i+1, j-1, k-1]    + 
   138                                 diagCoef    * density[i-1, j-1, k]      +   faceCoef    * density[i, j-1, k]    +   diagCoef    * density[i+1, j-1, k]      + 
   139                                 cornerCoef  * density[i-1, j-1, k+1]    +   diagCoef    * density[i, j-1, k+1]  +   cornerCoef  * density[i+1, j-1, k+1]    ; 
   142         float middleEight   =   diagCoef    * density[i-1, j, k-1]      +   faceCoef    * density[i, j, k-1]    +   diagCoef    * density[i+1, j, k-1]      + 
   143                                 faceCoef    * density[i-1, j, k]        +   0f                                  +   faceCoef    * density[i+1, j, k]        + 
   144                                 diagCoef    * density[i-1, j, k+1]      +   faceCoef    * density[i, j, k+1]    +   diagCoef    * density[i+1, j, k+1]      ; 
   147         float upperNine     =   cornerCoef  * density[i-1, j+1, k-1]    +   diagCoef    * density[i, j+1, k-1]  +   cornerCoef  * density[i+1, j+1, k-1]    + 
   148                                 diagCoef    * density[i-1, j+1, k]      +   faceCoef    * density[i, j+1, k]    +   diagCoef    * density[i+1, j+1, k]      + 
   149                                 cornerCoef  * density[i-1, j+1, k+1]    +   diagCoef    * density[i, j+1, k+1]  +   cornerCoef  * density[i+1, j+1, k+1]    ; 
   151         float result = lowerNine + middleEight + upperNine;
   169         for(
int i=0; i<
xDim; i++) {
   170             for(
int j=0; j<
yDim; j++) {
   171                 occlusion[i,        j,          0       ] = 0f; 
   172                 occlusion[i,        j,          zDim-1  ] = 0f; 
   174             for(
int k=0; k<
zDim; k++) {
   175                 occlusion[i,        0,          k       ] = 0f; 
   176                 occlusion[i,        yDim-1,     k       ] = 0f; 
   180         for(
int j=0; j<
yDim; j++) {
   181             for(
int k=0; k<
zDim; k++) {
   182                 occlusion[0,        j,          k       ] = 0f; 
   183                 occlusion[xDim-1,   j,          k       ] = 0f; 
   193         minDensity = 
float.MaxValue;
   194         maxDensity = -
float.MaxValue;
   195         foreach(
float f 
in density) {
   209         Debug.Log(
"Density bounds, min and max:");
   210         Debug.Log(minDensity.ToString());
   211         Debug.Log(maxDensity.ToString());
   219         pdb2den = 
new GameObject();
   221         genDensity = pdb2den.GetComponent<
PDBtoDEN>();
   226         if(moleculeSize < 2000)
   228         else if (moleculeSize < 5000)
   230         else if (moleculeSize < 10000)
   233             delta_scalar = 0.16f;
   235         delta = 
new Vector3(delta_scalar, delta_scalar, delta_scalar);
   243         xDim = density.GetLength(0);
   244         yDim = density.GetLength(1);
   245         zDim = density.GetLength(2);
   247         Debug.Log(
"Density grid size :");
   248         Debug.Log(xDim.ToString());
   249         Debug.Log(yDim.ToString());
   250         Debug.Log(zDim.ToString());
   254         for(
int i=1; i<(xDim-1); i++)
   255             for(
int j=1;  j<(yDim-1); j++)
   256                 for(
int k=1; k<(zDim-1); k++)
   274         Vector3 position = Vector3.zero;
   275         Vector3 indices = Vector3.zero;
   277         Debug.Log(maxDensity.ToString());
   288             position = bu.transform.position;
   290             indices = Vector3.Scale(delta, (position - origin)) + 
fudgeFactor;
   296             x = Mathf.RoundToInt(indices.x);
   297             y = Mathf.RoundToInt(indices.y);
   298             z = Mathf.RoundToInt(indices.z);
   299             colorFactor = (maxDensity - occlusion[x,y,z]) / maxDensity;
   313             color = (color * colorFactor * compensationFactor);
   329         Debug.Log(
"AmbientOcclusion: reverting to original colors.");
 static void SetOcclusionGridBounds()
Sets the occlusion grid bounds. 
 
static float compensationFactor
 
void Revert()
Reverts the molecule to its original colors, that is before the Depth Cueing effect was applied...
 
AmbientOcclusion()
Initializes a new instance of the AmbientOcclusion class. 
 
void TranPDBtoDEN(float resolution=DEFAULT_RESOLUTION, bool cap=true)
 
static void BuildColorList()
Builds the list of the original colors, that is before the Depth Cueing effect is applied...
 
static PDBtoDEN genDensity
 
void Occlude()
Perfoms the actual Ambient Occlusion operations. 
 
static Vector3 fudgeFactor
 
static BallUpdate[] balls
 
static float WeightedAverageOfSurroundingCubes(int i, int j, int k)
 
static GameObject pdb2den
 
const float totalWeightFactor
 
static Vector3 inverseDelta
 
static List< Color > atomsColorList
The color of each atom. 
 
static Vector3 fudgeFactor
 
static void FillFacesWithZeros()
This fills the "faces" of the cube with zeros, because they do not have the necessary number of neigh...
 
static float AverageOfSurroundingCubes(int i, int j, int k)
Computes the sum of the surrounding cubes. 
 
static Vector3 MinValue
The "smallest" corner of the bounding box that encloses the molecule. 
 
static float[,,] occlusion
 
static List< Color > originalColors
 
static List< float[]> atomsLocationlist
The coordinates of each atom.