Esempio n. 1
0
 void OnDrawGizmosSelected()
 {
     if (isInitialized && nodes.Count > 0)
     {
         VisualClass.DrawPath(nodes.ToArray(), Color.green);
     }
 }
Esempio n. 2
0
 //设置Target初始状态
 private void GetInitialState()
 {
     _target.nodes[0]        = _target.transform.position;
     _target.rotationList[0] = _target.transform.eulerAngles;
     if (_target.isCamera && _target.camera != null)
     {
         _target.cameraViewList[0] = _target.CameraView;
         if (_target.isLookAt && _target.lookAt != null)
         {
             _target.diffVector[0] = _target.transform.eulerAngles;
             GameObject cameraEmpty = new GameObject();
             cameraEmpty.name = "CameraEmpty";
             Vector3[] controlPoint = VisualClass.PathControlPointGenerator(_target.nodes.ToArray());
             cameraEmpty.transform.position = VisualClass.Interp(controlPoint, 0.1f);
             cameraEmpty.transform.LookAt(_target.lookAt);
             _target.diffVector[1] = cameraEmpty.transform.eulerAngles;
             _target.diffVector[1] = new Vector3(AngleClerp(_target.diffVector[0].x, _target.diffVector[1].x, 1f), AngleClerp(_target.diffVector[0].y, _target.diffVector[1].y, 1f), AngleClerp(_target.diffVector[0].z, _target.diffVector[1].z, 1f));
             float diff = (_target.diffVector[1] - _target.diffVector[0]).magnitude;
             if (diff > 0.1f)
             {
                 _target.needExcess = true;
             }
             else
             {
                 _target.needExcess = false;
             }
             //Debug.Log(diff);
             //Debug.Log(_target.diffVector[1].x + "," + _target.diffVector[1].y + ", " + _target.diffVector[1].z);
             //Debug.Log(_target.diffVector[0].x + "," + _target.diffVector[0].y + ", " + _target.diffVector[0].z);
             DestroyImmediate(cameraEmpty);
         }
     }
 }
Esempio n. 3
0
 public static extern Status XMatchVisualInfo
 (
     DisplayPtr display,
     int screen,
     int depth,
     VisualClass visualClass,
     out XVisualInfo vinfo_return
 );
Esempio n. 4
0
 void OnDrawGizmosSelected()
 {
     if (pathVisible)
     {
         if (nodes.Count > 0)
         {
             VisualClass.DrawPath(nodes.ToArray(), pathColor);
         }
     }
 }
Esempio n. 5
0
 public void MotionActive()
 {
     if (!moveFlag)
     {
         controlPoint = VisualClass.PathControlPointGenerator(nodes.ToArray());
         TimeRateGenerator(nodeCount);
         Debug.Log("Point Number: " + controlPoint.Length);
         totalTime = VisualClass.TimeGet(controlPoint, moveSpeed);
         Debug.Log("Time: " + totalTime);
         endTime  = 0.0f;
         moveFlag = true;
     }
 }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        //if (Input.GetKeyDown(KeyCode.Q))
        //{
        //	controlPoint = VisualClass.PathControlPointGenerator(nodes.ToArray());
        //	Debug.Log("Point Number: " + controlPoint.Length);
        //}

        //if (Input.GetKeyDown(KeyCode.T))
        //{
        //	totalTime = VisualClass.TimeGet(controlPoint, 1f);
        //	Debug.Log("Time: " + totalTime);
        //}

        //if (Input.GetKeyDown(KeyCode.S))
        //{
        //	endTime = 0.0f;
        //	moveFlag = true;
        //}

        if (moveFlag)
        {
            endTime += Time.deltaTime;
        }

        if (moveFlag && endTime >= totalTime)
        {
            moveFlag = false;
            VisualClass.TestMove(controlPoint, transform, 1f);
            if (camera != null)
            {
                CameraView = cameraViewList[cameraViewList.Count - 1];
            }
            if (isCamera && isLookAt && lookAt != null)
            {
                transform.LookAt(lookAt);
            }
            else
            {
                transform.eulerAngles = rotationList[rotationList.Count - 1];
            }
        }
    }
Esempio n. 7
0
 void LateUpdate()
 {
     if (moveFlag)
     {
         VisualClass.TestMove(controlPoint, transform, endTime / totalTime);
         if (isCamera && camera != null)              //摄像机
         {
             if (isLookAt && lookAt != null)          //有中心物体
             {
                 if (needExcess)
                 {
                     if (endTime / totalTime < 0.1f)
                     {
                         transform.eulerAngles = Vector3.Lerp(diffVector[0], diffVector[1], endTime / totalTime * 10f);
                     }
                     else
                     {
                         transform.LookAt(lookAt);
                     }
                 }
                 else
                 {
                     transform.LookAt(lookAt);
                 }
                 CameraView = ViewLerp(endTime / totalTime);
             }
             else                  //无中心物体
             {
                 transform.eulerAngles = EulerAngleLerp(endTime / totalTime, ref currentIndex, ref currentTimeRate);
                 //二分法查找算一次
                 CameraView = Mathf.Lerp(cameraViewList[currentIndex], cameraViewList[currentIndex + 1], currentTimeRate);
             }
         }
         else               //普通物体运动
         {
             transform.eulerAngles = EulerAngleLerp(endTime / totalTime, ref currentIndex, ref currentTimeRate);
         }
     }
 }
Esempio n. 8
0
 //场景Target状态插值
 public void SceneInterp(float current_value)
 {
     Vector3[] tempPoints = VisualClass.PathControlPointGenerator(nodes.ToArray());
     TimeRateGenerator(nodeCount);
     VisualClass.TestMove(tempPoints, transform, current_value);
     if (isCamera && camera != null)          //摄像机
     {
         if (isLookAt && lookAt != null)      //有中心物体
         {
             if (needExcess)
             {
                 if (current_value < 0.1f)
                 {
                     transform.eulerAngles = Vector3.Lerp(diffVector[0], diffVector[1], current_value * 10f);
                 }
                 else
                 {
                     transform.LookAt(lookAt);
                 }
             }
             else
             {
                 transform.LookAt(lookAt);
             }
             CameraView = ViewLerp(current_value);
         }
         else              //无中心物体
         {
             transform.eulerAngles = EulerAngleLerp(current_value, ref currentIndex, ref currentTimeRate);
             //二分法查找算一次
             CameraView = Mathf.Lerp(cameraViewList[currentIndex], cameraViewList[currentIndex + 1], currentTimeRate);
         }
     }
     else           //普通物体运动
     {
         transform.eulerAngles = EulerAngleLerp(current_value, ref currentIndex, ref currentTimeRate);
     }
 }