示例#1
0
 void Start()
 {
     newer = new rTransform();
     older = new rTransform();
     pushPosition();
     pushPosition();
     oldTime = 0;
 }
示例#2
0
    //get the target position of the camera
    rTransform getCameraTarget()
    {
        //variable for the target rTransform of the camera
        rTransform target = new rTransform();

        //calculate the position/rotation of the camera
        switch (camMode)
        {
        case CameraMode.Track:
            target.position = robotTransform.position + Quaternion.Euler(0f, 270f, 0f) * (cameraOffset.position * (float)zoom);
            target.rotation = cameraOffset.rotation + new Vector3(0f, 270f, 0f);
            break;

        case CameraMode.Chase:
            target.position = Quaternion.Euler(0f, robotTransform.rotation.y, 0f) * (cameraOffset.position * (float)zoom) + robotTransform.position;
            target.rotation = new Vector3(0f, robotTransform.rotation.y, 0f) + cameraOffset.rotation;
            break;

        case CameraMode.BirdsEye:
            target.rotation      = new Vector3(90f, 270f, 0f);
            target.position      = robotTransform.position + new Vector3(0f, 100f, 0f);
            cam.orthographicSize = cameraOffset.position.y * (float)zoom;
            break;

        case CameraMode.DriverStation:
            target.position = driverStation.transform.position + Quaternion.Euler(0f, 270f, 0f) * (cameraOffset.position * (float)zoom);
            target.rotation = cameraOffset.rotation + new Vector3(0f, 270f, 0f);
            break;

        case CameraMode.FullField:
            target.rotation      = new Vector3(90f, 270f, 0f);
            target.position      = new Vector3(0f, 100f, 0f);
            cam.orthographicSize = cameraOffset.position.y * (float)zoom;
            break;

        case CameraMode.VR:
            target.rotation      = new Vector3(17.178f, -106.465f, 0f);
            target.position      = new Vector3(9.486f, 1.735f, 2.133f);
            cam.orthographicSize = cameraOffset.position.y * (float)zoom;
            break;

        default:
            //something messed up!
            print("Failed to read camera mode. Setting default values.");
            //set pos & rotation to 0
            target.rotation = Vector3.zero;
            target.position = Vector3.zero;
            break;
        }
        return(target);
    }
示例#3
0
    //initializes robot rotation & orientation variables,
    //as well as setting camera position.
    void Start()
    {
        robotTransform  = new rTransform();
        cameraTransform = new rTransform();
        getRobotPosition();
        cameraTransform = getCameraTarget();
        setCameraTransform();

        //if the camera is in birdseye mode, go to orthographic projection
        if (camMode == CameraMode.BirdsEye)
        {
            cam.orthographic     = true;
            cam.orthographicSize = cameraOffset.position.y;
        }
        else
        {
            cam.orthographic = false;
        }
    }
示例#4
0
 //interpolate between this transform and another one
 public void lerp(double pAlpha, double rAlpha, rTransform t2)
 {
     position = Vector3.Lerp(position, t2.position, (float)pAlpha);
     rotation = Quaternion.Lerp(Quaternion.Euler(rotation), Quaternion.Euler(t2.rotation), (float)rAlpha).eulerAngles;
 }