//Construct a new DatabaseParams as a copy of a given DatabaseParams
 public DatabaseParams(DatabaseParams toCopy)
 {
     pixelScale     = toCopy.getPixelScale();
     alphaColor     = toCopy.getAlphaColor();
     alphaThreshold = toCopy.getAlphaThreshold();
     alphaSoftness  = toCopy.getAlphaThreshold();
     hasAlpha       = toCopy.getHasAlpha();
     minPhi         = toCopy.getMinPhi();
     maxPhi         = toCopy.getMaxPhi();
     minTheta       = toCopy.getMinTheta();
     maxTheta       = toCopy.getMaxTheta();
     phiRescaled    = toCopy.getPhiRescaled();
     thetaRescaled  = toCopy.getThetaRescaled();
     invertPhi      = toCopy.getInvertPhi();
     invertTheta    = toCopy.getInvertTheta();
     phiAlignment   = toCopy.getPhiAlignment();
     thetaAlignment = toCopy.getThetaAlignment();
     directory      = toCopy.getDirectory();
     online         = toCopy.getOnline();
 }
Example #2
0
    }     //end LoadDatabase()

    /*
     * Called once per frame.
     * Rotates sprite to face camera
     * Calculates phi and theta values and calls UpdateTexture (if the database is loaded)
     */
    void Update()
    {
        transform.LookAt(PlayerControls.GetGameObject().transform);
        transform.Rotate(new Vector3(0, 180, 0));

        //Calculate phi and set shouldUpdate to true if it has changed
        if (phiVar != null)
        {
            float phi = transform.localRotation.eulerAngles.y;

            //Adjust phi according to alignment, invert and rescaling values
            if (databaseParams.getInvertPhi())
            {
                phi = 360 - phi;
            }
            phi = (phi + databaseParams.getPhiAlignment()) % 360;

            if (databaseParams.getPhiRescaled())
            {
                float min   = phiValues[0];
                float max   = phiValues[phiValues.Length - 1];
                float ratio = (phi - databaseParams.getMinPhi()) / (databaseParams.getMaxPhi() - databaseParams.getMinPhi());
                phi = ratio * (max - min) + min;
            }

            phi = FindNearest(phi, phiValues);
            if (!phi.ToString().Equals(phiVar.GetSelectedValue()))
            {
                phiVar.SetSelectedValue(phi.ToString());
            }
        }

        //Calculate theta and set shouldUpdate to true if it has changed
        if (thetaVar != null)
        {
            float theta = transform.localRotation.eulerAngles.x;
            theta = theta <= 90 ? theta + 90 : theta - 270;             //Corrects rotation

            //Adjust theta according to alignment, invert and rescaling values
            if (databaseParams.getInvertTheta())
            {
                theta = 180 - theta;
            }
            theta = (theta + databaseParams.getThetaAlignment()) % 360;

            if (databaseParams.getThetaRescaled())
            {
                float min   = thetaValues[0];
                float max   = thetaValues[thetaValues.Length - 1];
                float ratio = (theta - databaseParams.getMinTheta()) / (databaseParams.getMaxTheta() - databaseParams.getMinTheta());
                theta = ratio * (max - min) + min;
            }

            theta = FindNearest(theta, thetaValues);
            if (!theta.ToString().Equals(thetaVar.GetSelectedValue()))
            {
                thetaVar.SetSelectedValue(theta.ToString());
            }
        }

        if (loaded)
        {
            UpdateTexture();
        }

        float megabytes = cache.getMemorySize() / (1000000.0f);

        cacheText.text = "Cache size: " + megabytes.ToString("F2") + " MB\n(" +
                         cache.getSize() + "/" + Cache.maxItems + ") Images stored";
    }