Exemple #1
0
 private void bonds()
 {
     if (addAtoms.proteinShowing)
     {
         addAtoms.proteinShowing = addAtoms.resetProtein("bonds");
         if (addAtoms.ballAndStickShowing)
         {
             addAtoms.resetProtein("balls");
         }
     }
     else
     {
         addAtoms.proteinShowing = addAtoms.showMode("bonds");
         if (addAtoms.ballAndStickShowing)
         {
             addAtoms.showMode("balls");
         }
     }
 }
Exemple #2
0
    public virtual void UpdateMovement()
    {
        if (HaltUpdateMovement)
        {
            return;
        }

        bool moveForward = Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow);
        bool moveLeft    = Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow);
        bool moveRight   = Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow);
        bool moveBack    = Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow);
        bool moveUp      = Input.GetKey(KeyCode.T);
        bool moveDown    = Input.GetKey(KeyCode.G);
        bool zoomIn      = Input.GetAxis("Mouse ScrollWheel") > 0;
        bool zoomOut     = Input.GetAxis("Mouse ScrollWheel") < 0;


        MoveScale = 1.0f;

        if ((moveForward && moveLeft) || (moveForward && moveRight) ||
            (moveBack && moveLeft) || (moveBack && moveRight))
        {
            MoveScale = 0.70710678f;
        }


        MoveScale *= SimulationRate * Time.deltaTime;

        // Compute this for key movement
        float moveInfluence = Acceleration * 0.1f * MoveScale * MoveScaleMultiplier;

        Quaternion ort      = (HmdRotatesY) ? CameraController.centerEyeAnchor.rotation : transform.rotation;
        Vector3    ortEuler = ort.eulerAngles;

        ortEuler.z = ortEuler.x = 0f;
        ort        = Quaternion.Euler(ortEuler);

        if (moveForward)
        {
            MoveThrottle += ort * (transform.lossyScale.z * moveInfluence * Vector3.forward);
        }
        if (moveBack)
        {
            MoveThrottle += ort * (transform.lossyScale.z * moveInfluence * BackAndSideDampen * Vector3.back);
        }
        if (moveLeft)
        {
            MoveThrottle += ort * (transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.left);
        }
        if (moveRight)
        {
            MoveThrottle += ort * (transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.right);
        }
        if (moveUp)
        {
            MoveThrottle += ort * (transform.lossyScale.y * moveInfluence * Vector3.up);
        }
        if (moveDown)
        {
            MoveThrottle += ort * (transform.lossyScale.y * moveInfluence * BackAndSideDampen * Vector3.down);
        }

        if (zoomIn)
        {
            Camera leftCamera  = CameraController.leftEyeAnchor.GetComponent <Camera> ();
            Camera rightCamera = CameraController.rightEyeAnchor.GetComponent <Camera> ();
            if (leftCamera.fieldOfView > 2)
            {
                leftCamera.fieldOfView -= 2;
            }
            if (rightCamera.fieldOfView > 2)
            {
                rightCamera.fieldOfView -= 2;
            }
        }

        if (zoomOut)
        {
            Camera leftCamera  = CameraController.leftEyeAnchor.GetComponent <Camera> ();
            Camera rightCamera = CameraController.rightEyeAnchor.GetComponent <Camera> ();
            if (leftCamera.fieldOfView < 99)
            {
                leftCamera.fieldOfView += 2;
            }
            if (rightCamera.fieldOfView < 99)
            {
                rightCamera.fieldOfView += 2;
            }
        }


        //toggle
        if (Input.GetKey(KeyCode.R) & buttonPushed < Time.time - 0.2f)            //show hide ribbons
        {
            if (addAtoms.ribbonShowing)
            {
                addAtoms.ribbonShowing = addAtoms.resetProtein("ribbons");
            }
            else
            {
                addAtoms.ribbonShowing = addAtoms.showMode("ribbons");
            }
            buttonPushed = Time.time;
        }

        if (Input.GetKey(KeyCode.N) & buttonPushed < Time.time - 0.2f)            //menu
        {
            source.PlayOneShot(menuToggled, 0.5f);
            menu.enabled = !menu.enabled;              //hide show menu
            buttonPushed = Time.time;
        }


        if (Input.GetKey(KeyCode.V) & buttonPushed < Time.time - 0.2f)                  //center
        {
            addAtoms.setPosition(ort * Vector3.forward * 30 + this.transform.position); //centers the atoms infront of the user
            buttonPushed = Time.time;
        }

        if (Input.GetKey(KeyCode.L) & buttonPushed < Time.time - 0.2f)            //screenshot
        {
            Application.CaptureScreenshot(Application.dataPath + "/Screenshot.png", 4);
            buttonPushed = Time.time;
        }

        if (Input.GetKey(KeyCode.X) & buttonPushed < Time.time - 0.2f)            //reset center
        {
            addAtoms.resetTarget();
            buttonPushed = Time.time;
        }

        if (Input.GetKey(KeyCode.Z) & buttonPushed < Time.time - 0.2f)            //lock target
        {
            addAtoms.lockTarget();
            buttonPushed = Time.time;
        }


        if (Input.GetKey(KeyCode.P) & buttonPushed < Time.time - 0.2f)            // change driver
        {
            bool newDriver = false;
            foreach (var user in trackedUsers)
            {
                if (user == null)
                {
                    continue;
                }
                if (user.IsTracked)
                {
                    if (driver == user.TrackingId)
                    {
                        newDriver = true;
                        continue;
                    }
                    if (newDriver)
                    {
                        setDriver(user.TrackingId);
                        newDriver = false;
                        break;
                    }
                }
            }
            if (newDriver)               //iterate once more if a new driver wasn't selected
            {
                foreach (var user in trackedUsers)
                {
                    if (user == null)
                    {
                        continue;
                    }
                    if (user.IsTracked)
                    {
                        if (newDriver)
                        {
                            setDriver(user.TrackingId);
                            break;
                        }
                    }
                }
            }
        }


        moveInfluence = SimulationRate * Time.deltaTime * Acceleration * 0.1f * MoveScale * MoveScaleMultiplier;
    }
