コード例 #1
0
        // public method

        #endregion "public method"

        #region "private method"



        private void _OnGUI_IKPanel(CCDSolverMB cp)
        {
            switch (m_panel)
            {
            case EPanel.Normal: break;

            case EPanel.Continuous: break;

            case EPanel.Manual:
            {
                EUtil.DrawSplitter();
                if (GUILayout.Button(CONT_GO, EditorStyles.toolbarButton))
                {
                    var solver = cp.GetSolver();
                    Undo.RecordObjects(solver.GetJoints(), "IK Follow");
                    solver.Execute();
                }
            }
            break;

            case EPanel.Debug:
            {
                EUtil.DrawSplitter();
                _OnGUI_IKPanel_Debug(cp);
            }
            break;

            default:
                Dbg.LogErr("CCDSolverEditor._OnGUI_IKPanel: unexpected panel mode: {0}", m_panel);
                break;
            }
        }
コード例 #2
0
            private float _GetAnimWeight(int idx)
            {
                switch (idx)
                {
                case 0: return(m_Weight0);

                case 1: return(m_Weight1);

                case 2: return(m_Weight2);

                case 3: return(m_Weight3);

                case 4: return(m_Weight4);

                case 5: return(m_Weight5);

                case 6: return(m_Weight6);

                case 7: return(m_Weight7);

                case 8: return(m_Weight8);

                case 9: return(m_Weight9);

                default:
                    Dbg.LogErr("MorphProc._GetAnimWeight: unexpected weight index: {0}", idx);
                    return(0);
                }
            }
コード例 #3
0
            private bool m_IsQuadEdge;  //if not, then this edge is not shown in quad mode

            #endregion "data"

            #region "public method"
            // public method

            public VEdge(VVert v0, VVert v1)
            {
                // init the two verts
                m_VVerts = new VVert[2];
                int cmp = v0.CompareTo(v1);

                if (cmp < 0)
                {
                    m_VVerts[0] = v0;
                    m_VVerts[1] = v1;
                }
                else if (cmp > 0)
                {
                    m_VVerts[0] = v1;
                    m_VVerts[1] = v0;
                }
                else
                {
                    Dbg.LogErr("VEdge.ctor: v0 == v1: {0}, {1}", v0, v1);
                }

                // init the tri cont
                m_TriCont = new RTriCont();

                m_IsQuadEdge = true;
            }
コード例 #4
0
        private Ray _GetProjectRay()
        {
            Vector3 baseDir = Vector3.zero;

            switch (m_projectDir)
            {
            case EAxisD.X: baseDir = Vector3.right; break;

            case EAxisD.Y: baseDir = Vector3.up; break;

            case EAxisD.Z: baseDir = Vector3.forward; break;

            case EAxisD.InvX: baseDir = Vector3.left; break;

            case EAxisD.InvY: baseDir = Vector3.down; break;

            case EAxisD.InvZ: baseDir = Vector3.back; break;

            default: Dbg.LogErr("ShrinkWrap._GetProjectRay: unexpected projectDir: {0}", m_projectDir); break;
            }

            Vector3 dir = baseDir;

            switch (m_ownerSpace)
            {
            case ESpace.Self: dir = m_tr.TransformDirection(baseDir); break;

            case ESpace.World: break;     //do nothing
            }

            Ray r = new Ray(m_tr.position, dir);

            return(r);
        }
コード例 #5
0
            private void _SetAnimWeight(int idx, float w)
            {
                switch (idx)
                {
                case 0: m_Weight0 = w; break;

                case 1: m_Weight1 = w; break;

                case 2: m_Weight2 = w; break;

                case 3: m_Weight3 = w; break;

                case 4: m_Weight4 = w; break;

                case 5: m_Weight5 = w; break;

                case 6: m_Weight6 = w; break;

                case 7: m_Weight7 = w; break;

                case 8: m_Weight8 = w; break;

                case 9: m_Weight9 = w; break;

                default:
                    Dbg.LogErr("MorphProc._SetAnimWeight: unexpected weight index: {0}", idx);
                    break;
                }
            }
