コード例 #1
0
        /*! \cond PRIVATE */

        void getInterpolatedSourcePosition(CurvySplineBase spline, float tf, out Vector3 position, out Vector3 tangent, out Vector3 up)
        {
            if (spline.Length == 0)
            {
                position = spline.transform.localPosition;
                tangent  = Vector3.forward;
                up       = Vector3.up;
            }
            else
            {
                if (UseCache)
                {
                    position = spline.InterpolateFast(tf);
                    tangent  = spline.GetTangentFast(tf);
                }
                else
                {
                    position = spline.Interpolate(tf);
                    tangent  = spline.GetTangent(tf, position);
                }
                up = spline.GetOrientationUpFast(tf);
            }
            if (Space == Space.World)
            {
                position = spline.transform.TransformPoint(position);
                tangent  = spline.transform.TransformDirection(tangent);
                up       = spline.transform.TransformDirection(up);
            }
        }
コード例 #2
0
ファイル: CurvyUtility.cs プロジェクト: shaunvxc/Infamy
        public CurvyMeshSegmentInfo(SplinePathMeshBuilder mb, float tf, float distance, Vector3 scale)
        {
            Target = mb.Spline;
            TF = tf;
            mDistance = distance;

            Vector3 p = (mb.FastInterpolation) ? Target.InterpolateFast(TF) : Target.Interpolate(TF);

            if (mb.UseWorldPosition)
                Matrix = Matrix4x4.TRS(mb.Transform.InverseTransformPoint(p), Target.GetOrientationFast(TF), scale);
            else
                Matrix = Matrix4x4.TRS(Target.Transform.InverseTransformPoint(p), Target.GetOrientationFast(TF), scale);
        }
コード例 #3
0
ファイル: Obsolete.cs プロジェクト: scumbly/Organ-Grinder
    public CurvyMeshSegmentInfo(SplinePathMeshBuilder mb, float tf, float distance, Vector3 scale)
    {
        Target    = mb.Spline;
        TF        = tf;
        mDistance = distance;

        Vector3 p = (mb.FastInterpolation) ? Target.InterpolateFast(TF) : Target.Interpolate(TF);

        if (mb.UseWorldPosition)
        {
            Matrix = Matrix4x4.TRS(mb.Transform.InverseTransformPoint(p), Target.GetOrientationFast(TF), scale);
        }
        else
        {
            Matrix = Matrix4x4.TRS(Target.transform.InverseTransformPoint(p), Target.GetOrientationFast(TF), scale);
        }
    }
コード例 #4
0
        /*! \cond PRIVATE */

        void getInterpolatedSourcePosition(CurvySplineBase spline,float tf, out Vector3 position, out Vector3 tangent, out Vector3 up)
        {
            if (UseCache)
            {
                position = spline.InterpolateFast(tf);
                tangent = spline.GetTangentFast(tf);
            }
            else
            {
                position = spline.Interpolate(tf);
                tangent = spline.GetTangent(tf, position);
            }
            up = spline.GetOrientationUpFast(tf);
            if (Space == Space.World)
            {
                position = spline.transform.TransformPoint(position);
                tangent = spline.transform.TransformDirection(tangent);
                up = spline.transform.TransformDirection(up);
            }
        }
コード例 #5
0
        void DoInterpolate()
        {
            if (!mSpline.IsInitialized)
            {
                return;
            }
            System.Type metaType = System.Type.GetType(MetaDataType.Value);
            bool        calc     = !Input.IsNone;

            if (calc)
            {
                float f = (UseWorldUnits.Value) ? mSpline.DistanceToTF(Input.Value) : Input.Value;

                if (StorePosition.UseVariable)
                {
                    StorePosition.Value = (UseCache.Value) ? mSpline.InterpolateFast(f) : mSpline.Interpolate(f);
                }

                if (StoreTangent.UseVariable)
                {
                    StoreTangent.Value = mSpline.GetTangent(f);
                }

                if (StoreUpVector.UseVariable)
                {
                    StoreUpVector.Value = mSpline.GetOrientationUpFast(f);
                }

                if (StoreRotation.UseVariable)
                {
                    StoreRotation.Value = (StoreUpVector.IsNone) ? mSpline.GetOrientationFast(f) : Quaternion.LookRotation(mSpline.GetTangent(f), StoreUpVector.Value);
                }

                if (StoreScale.UseVariable)
                {
                    StoreScale.Value = mSpline.InterpolateScale(f);
                }

                if (StoreTF.UseVariable)
                {
                    StoreTF.Value = f;
                }

                if (StoreDistance.UseVariable)
                {
                    StoreDistance.Value = (UseWorldUnits.Value) ? Input.Value : mSpline.TFToDistance(f);
                }
                if (metaType != null)
                {
                    if (StoreMetadata.UseVariable)
                    {
                        StoreMetadata.Value = mSpline.GetMetadata(metaType, f);
                    }
                    if (StoreInterpolatedMetadata.useVariable)
                    {
                        StoreInterpolatedMetadata.SetValue(mSpline.InterpolateMetadata(metaType, f));
                    }
                }


                CurvySplineSegment seg = null;
                float segF             = 0;
                if (StoreSegment.UseVariable)
                {
                    seg = getSegment(f, out segF);
                    StoreSegment.Value = seg.gameObject;
                }

                if (StoreSegmentF.UseVariable)
                {
                    if (!seg)
                    {
                        seg = getSegment(f, out segF);
                    }
                    StoreSegmentF.Value = segF;
                }

                if (StoreSegmentDistance.UseVariable)
                {
                    if (!seg)
                    {
                        seg = getSegment(f, out segF);
                    }
                    StoreSegmentDistance.Value = seg.LocalFToDistance(segF);
                }
            }
            // General
            if (StoreLength.UseVariable)
            {
                StoreLength.Value = mSpline.Length;
            }

            if (StoreCount.UseVariable)
            {
                StoreCount.Value = (mSpline is CurvySplineGroup) ? ((CurvySplineGroup)mSpline).Count : ((CurvySpline)mSpline).Count;
            }
        }