Example #1
0
        void LateUpdate()
        {
            if (!m_Inited || m_FollowTargetTrans == null)
            {
                return;
            }

            m_FollowTargetPos = m_FollowTargetTrans.TransformPoint(m_FollowTargetOffset);

            Vector3 offset = m_ExpectedOffset;
            bool    avoid  = AvoidObstruction(ref offset);

            if (followDumpping.Used)
            {
                Vector3 currOffset = transform.position - m_FollowTargetPos;
                if (CocoMath.Approximately(currOffset, offset, 0.0001f))
                {
                    return;
                }

                float t = followDumpping.Value * Time.deltaTime;
                offset = !avoid?Vector3.Slerp(currOffset, offset, t) : Vector3.Lerp(currOffset, offset, t);
            }

            transform.position = m_FollowTargetPos + offset;
            transform.LookAt(m_FollowTargetPos);

            if (OnMoveEvent != null)
            {
                OnMoveEvent(this);
            }
        }
Example #2
0
 public void ApplyToTransform(Transform trans)
 {
     if (IsLocal)
     {
         trans.localPosition    = Position;
         trans.localEulerAngles = EulerAngles;
         trans.localScale       = Scale;
     }
     else
     {
         trans.position    = Position;
         trans.eulerAngles = EulerAngles;
         trans.localScale  = Vector3.Scale(Scale, CocoMath.Divide(trans.localScale, trans.lossyScale));
     }
 }
Example #3
0
 public static void ApplyTransform(Transform fromTrans, Transform toTrans, bool isLocal)
 {
     if (isLocal)
     {
         toTrans.localPosition = fromTrans.localPosition;
         toTrans.localRotation = fromTrans.localRotation;
         toTrans.localScale    = fromTrans.localScale;
     }
     else
     {
         toTrans.position   = fromTrans.position;
         toTrans.rotation   = fromTrans.rotation;
         toTrans.localScale = Vector3.Scale(fromTrans.lossyScale, CocoMath.Divide(toTrans.localScale, toTrans.lossyScale));
     }
 }
Example #4
0
        private static RenderTexture RetainRenderTexture(ref Rect captureRect, Camera camera, float scaleFactor, TextureFormat textureFormat, int antiAliasing)
        {
            // rt format
            RenderTextureFormat rtFormat;

            switch (textureFormat)
            {
            case TextureFormat.ARGB32:
            case TextureFormat.RGBA32:
            case TextureFormat.RGB24:
                rtFormat = RenderTextureFormat.ARGB32;
                break;

            case TextureFormat.RGBAFloat:
                rtFormat = RenderTextureFormat.ARGBFloat;
                break;

            case TextureFormat.RGBAHalf:
                rtFormat = RenderTextureFormat.ARGBHalf;
                break;

            default:
                Debug.LogErrorFormat("CocoShot->CaptureScreenshot: texture format [{0}] NOT supported!", textureFormat);
                return(null);
            }

            var rtWidth  = camera.pixelWidth;
            var rtHeight = camera.pixelHeight;

            if (!Mathf.Approximately(scaleFactor, 1.0f))
            {
                rtWidth  = Mathf.RoundToInt(rtWidth * scaleFactor);
                rtHeight = Mathf.RoundToInt(rtHeight * scaleFactor);

                captureRect = CocoMath.Scale(captureRect, scaleFactor);
            }
            captureRect = CocoMath.Round(captureRect);
            //Debug.LogError (captureRect + ", (" + rtWidth + ", " + rtHeight + ")");

            return(RenderTexture.GetTemporary(rtWidth, rtHeight, 24, rtFormat, RenderTextureReadWrite.Default, antiAliasing));
        }
Example #5
0
 protected override bool IsNonNullDifferent(Vector3 value1, Vector3 value2)
 {
     return(!CocoMath.Approximately(value1, value2, m_ErrorRange));
 }