コード例 #6
0
        /// <summary>
        /// use prev data to calculate current up dir
        /// </summary>
        private Vector3 _CalcUp(float t, Vector3 prevTan, Vector3 currTan, ref Vector3 prevBaseUp)
        {
            Vector3 currUp = Vector3.zero;

            switch (m_twistMtd)
            {
            case ETwistMethod.YUp:
            {
                Vector3 bino = Vector3.Cross(Vector3.up, currTan);
                currUp = Vector3.Cross(currTan, bino).normalized;
            }
            break;

            case ETwistMethod.Minimum:
            {
                Vector3 prevBino = Vector3.Cross(prevBaseUp, prevTan);
                currUp = Vector3.Cross(currTan, prevBino).normalized;
            }
            break;

            default:
                Dbg.LogErr("CatmullRomUniform._CalcUp: unexpected twistMtd: {0}", m_twistMtd); break;
            }

            if (currUp == Vector3.zero)
            {
                currUp = prevBaseUp;
            }
            prevBaseUp = currUp;

            currUp = ConUtil.ApplyTiltToUp(m_points, t, ref currTan, ref currUp);

            return(currUp);
        }
コード例 #7
0
        public Bounds CalculateTransformedBounds(int maxIter = DEF_ITER_BOUND)
        {
            ISpline spline = Spline;

            if (spline == null)
            {
                Dbg.LogErr("BaseSplineBehaviour.CalculateTransformedBounds: not set spline yet");
                return(new Bounds());
            }

            Bounds bd = new Bounds();

            if (maxIter < 0)
            {
                maxIter = Mathf.Max((spline.PointCount - 1) * 10, 100);
            }

            for (int i = 0; i < maxIter; ++i)
            {
                float   t = (float)i / (float)maxIter;
                Vector3 p = GetTransformedPosition(t);
                bd.Encapsulate(p);
            }

            return(bd);
        }
コード例 #8
0
    private static Material getMaterialIris()
    {
        Material _mat = (Material)Resources.Load("AMIrisShapeMaterial");

        if (!_mat)
        {
            Dbg.LogErr("failed to load AMIrisShapeMaterial!!");
            //_mat = new Material //_Matrix & _TexMatrix is obsoleted since Unity5.0
            //(
            //    "Shader \"Animator/AMIrisShape\" {" +
            //    "Properties {" +
            //    "	_MainTex (\"Base (RGB)\", 2D) = \"white\" {}" +
            //    "	_Mask (\"Culling Mask\", 2D) = \"white\" {}" +
            //    "	_Cutoff (\"Alpha cutoff\", Range (0,1)) = 0.1 " +
            //    "     _Color (\"Main Color\", Color) = (1,1,1,1) }" +
            //    "SubShader {" +
            //    "	Tags {\"Queue\"=\"Background\"}" +
            //    "	Lighting Off" +
            //    "	ZWrite Off" +
            //    "	Blend SrcAlpha OneMinusSrcAlpha" +
            //    "	AlphaTest GEqual [_Cutoff]" +
            //    "	Pass {" +
            //    "		SetTexture [_Mask] { matrix [_Matrix] combine texture }" +
            //    "		SetTexture [_MainTex] { ConstantColor [_Color] matrix[_TexMatrix] combine texture * constant, previous }" +
            //    "	}" +
            //    "}}"
            //);
        }
        return(_mat);
    }
コード例 #9
0
ファイル: Floor.cs プロジェクト: arslanarshad31/SpeechToSign
        /// <summary>
        /// calculate the normal vector of the plane,
        /// account for the useRotation, ePlaneDir
        /// </summary>
        private Vector3 _GetNormal()
        {
            Vector3 n = Vector3.up;

            switch (m_ePlaneDir)
            {
            case EAxisD.X: n = Vector3.right; break;

            case EAxisD.Y: n = Vector3.up; break;

            case EAxisD.Z: n = Vector3.forward; break;

            case EAxisD.InvX: n = Vector3.left; break;

            case EAxisD.InvY: n = Vector3.down; break;

            case EAxisD.InvZ: n = Vector3.back; break;

            default: Dbg.LogErr("Floor._GetNormal: unexpected EAxisD: {0}", m_ePlaneDir); break;
            }

            if (m_useRotation)
            {
                n = m_target.rotation * n;
            }

            return(n.normalized);
        }
コード例 #10
0
ファイル: Dbg.cs プロジェクト: arslanarshad31/SpeechToSign
    public static void Assert <T1, T2, T3, T4, T5>(bool cond, string fmt, T1 par1, T2 par2, T3 par3, T4 par4, T5 par5)
    {
        if (cond)
        {
            return;
        }

        Dbg.LogErr(fmt, par1, par2, par3, par4, par5);
    }
コード例 #11
0
ファイル: Dbg.cs プロジェクト: arslanarshad31/SpeechToSign
    public static void Assert <T1, T2, T3>(bool cond, string fmt, T1 par1, T2 par2, T3 par3)
    {
        if (cond)
        {
            return;
        }

        Dbg.LogErr(fmt, par1, par2, par3);
    }
コード例 #12
0
ファイル: Dbg.cs プロジェクト: arslanarshad31/SpeechToSign
    public static void Assert <T1>(bool cond, T1 msg)
    {
        if (cond)
        {
            return;
        }

        Dbg.LogErr(msg);
    }
コード例 #13
0
ファイル: Dbg.cs プロジェクト: arslanarshad31/SpeechToSign
    public static void Assert <T1>(bool cond, string fmt, T1 par1)
    {
        if (cond)
        {
            return;
        }

        Dbg.LogErr(fmt, par1);
    }
コード例 #14
0
        public static void PrefGUI()
        {
            if (!m_isLoaded)
            {
                _LoadPrefs();
            }

            EditorGUILayout.BeginHorizontal();
            {
                EUtil.PushGUIEnable(m_selectProduct != SelectProd.CAT);
                if (GUILayout.Button(new GUIContent("Character Animation Tools", "Bone Animation, Vertex animation, animation export, and all other tools"),
                                     EditorStyles.toolbarButton))
                {
                    m_selectProduct = SelectProd.CAT;
                }
                EUtil.PopGUIEnable();

                EUtil.PushGUIEnable(m_selectProduct != SelectProd.ImmConsole);
                if (GUILayout.Button(new GUIContent("Immediate Console", "Execute C# snippets immediately in edit-mode & game-mode"),
                                     EditorStyles.toolbarButton))
                {
                    m_selectProduct = SelectProd.ImmConsole;
                }
                EUtil.PopGUIEnable();
            }
            EditorGUILayout.EndHorizontal();

            switch (m_selectProduct)
            {
            case SelectProd.CAT:
            {
                _GUI_CAT();
            }
            break;

            case SelectProd.ImmConsole:
            {
                _GUI_ImmConsole();
            }
            break;

            case SelectProd.None:
            {
                _GUI_None();
            }
            break;

            default:
                Dbg.LogErr("Pref.PrefGUI: unexpected selected product: {0}", m_selectProduct);
                break;
            }
        }
コード例 #15
0
        private Vector3 _GetSourceData()
        {
            switch (m_srcDataType)
            {
            case ETransformData.Position: return(m_target.GetPosition(m_targetSpace));

            case ETransformData.Rotation: return(m_target.GetEuler(m_targetSpace));

            case ETransformData.Scale: return(m_target.GetScale(m_targetSpace));

            default: Dbg.LogErr("TransformMapping._GetSourceData: unexpected srcDataType: {0}", m_srcDataType); return(Vector3.zero);
            }
        }
コード例 #16
0
        //public override void DoDrawGizmos()
        //{
        //    base.DoDrawGizmos();
        //}

        #endregion "public method"

        #region "private method"

        private void _SetDestinationData(Vector3 dstData)
        {
            switch (m_dstDataType)
            {
            case ETransformData.Position: m_tr.SetPosition(dstData, m_ownerSpace); break;

            case ETransformData.Rotation: m_tr.SetEuler(dstData, m_ownerSpace); break;

            case ETransformData.Scale: m_tr.SetScale(dstData, m_ownerSpace); break;

            default: Dbg.LogErr("TransformMapping._SetDestinationData: unexpected dstDataType: {0}", m_dstDataType); break;
            }
        }
コード例 #17
0
 /// <summary>
 /// if not found, return negative value
 /// </summary>
 public static float GetTimeByTag(CutsceneController cc, string tag)
 {
     for (int idx = 0; idx < cc.m_TimeTags.Count; ++idx)
     {
         TimeTag t = cc.m_TimeTags[idx];
         if (t.m_Name == tag)
         {
             return(t.m_Time);
         }
     }
     Dbg.LogErr("CutsceneController.GetTimeByTag: failed to find tag: {0}", tag);
     return(float.NegativeInfinity);
 }
