Beispiel #1
0
        protected TR DestinationInitialCoords(ObjectSpace space)
        {
            switch (space)
            {
            case ObjectSpace.model:
                if (m_dst == null)
                {
                    return(new TR(ModelRoot.rotation, transform.position));
                }
                else
                {
                    var r = (TR.FromParent(ModelRoot) * m_dst.ModelInitial).Rotation;
                    var t = (TR.FromParent(transform) * m_dst.LocalInitial).Translation;
                    return(new TR(r, t));
                }

            case ObjectSpace.local:
                if (m_dst == null)
                {
                    return(TR.FromWorld(transform));
                }
                else
                {
                    return(TR.FromParent(transform) * m_dst.LocalInitial);
                }

            default:
                throw new NotImplementedException();
            }
        }
Beispiel #2
0
        protected TR SourceInitialCoords(ObjectSpace space)
        {
            switch (space)
            {
            case ObjectSpace.model:
                if (m_src == null)
                {
                    return(new TR(ModelRoot.rotation, Source.position));
                }
                else
                {
                    var r = (TR.FromParent(ModelRoot) * m_src.ModelInitial).Rotation;
                    var t = (TR.FromParent(Source) * m_src.LocalInitial).Translation;
                    return(new TR(r, t));
                }

            case ObjectSpace.local:
                if (m_src == null)
                {
                    return(TR.FromWorld(Source));
                }
                else
                {
                    return(TR.FromParent(Source) * m_src.LocalInitial);
                }

            default:
                throw new NotImplementedException();
            }
        }
Beispiel #3
0
 protected TR DestinationInitialCoords()
 {
     if (m_dst == null)
     {
         return(TR.FromWorld(transform));
     }
     else
     {
         return(TR.FromParent(transform) * m_dst.LocalInitial);
     }
 }
Beispiel #4
0
 protected TR SourceInitialCoords()
 {
     if (m_src == null)
     {
         return(TR.FromWorld(Source));
     }
     else
     {
         return(TR.FromParent(Source) * m_src.LocalInitial);
     }
 }
Beispiel #5
0
        public TR Delta(ObjectSpace coords, Quaternion sourceRotationOffset)
        {
            switch (coords)
            {
            // case SourceCoordinates.World: return m_transform.rotation * Quaternion.Inverse(m_initial.Rotation);
            case ObjectSpace.local: return(TR.FromLocal(Source) * (LocalInitial * new TR(sourceRotationOffset)).Inverse());

            case ObjectSpace.model: return(TR.FromWorld(Source) * (TR.FromParent(ModelRoot) * ModelInitial * new TR(sourceRotationOffset)).Inverse());

            default: throw new NotImplementedException();
            }
        }
        public void OnSceneGUI()
        {
            if (m_target.Source == null)
            {
                return;
            }

            // this to target line
            Handles.color = Color.yellow;
            Handles.DrawLine(m_target.Source.position, m_target.transform.position);

            var pos = m_target.transform.position;

            var pr = TR.FromParent(m_target.transform);

            if (m_target.m_src == null)
            {
                EditorGUI.BeginChangeCheck();
                TR.FromWorld(m_target.transform).Draw(0.2f);

                Handles.matrix = Matrix4x4.identity;
                var rot = Handles.RotationHandle(pr.Rotation * m_target.DestinationOffset, pos);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(m_target, "Rotated RotateAt Point");
                    m_target.DestinationOffset = Quaternion.Inverse(pr.Rotation) * rot;
                }

                DrawAimUp(rot, pos, Color.yellow);
            }
            else
            {
                var init = pr.Rotation * m_target.m_src.LocalInitial.Rotation;
                DrawAimUp(init * m_target.DestinationOffset, m_target.transform.position, Color.yellow);
                new TR(init, m_target.transform.position).Draw(0.2f);
                DrawAimUp(init * m_target.DestinationOffset * m_target.Delta, m_target.transform.position, Color.magenta);
            }

            // Target UPVector
            Handles.color = Color.green;
            Handles.DrawLine(m_target.transform.position, m_target.transform.position + m_target.UpVector);
        }