示例#1
0
    void FixedUpdate()
    {
        if (Status.IsReviewing)
        {
            //this option is when review the camera trace
            //TODO:first get the current frame camera motion, then translate to there.
            if (Status.CurrentFrameNum <= Status.TotalFrameNum)
            {
                //cameraMotionKeyframe = cameraFrameData[Status.CurrentFrameNum - 1].ToString();
                cameraMotionKeyframe = cameraFrameData[Status.CurrentFrameNum - 1];
                //display the camera motion key frame data;
                CameraInfoText.text = cameraMotionKeyframe;
                //parse cameraMotionKeyframe
                brokenString = cameraMotionKeyframe.Split(splitIdentifier);


                transform.position = new Vector3(System.Convert.ToSingle(brokenString[2]),
                                                 System.Convert.ToSingle(brokenString[3]),
                                                 System.Convert.ToSingle(brokenString[4]));
                transform.rotation = new Quaternion(System.Convert.ToSingle(brokenString[5]),
                                                    System.Convert.ToSingle(brokenString[6]),
                                                    System.Convert.ToSingle(brokenString[7]),
                                                    System.Convert.ToSingle(brokenString[8]));
                transform.GetComponent <Camera>().fieldOfView = System.Convert.ToSingle(brokenString[9]);
                Status.CurrentFrameNum = Status.CurrentFrameNum + 1;
            }
        }
        else
        {
            //use the gyroscope and joystick to control the camera motion
            //camera rotation
            if (isGyro)
            {
                transform.Rotate(initialOrientation - Input.gyro.rotationRateUnbiased);
            }


            cameraTranslateVector.x = joystick.position.x;                      //left&right
            cameraTranslateVector.z = joystick.position.y;                      //front back
            cameraTranslateVector.y = (UpAndDown.value - 0.5f) * 2f;            //up down

            transform.Translate(cameraTranslateVector * moveSpeed * Time.fixedDeltaTime, Space.Self);


            //then recoding the data.
            //TODO: not like maya, in Unity3d the coordinate is left-hand.
            //TODO: if we drag the slider, we should reset the frame
            cameraMotionKeyframe = "camera" + ";" + Status.CurrentFrameNum + ";" +                                                                                      //frame number
                                   transform.position.x + ";" + transform.position.y + ";" + transform.position.z + ";" +                                               //position
                                   transform.rotation.x + ";" + transform.rotation.y + ";" + transform.rotation.z + ";" + transform.rotation.w + ";" +                  //rotation
                                   transform.GetComponent <Camera>().fieldOfView + "\n";
            //display current camera information on the screen
            CameraInfoText.text = cameraMotionKeyframe;

            //if is connected to server send the camera info text to server synchronized
            if (Setting.connected)
            {
                client.SendData(cameraMotionKeyframe);
            }

            if (Status.IsRecording)
            {
                if (Status.CurrentFrameNum <= Status.TotalFrameNum)
                {                       //if the frame number is small than the total number , replace the arrylist
                    cameraFrameData[Status.CurrentFrameNum - 1] = cameraMotionKeyframe;
                }
                else                    //else add to the arraylist
                {
                    cameraFrameData.Add(cameraMotionKeyframe);
                }
                Status.CurrentFrameNum = Status.CurrentFrameNum + 1;
            }
            else
            {
                Status.TotalFrameNum = cameraFrameData.Count;
            }

            if (Status.IsClearRecord)
            {
                //TODO: if clear the former recorded data
                //ResetRecord();
                cameraFrameData.Clear();
            }
        }
    }
示例#2
0
 public void SendMsgToServer()
 {
     client.SendData(sendCmdInput.text);
 }