コード例 #18
0
        private Vector3 _GetDestData()
        {
            switch (m_dstDataType)
            {
            case ETransformData.Position: return(m_tr.GetPosition(m_ownerSpace));

            case ETransformData.Rotation: return(m_tr.GetEuler(m_ownerSpace));

            case ETransformData.Scale: return(m_tr.GetScale(m_ownerSpace));

            default: Dbg.LogErr("TransformMapping._GetDestData: unexpected DstDataType: {0}", m_dstDataType); return(Vector3.zero);
            }
        }
コード例 #19
0
        private void _SetDimensionByBounds(ClampTo cp, Bounds bd)
        {
            switch (cp.MainAxis)
            {
            case EAxis.X: cp.Dimension = bd.size.x; cp.StartVal = bd.min.x; break;

            case EAxis.Y: cp.Dimension = bd.size.y; cp.StartVal = bd.min.y; break;

            case EAxis.Z: cp.Dimension = bd.size.z; cp.StartVal = bd.min.z; break;

            default: Dbg.LogErr("ClampToEditor._SetDimensionByBounds: unexpected mainAxis: {0}", cp.MainAxis); break;
            }
        }
コード例 #20
0
            /// <summary>
            /// assume the rTriIdx is not degraded
            /// </summary>
            public VFace GetVFaceFromRTri(int rTriIdx)
            {
                VFace vf = null;

                if (m_VFaceCont.TryGetValue(rTriIdx, out vf))
                {
                    return(vf);
                }
                else
                {
                    Dbg.LogErr("VMesh.GetVFaceFromRTri: the rTriIdx is not found in m_VFaceCont, {0}", rTriIdx);
                    return(null);
                }
            }
コード例 #21
0
            public VEdge CheckedGetVEdge(VVert rhs)
            {
                for (int i = 0; i < m_veLst.Count; ++i)
                {
                    VEdge e = m_veLst[i];
                    if (e.Contains(rhs))
                    {
                        return(e);
                    }
                }

                Dbg.LogErr("VVerts.CheckedGetVEdge: failed to find an edge for: {0}=>{1}", this, rhs);
                return(null);
            }
コード例 #22
0
        public Vector3 GetPosition(float t)
        {
            ISpline sp = Spline;

            if (sp == null)
            {
                Dbg.LogErr("BaseSplineBehaviour.GetPosition: not set spline yet");
                return(Vector3.zero);
            }

            Dbg.Assert(0 <= t && t <= 1, "BaseSplineBehaviour.GetPosition: t beyond range: {0}", t);

            Vector3 pos = sp.Interp(t);

            return(pos);
        }
コード例 #23
0
        public Vector3 GetTangent(float t)
        {
            ISpline sp = Spline;

            if (sp == null)
            {
                Dbg.LogErr("BaseSplineBehaviour.GetTangent: not set spline yet");
                return(Vector3.zero);
            }

            Dbg.Assert(0 <= t && t <= 1, "BaseSplineBehaviour.GetTangent: t beyond range: {0}", t);

            Vector3 tan = sp.Tangent(t);

            return(tan);
        }
コード例 #24
0
        public Vector3 GetUp(float t)
        {
            ISpline sp = Spline;

            if (sp == null)
            {
                Dbg.LogErr("BaseSplineBehaviour.GetUp: not set spline yet");
                return(Vector3.zero);
            }

            Dbg.Assert(0 <= t && t <= 1, "BaseSplineBehaviour.GetUp: t beyond range: {0}", t);

            Vector3 up = sp.Up(t);

            return(up);
        }
