devNotes 6-19-2017 Flight – Presets – Rotations

—————————————————————

    private void CLIMBING_IN_The_VU()
    {
        //Vector3 vCtrl1_to_Ctrl2 = ctrl2.transform.position - ctrl1.transform.position;
        bool bClimb1 = ctrl1.GetComponent<Argos_Controller_Interface>().bClimbing;
        bool bClimb2 = ctrl2.GetComponent<Argos_Controller_Interface>().bClimbing;

        Vector3 axis;
        float angle;

        if (bClimb1 || bClimb2)
        {
            if (is_A_Trigger_Pressed() && bClimb1)
            {
                vCtrl1_Right = ctrl1.transform.right;
                Quaternion q = Quaternion.FromToRotation(vCtrl1_Right, vCtrl1_Last_Right);
                
                vCtrl1_Up = ctrl1.transform.up;
                Quaternion q2 = Quaternion.FromToRotation(vCtrl1_Up, vCtrl1_Last_Up);
                Quaternion q3 = q * q2;

                slerp_Ctrl_Pos_1 = Vector3.Slerp(slerp_Ctrl_Pos_1, ctrl1.transform.position, Time.deltaTime * grab_Rotate_Damping);

                slerp_Rotation_1 = Quaternion.Slerp(slerp_Rotation_1, q3, Time.deltaTime * grab_Rotate_Damping);

                slerp_Rotation_1.ToAngleAxis(out angle, out axis);

                argos_Teleport.transform.RotateAround(slerp_Ctrl_Pos_1, axis, angle * 0.99f);

                VU_UI.transform.RotateAround(slerp_Ctrl_Pos_1, axis, angle *0.99f);

            }
            else if(is_A_Trigger_Pressed() && bClimb2)
            {
                vCtrl2_Right = ctrl2.transform.right;
                Quaternion q = Quaternion.FromToRotation(vCtrl2_Right, vCtrl2_Last_Right);

                vCtrl2_Up = ctrl2.transform.up;
                Quaternion q2 = Quaternion.FromToRotation(vCtrl2_Up, vCtrl2_Last_Up);
                Quaternion q3 = q * q2;
                slerp_Ctrl_Pos_2 = Vector3.Slerp(slerp_Ctrl_Pos_2, ctrl2.transform.position, Time.deltaTime * grab_Rotate_Damping);

                slerp_Rotation_2 = Quaternion.Slerp(slerp_Rotation_2, q3, Time.deltaTime * grab_Rotate_Damping);

                slerp_Rotation_2.ToAngleAxis(out angle, out axis);

                argos_Teleport.transform.RotateAround(slerp_Ctrl_Pos_2, axis, angle * 0.99f);

                VU_UI.transform.RotateAround(slerp_Ctrl_Pos_2, axis, angle * 0.99f);
            }

            if (!is_A_Trigger_Pressed())
            {
                float c = 1;
                if(current_USER_LOCATION == USER_LOCATION.IN_THE_VU)
                {
                    c = 75* ui_Ladder.Velocity_Adjust/28f; //Introduce scaling
                }
                if (bClimb1)
                {
                    Vector3 vDelt = ctrl1.transform.position - vCtrl1_Last_Pos;
                    argos_Teleport.transform.position -= c*vDelt;
                    Vector3 vTran = c * vDelt; //argos_Teleport.transform.InverseTransformDirection(c * vDelt);
                    VU_UI.transform.position -= vTran;
                }
                else if (bClimb2)
                {
                    Vector3 vDelt = ctrl2.transform.position - vCtrl2_Last_Pos;
                    argos_Teleport.transform.position -= c*vDelt;
                    Vector3 vTran = c * vDelt; //argos_Teleport.transform.InverseTransformDirection(c * vDelt);
                    VU_UI.transform.position -= vTran;
                }
            }
        }
        else
        {
            if (active_Ctrl_States.bCtrl_1_On)
            {
                slerp_Ctrl_Pos_1 = ctrl1.transform.position;
                slerp_Rotation_1 = Quaternion.identity;
            }
            if(active_Ctrl_States.bCtrl_1_On)
            {
                slerp_Ctrl_Pos_2 = ctrl2.transform.position;
                slerp_Rotation_2 = Quaternion.identity;
            }
        }

        vCtrl1_Last_Right = ctrl1.transform.right;
        vCtrl2_Last_Right = ctrl2.transform.right;
        vCtrl1_Last_Up    = ctrl1.transform.up;
        vCtrl2_Last_Up    = ctrl2.transform.up;

        vCtrl1_Last_Pos = ctrl1.transform.position;
        vCtrl2_Last_Pos = ctrl2.transform.position;
    }

 


    public void Shape_Flight_Control_Transforms()
    {
        if (glass_Stabilizer != null)
        {
            vCurrPos = argos_Teleport.transform.position;
            if (active_Ctrl_States.bGlobal_Flight_Control_On)
            {
                if (!bUI_Grabbed_Glass_Hold)
                {
                    float rotation_Rate = argos_file.Get_Curr_Rotation_Rate_Adjust((int)active_Ctrl_States.curr_FLIGHT_MODE); //ui_Ladder.Rotation_Rate;
                    float velocity_Adjust = argos_file.Get_Curr_Velocity_Adjust((int)active_Ctrl_States.curr_FLIGHT_MODE);//ui_Ladder.Velocity_Adjust;
                    if (current_USER_LOCATION != USER_LOCATION.IN_THE_VU)
                    {
                        rotation_Rate /= 5f; //Don't rotate so much in Lab View
                        velocity_Adjust = velocity_Adjust * 5;
                    }

                    float val_Z = ctrl_Rotation.get_z_Rota();
                    argos_Teleport.transform.RotateAround(glass_Stabilizer.gameObject.transform.position,
                        glass_Stabilizer.gameObject.transform.forward, rotation_Rate * val_Z * Time.fixedDeltaTime);

                    VU_UI.transform.RotateAround(glass_Stabilizer.gameObject.transform.position,
                        glass_Stabilizer.gameObject.transform.forward, rotation_Rate * val_Z * Time.fixedDeltaTime);

                    /////////////////////////////////

                    float val_X = ctrl_Rotation.get_x_Rota();
                    argos_Teleport.transform.RotateAround(glass_Stabilizer.gameObject.transform.position,
                        glass_Stabilizer.gameObject.transform.right, rotation_Rate * val_X * Time.fixedDeltaTime);

                    VU_UI.transform.RotateAround(glass_Stabilizer.gameObject.transform.position,
                            glass_Stabilizer.gameObject.transform.right, rotation_Rate * val_X * Time.fixedDeltaTime);

                    /////////////////////////////////


                    float val_Y = ctrl_Rotation.get_y_Rota();
                    argos_Teleport.transform.RotateAround(glass_Stabilizer.gameObject.transform.position,
                        glass_Stabilizer.gameObject.transform.up, rotation_Rate * val_Y * Time.fixedDeltaTime);

                    VU_UI.transform.RotateAround(glass_Stabilizer.gameObject.transform.position,
                        glass_Stabilizer.gameObject.transform.up, rotation_Rate * val_Y * Time.fixedDeltaTime);

                    /////////////////////////////////

                    Vector3 dP = glass_Stabilizer.get_current_Velocity() * velocity_Adjust * Time.fixedDeltaTime;
                    argos_Teleport.transform.position += dP;
                    VU_UI.transform.transform.position += dP;

                }
            }
            vLastPos = vCurrPos;
        }
    }

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *