public override void Init()
    {
        // First we use PDBtoDen to create a density grid.
        pdb2den = new GameObject();
        pdb2den.AddComponent <PDBtoDEN>();
        genDensity = pdb2den.GetComponent <PDBtoDEN>();

        float delta_scalar = 2.0f;

        delta = new Vector3(delta_scalar, delta_scalar, delta_scalar);
        genDensity.TranPDBtoDEN(delta_scalar);
        delta       = PDBtoDEN.delta;
        fudgeFactor = PDBtoDEN.fudgeFactor;

        // We get that grid and its delta.
        density = PDBtoDEN.GridS;
        //delta = PDBtoDEN.delta;

        inverseDelta = new Vector3(1f / delta.x,
                                   1f / delta.y,
                                   1f / delta.z);

        // We need to refresh the molecule's origin when it's not the first molecule for which we generate a volumetric density.
        origin = MoleculeModel.MinValue;

        // We determine the amplitude of the density.
        foreach (float f in density)
        {
            if (f > maxDensity)
            {
                maxDensity = f;
            }
            if (f < minDensity)
            {
                minDensity = f;
            }
        }
        densityAmplitude = maxDensity - minDensity;

        // Creating the dynamic particle list, building the static particle array,
        // setting it to the particle system, and enabling the renderer.
        SetParticleSystem();
    }     // End of Init
示例#2
0
    /// <summary>
    /// Initializes a new instance of the <see cref="AmbientOcclusion"/> class.
    /// </summary>
    public AmbientOcclusion()
    {
        // First we use PDBtoDen to create a density grid.
        pdb2den = new GameObject();
        pdb2den.AddComponent <PDBtoDEN>();
        genDensity = pdb2den.GetComponent <PDBtoDEN>();


        float delta_scalar;
        int   moleculeSize = MoleculeModel.atomsLocationlist.Count;

        if (moleculeSize < 2000)
        {
            delta_scalar = 0.2f;
        }
        else if (moleculeSize < 5000)
        {
            delta_scalar = 0.4f;
        }
        else if (moleculeSize < 10000)
        {
            delta_scalar = 0.2f;
        }
        else
        {
            delta_scalar = 0.16f;
        }
        //fudgeFactor = PDBtoDEN.fudgeFactor /delta_scalar; ???
        delta = new Vector3(delta_scalar, delta_scalar, delta_scalar);
        genDensity.TranPDBtoDEN(delta_scalar, false);
        density     = PDBtoDEN.GridS;
        fudgeFactor = PDBtoDEN.fudgeFactor;

        // We need to refresh the molecule's origin when it's not the first molecule for which we generate a volumetric density.
        origin = MoleculeModel.MinValue;

        xDim = density.GetLength(0);
        yDim = density.GetLength(1);
        zDim = density.GetLength(2);

        Debug.Log("Density grid size :");
        Debug.Log(xDim.ToString());
        Debug.Log(yDim.ToString());
        Debug.Log(zDim.ToString());

        occlusion = new float[xDim, yDim, zDim];

        for (int i = 1; i < (xDim - 1); i++)
        {
            for (int j = 1; j < (yDim - 1); j++)
            {
                for (int k = 1; k < (zDim - 1); k++)
                {
                    if (weighted)
                    {
                        occlusion[i, j, k] = WeightedAverageOfSurroundingCubes(i, j, k);
                    }
                    else
                    {
                        occlusion[i, j, k] = AverageOfSurroundingCubes(i, j, k);
                    }
                }
            }
        }

        FillFacesWithZeros();
        SetOcclusionGridBounds();
        balls = GameObject.FindObjectsOfType(typeof(BallUpdate)) as BallUpdate[];
        BuildColorList();
        reset = false;
    }