コード例 #25
0
        public override void Apply(ISolver solver, int jointIdx)
        {
            if (m_nextJoint == null)
            {
                Dbg.CLogWarn(this, "AngleConstraintMB.Apply: nextJoint not set");
                return;
            }

            if (jointIdx == solver.Count)
            {
                return; //if no child joint, cannot apply angle constraint
            }
            var       joints = solver.GetJoints();
            Transform j      = joints[jointIdx];

            if (m_rotAxis == Vector3.zero)
            {
                Dbg.LogErr("AngleConstraintMB.Apply: the axis is zero vector");
                return;
            }
            if (m_minLimit > m_maxLimit)
            {
                Misc.Swap(ref m_minLimit, ref m_maxLimit);
            }

            Transform nextJ        = joints[jointIdx + 1];
            Transform parentJ      = j.parent; //THIS could be NULL, use Misc.TransformDirectoin/InverseTransformDirection
            Vector3   jpos         = j.position;
            Vector3   nextJpos     = nextJ.position;
            Vector3   rotAxisWorld = Misc.TransformDirection(parentJ, m_rotAxis); //axis convert from parentSpace to worldSpace

            // project to the rotation plane
            Vector3 diff0         = nextJpos - jpos;                             //world space
            Vector3 projDiff      = Vector3.ProjectOnPlane(diff0, rotAxisWorld); //world space
            Vector3 worldPrimAxis = Misc.TransformDirection(parentJ, m_primAxis);

            float angle = Misc.ToAngleAxis(worldPrimAxis, projDiff, rotAxisWorld);

            if (angle < m_minLimit || m_maxLimit < angle)
            { //need clamp
                angle = Mathf.Clamp(angle, m_minLimit, m_maxLimit);
            }

            j.localRotation = Quaternion.AngleAxis(angle, m_rotAxis) * m_startLocalRot; //local
        }
コード例 #26
0
        public bool Calc(float t, out Vector3 pos, out Vector3 tan, out Vector3 up)
        {
            pos = Vector3.zero;
            tan = Vector3.forward;
            up  = Vector3.up;

            ISpline sp = Spline;

            if (sp == null)
            {
                Dbg.LogErr("BaseSplineBehaviour.Calc: not set spline yet");
                return(false);
            }

            Dbg.Assert(0 <= t && t <= 1, "BaseSplineBehaviour.GetUp: t beyond range: {0}", t);

            sp.Calc(t, out pos, out tan, out up);
            return(true);
        }
コード例 #27
0
    private static void _ExecuteEndAction(CutsceneController cc)
    {
        switch (cc.m_EndAction)
        {
        case EndAction.Destroy:
        {
            GameObject.Destroy(cc.gameObject);
        }
        break;

        case EndAction.Deactivate:
        {
            cc.gameObject.SetActive(false);
        }
        break;

        default:
            Dbg.LogErr("CutsceneController._OnAnimStoppedChange: unexpected EndAction: {0}", cc.m_EndAction);
            break;
        }
    }
コード例 #28
0
            public void SetMorphAt(int idx, ShapeKeyMorphSO shape)
            {
                Dbg.Assert(m_Deforms != null, "SetMorphAt: m_Deforms == null");

                if (idx < m_Deforms.Count)
                {
                    m_Deforms[idx] = shape;
                }
                else if (idx == m_Deforms.Count)
                {
                    m_Deforms.Add(shape);
                }
                else if (idx >= MAX_SHAPEKEY_CNT)
                {
                    Dbg.LogErr("MorphProc.SetMorphAt: current only support up to 10 shape keys");
                }
                else
                {
                    Dbg.LogErr("MorphProc.SetMorphAt: idx beyond range: {0}, {1}", idx, m_Deforms.Count);
                }
            }
コード例 #29
0
        public Bounds CalculateBounds(int maxIter = DEF_ITER_BOUND)
        {
            ISpline spline = Spline;

            if (spline == null)
            {
                Dbg.LogErr("BaseSplineBehaviour.CalculateBounds: not set spline yet");
                return(new Bounds());
            }

            Bounds bd = new Bounds();

            for (int i = 0; i < maxIter; ++i)
            {
                float   t = (float)i / (float)maxIter;
                Vector3 p = GetPosition(t);
                bd.Encapsulate(p);
            }

            return(bd);
        }
コード例 #30
0
        /// <summary>
        /// ensure the a0 & a1 not on same axis;
        ///
        /// return the modified value for a1
        /// </summary>
        public static EAxisD EnsureAxisNotColinear(EAxisD a0, EAxisD a1)
        {
            if (a0 != a1 && ((int)a0 << 3) != (int)a1 && ((int)a1 << 3) != (int)a0)
            {
                return(a1); //good
            }
            if (a1 != EAxisD.X && a1 != EAxisD.InvX)
            {
                return(EAxisD.X);
            }
            if (a1 != EAxisD.Y && a1 != EAxisD.InvY)
            {
                return(EAxisD.Y);
            }
            if (a1 != EAxisD.Z && a1 != EAxisD.InvZ)
            {
                return(EAxisD.Z);
            }

            Dbg.LogErr("EnsureAxisNotColinear: error: {0}, {1}", a0, a1);
            return(0);
        }