コード例 #1
0
    void Update()
    {
        //Directions obtained from CC_CANOE class. We use the Right wand and Head for orientation.
        //Where the right wand is pointed is the direction the player will move
        Vector3 forwardDir = CC_CANOE.WandGameObject(Wand.Right).transform.forward;
        Vector3 rightDir   = CC_CANOE.HeadGameObject().transform.right;

        rightDir = Vector3.Normalize(Vector3.ProjectOnPlane(rightDir, Vector3.up));
        Vector3 upDir = Vector3.up;

        //The input from the trigger axis of the left wand
        float forward = CC_INPUT.GetAxis(Wand.Right, WandAxis.Trigger);

        //Move the CharacterController attached to the CC_CANOE.
        Vector3 movement = forwardDir * forward;

        charCont.Move(movement * Time.deltaTime * moveSpeed);

        //The input from the X and Y axis of the right wand joystick.
        yAxisChange += CC_INPUT.GetAxis(Wand.Right, WandAxis.XAxis) * Time.deltaTime * lookSpeed;
        yAxisChange  = yAxisChange % 360.0f;
        xAxisChange += CC_INPUT.GetAxis(Wand.Right, WandAxis.YAxis) * Time.deltaTime * lookSpeed;
        xAxisChange  = Mathf.Clamp(xAxisChange, -maxPitch, maxPitch);

        //Change the direction the CharacterController is facing.
        charCont.transform.rotation = Quaternion.identity;
        charCont.transform.RotateAround(CC_CANOE.CanoeGameObject().transform.position, Vector3.up, yAxisChange);
        charCont.transform.RotateAround(CC_CANOE.CanoeGameObject().transform.position, rightDir, xAxisChange);
    }
コード例 #2
0
    /// <summary>
    /// Updates the camera perspective for one group of screens.
    /// </summary>
    /// <param name="cameras">Array of cameras.</param>
    /// <param name="cameraIndex">Index of the camera to update.</param>
    /// <param name="panOptic">True for panoptic view mode.</param>
    public void UpdateCameraPerspective(Camera[] cameras, int cameraIndex, bool panOptic)
    {
        //Get this camera rig's projection screens
        GameObject[] projScreens = new GameObject[4];
        if (cameraIndex == 8)
        {
            cameraIndex = 0;
        }
        projScreens[0] = Screens.transform.GetChild(cameraIndex * 4).gameObject;
        projScreens[1] = Screens.transform.GetChild(cameraIndex * 4 + 1).gameObject;
        projScreens[2] = Screens.transform.GetChild(cameraIndex * 4 + 2).gameObject;
        projScreens[3] = Screens.transform.GetChild(cameraIndex * 4 + 3).gameObject;

        //Set each camera's rotation depending on PanOptic setting
        if (panOptic)
        {
            for (int i = 0; i < 4; i++)
            {
                cameras[i].transform.LookAt(projScreens[i].transform, CC_CANOE.CanoeGameObject().transform.up);
            }
        }
        else
        {
            for (int i = 0; i < 4; i++)
            {
                cameras[i].transform.localEulerAngles = Vector3.zero;
            }
        }

        //Set each camera's projection
        for (int i = 0; i < 4; i++)
        {
            perspectiveOffCenter(cameras[i], projScreens[i]);
            perspectiveOffCenter(cameras[i].transform.GetChild(0).GetComponent <Camera>(), projScreens[i]);
            perspectiveOffCenter(cameras[i].transform.GetChild(1).GetComponent <Camera>(), projScreens[i]);
        }
    }