Exemple #3
0
    override protected void setDataModel(bool value)
    {
        if (addAtoms == null)
        {
            addAtoms = transform.parent.parent.gameObject.GetComponent <AddAtoms>();
        }

        switch (propertyToggled)
        {
        case PropertiesToToggle.Protein:
            if (addAtoms.proteinShowing)
            {
                addAtoms.proteinShowing = addAtoms.resetProtein("bonds");
                if (addAtoms.ballAndStickShowing)
                {
                    addAtoms.resetProtein("balls");
                }
            }
            else
            {
                addAtoms.proteinShowing = addAtoms.showMode("bonds");
                if (addAtoms.ballAndStickShowing)
                {
                    addAtoms.showMode("balls");
                }
            }
            break;

        case PropertiesToToggle.Ribbons:
            if (addAtoms.alphaShowing)
            {
                addAtoms.alphaShowing = addAtoms.resetProtein("alpha");
            }
            if (addAtoms.ribbonShowing)
            {
                addAtoms.ribbonShowing = addAtoms.resetProtein("ribbons");
            }
            else
            {
                addAtoms.ribbonShowing = addAtoms.showMode("ribbons");
            }
            break;

        case PropertiesToToggle.AlphaTrace:
            if (addAtoms.ribbonShowing)
            {
                addAtoms.ribbonShowing = addAtoms.resetProtein("ribbons");
            }
            if (addAtoms.alphaShowing)
            {
                addAtoms.alphaShowing = addAtoms.resetProtein("alpha");
            }
            else
            {
                addAtoms.alphaShowing = addAtoms.showMode("alpha");
            }
            break;

        case PropertiesToToggle.Water:
            if (addAtoms.waterShowing)
            {
                addAtoms.waterShowing = addAtoms.resetProtein("water");
            }
            else
            {
                addAtoms.waterShowing = addAtoms.showMode("water");
            }
            break;

        case PropertiesToToggle.Ions:
            if (addAtoms.ionsShowing)
            {
                addAtoms.ionsShowing = addAtoms.resetProtein("ion");
            }
            else
            {
                addAtoms.ionsShowing = addAtoms.showMode("ion");
            }
            break;

        case PropertiesToToggle.HBond:
            if (addAtoms.HBondShowing)
            {
                addAtoms.HBondShowing = addAtoms.resetProtein("hbond");
            }
            else
            {
                addAtoms.HBondShowing = addAtoms.showMode("hbond");
            }
            break;

        case PropertiesToToggle.Ligand:
            if (addAtoms.hetatmStick || addAtoms.hetatmBS)
            {
                if (PlayerPrefs.GetString("hetatmBS") == "True")
                {
                    addAtoms.hetatmBS = addAtoms.resetProtein("hetatmbs");
                }
                else if (addAtoms.sphere)
                {
                    addAtoms.hetatmBS = addAtoms.resetProtein("hetatmbs");
                }
                addAtoms.hetatmStick = addAtoms.resetProtein("hetatms");
            }
            else
            {
                if (PlayerPrefs.GetString("hetatmBS") == "True")
                {
                    addAtoms.hetatmBS = addAtoms.showMode("hetatmbs");
                }
                else if (addAtoms.sphere)
                {
                    addAtoms.hetatmBS = addAtoms.showMode("hetatmbs");
                }
                addAtoms.hetatmStick = addAtoms.showMode("hetatms");
            }
            break;
        }
    }