Esempio n. 1
0
 public CameraManager()
 {
     position1 = new cameraPosition();
     position2 = new cameraPosition();
     position3 = new cameraPosition();
     position4 = new cameraPosition();
     position5 = new cameraPosition();
     position6 = new cameraPosition();
     position7 = new cameraPosition();
     position8 = new cameraPosition();
     position9 = new cameraPosition();
     position0 = new cameraPosition();
 }
Esempio n. 2
0
    // constructor that makes a serializablePosition from a specific cameraPosition
    public serializablePosition(cameraPosition P)
    {
        FOV = P.FOV;

        posX = P.position.x;
        posY = P.position.y;
        posZ = P.position.z;

        angleW = P.angle.w;
        angleX = P.angle.x;
        angleY = P.angle.y;
        angleZ = P.angle.z;

        angleCamW = P.angleCam.w;
        angleCamX = P.angleCam.x;
        angleCamY = P.angleCam.y;
        angleCamZ = P.angleCam.z;
    }
Esempio n. 3
0
    void loadPosition(cameraPosition P)                                 //sets current position, player angle(theta), and FOV to selected save and prepares camera to load angle(phi)
    {
        Input.ResetInputAxes();                                         //resets input from the movement keys

        float clampedX = Mathf.Clamp(P.position.x, minPos.x, maxPos.x); //accounts for if the position was saved while viewing a database that had different bounds
        float clampedY = Mathf.Clamp(P.position.y, minPos.y, maxPos.y);
        float clampedZ = Mathf.Clamp(P.position.z, minPos.z, maxPos.z);

        transform.position = new Vector3(clampedX, clampedY, clampedZ);

        Camera.main.fieldOfView = P.FOV;
        FOV = P.FOV;
        transform.rotation = P.angle;

        loadCameraRotation = P.angleCam;
        CameraControls.fixAngle();

        /*print ("loading angle (" + P.angleCam.eulerAngles.x + ", " + P.angle.eulerAngles.y + ", 0.0)\n"
         + "and position" + P.position.ToString () + "\n");
         + print("and FOV " + P.FOV + "\n");*/

        isLoading = false;
    }
Esempio n. 4
0
    void loadPositionAnimated(cameraPosition P)                         //sets the value of the variables used to keep track of animation
    {
        Input.ResetInputAxes();                                         //resets input from the movement keys
        dX = (P.position.x - transform.position.x) / (floatFrames - 1); // the distance incremented in the +X direction each frame
        dY = (P.position.y - transform.position.y) / (floatFrames - 1); // +Y direction increment
        dZ = (P.position.z - transform.position.z) / (floatFrames - 1); // +Z direction increment

        /* calculates the minimum increment necessary to animate the player's angle theta (left and right)
         * either ((theta - current theta) / frames),((theta - current theta - 360) / frames), or ((theta - current theta + 360) / frames)
         * essentially, the angle is corrected by +- 360 / frames if it means an increment with a smaller absolute value.
         */
        float dTheta1 = (P.angle.eulerAngles.y - transform.eulerAngles.y) / (floatFrames - 1);

        float dTheta2 = (P.angle.eulerAngles.y - transform.eulerAngles.y - 360) / (floatFrames - 1);
        float dTheta3 = (P.angle.eulerAngles.y - transform.eulerAngles.y + 360) / (floatFrames - 1);


        if (Mathf.Min(Mathf.Min(Mathf.Abs(dTheta1), Mathf.Abs(dTheta2)), dTheta3) == Mathf.Abs(dTheta1))
        {
            dTheta = dTheta1;
        }
        else if (Mathf.Min(Mathf.Abs(dTheta2), dTheta3) == Mathf.Abs(dTheta2))
        {
            dTheta = dTheta2;
        }
        else
        {
            dTheta = dTheta3;
        }

        // calculates the minimum increment necessary to animate the camera's angle phi (up and down)
        // either ((phi - current phi) / frames),((phi - current phi - 360) / frames), or ((phi - current phi + 360) / frames)

        float dPhi1 = (P.angleCam.eulerAngles.x - CameraControls.currentAngle.eulerAngles.x) / (floatFrames - 1);
        float dPhi2 = ((P.angleCam.eulerAngles.x - CameraControls.currentAngle.eulerAngles.x) - 360) / (floatFrames - 1);
        float dPhi3 = ((P.angleCam.eulerAngles.x - CameraControls.currentAngle.eulerAngles.x) + 360) / (floatFrames - 1);

        if (Mathf.Min((Mathf.Min(Mathf.Abs(dPhi1), Mathf.Abs(dPhi2))), dPhi3) == Mathf.Abs(dPhi1))
        {
            dPhi = dPhi1;
        }
        else if (Mathf.Min((Mathf.Min(Mathf.Abs(dPhi1), Mathf.Abs(dPhi2))), dPhi3) == Mathf.Abs(dPhi2))
        {
            dPhi = dPhi2;
        }
        else
        {
            dPhi = dPhi3;
        }

        dF = (P.FOV - FOV) / (floatFrames - 1);       // the FOV increment

        animationFrame = 0;
        if (isOrbiting)
        {
            animationFrame = 1;
        }
        lastFrame = P;

        /*print ("loading angle (" + P.angleCam.eulerAngles.x + ", " + P.angle.eulerAngles.y + ", 0.0)\n"
         + "and position" + P.position.ToString () + "\n");
         + print("and FOV " + P.FOV + " and animating\n");*/
    }
Esempio n. 5
0
 // Use this for initialization
 void Start()
 {
     cameraPos = cameraPosition.BACK;
     offset	  = transform.position - GameController.control.transform.position;
     transform.LookAt (GameController.control.transform.position);
 }