示例#1
0
 /// <summary>
 /// Add torque (force in terms of rotation)
 /// </summary>
 public void AddTorque(Euler4 torque)
 {
     if (isActiveAndEnabled)
     {
         body.ApplyTorque(torque);
     }
 }
示例#2
0
        private string Euler4()
        {
            int    val1, val2;
            Euler4 e4     = new Euler4();
            int    result = e4.FindPalidromes(3, out val1, out val2);

            return(result.ToString());
        }
示例#3
0
 static void SetAnimation(Viewer4 v, Euler4 t)
 {
     _fromR   = v.transform4.rotation.ToEuler();
     _time    = EditorApplication.timeSinceStartup;
     _targetR = t;
     _viewer  = v;
     EditorApplication.update += TransformViewerR;
 }
示例#4
0
        static void TransformViewerR()
        {
            var d = 1 - InverseLerp(_time, _time + 0.4, EditorApplication.timeSinceStartup);

            _viewer.transform4.rotation = Matrix4.Euler(Euler4.LerpAngle(_fromR, _targetR, 1 - d * d));

            if (d <= 0)
            {
                // Accuracy issue
                _viewer.transform4.rotation = Matrix4.Euler(_fromR);
                _viewer.transform4.rotation = Matrix4.Euler(_targetR);
                EditorApplication.update   -= TransformViewerR;
            }
        }
示例#5
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (!IsToEuler())
            {
                EditorGUI.BeginProperty(position, label, property);
                position.height = 16;

                var child = property.FindPropertyRelative("ex");
                do
                {
                    EditorGUI.PropertyField(position, child, child.name == "ex" ? label : new GUIContent(" "));
                    position.y += 16;

                    if (child.name == "ew")
                    {
                        break;
                    }
                } while (child.Next(false));

                EditorGUI.EndProperty();
                return;
            }

            var tr = property.GetValue <Matrix4>();

            if (_matrix != tr)
            {
                _matrix = tr;
                _euler  = tr.ToEuler();
            }

            if (!EditorGUIUtility.wideMode)
            {
                EditorGUIUtility.labelWidth /= 2f;
            }
            position = EditorGUI.PrefixLabel(position, label);

            EditorGUI.BeginProperty(position, label, property);
            EditorGUI.showMixedValue = property.hasMultipleDifferentValues;
            EditorGUI.BeginChangeCheck();

            PropertyEuler(position);

            if (EditorGUI.EndChangeCheck())
            {
                var m = Matrix4.Euler(_euler);
                // Should there be a better way?
                property.FindPropertyRelative("ex.x").floatValue = m.ex.x;
                property.FindPropertyRelative("ex.y").floatValue = m.ex.y;
                property.FindPropertyRelative("ex.z").floatValue = m.ex.z;
                property.FindPropertyRelative("ex.w").floatValue = m.ex.w;
                property.FindPropertyRelative("ey.x").floatValue = m.ey.x;
                property.FindPropertyRelative("ey.y").floatValue = m.ey.y;
                property.FindPropertyRelative("ey.z").floatValue = m.ey.z;
                property.FindPropertyRelative("ey.w").floatValue = m.ey.w;
                property.FindPropertyRelative("ez.x").floatValue = m.ez.x;
                property.FindPropertyRelative("ez.y").floatValue = m.ez.y;
                property.FindPropertyRelative("ez.z").floatValue = m.ez.z;
                property.FindPropertyRelative("ez.w").floatValue = m.ez.w;
                property.FindPropertyRelative("ew.x").floatValue = m.ew.x;
                property.FindPropertyRelative("ew.y").floatValue = m.ew.y;
                property.FindPropertyRelative("ew.z").floatValue = m.ew.z;
                property.FindPropertyRelative("ew.w").floatValue = m.ew.w;
            }

            EditorGUI.showMixedValue = false;
            EditorGUI.EndProperty();
            if (!EditorGUIUtility.wideMode)
            {
                EditorGUIUtility.labelWidth *= 2f;
            }
        }