Exemplo n.º 1
0
        public override Vector3 GetTarget()
        { //get target position
            Vector3 target = Vector3.zero;

            if (space == Space.World)
            {
                target = value;
            }
            else if (space == Space.Self)
            {
                if (link == Link.Offset)
                {
                    if (factorScale)
                    {
                        target = Linking.TransformPoint(value * offsetScale, parentPos, parentRot, parentScale); //WORKS!
                    }
                    else
                    {
                        target = Linking.TransformPoint(value, parentPos, parentRot);
                    }

                    target = offset.ApplyPosition(this, target);
                }
                else if (link == Link.Match)
                {
                    Vector3 newTarget;

                    //if (!editorApply) // (Cannot change position while applying to parent) {
                    SetPrevious();
                    //}

                    if (factorScale)
                    {
                        newTarget = Linking.TransformPoint(previous * offsetScale, parent.position, parent.rotation, parent.scale);
                    }
                    else
                    {
                        newTarget = Linking.TransformPoint(previousDirection, parent.position, parent.rotation); //++++++++ ATTENTION
                    }

                    target = newTarget;
                }
            }

            return(target);
        }
Exemplo n.º 2
0
 public Vector3 SetPosition(Vector3 position, Space relativeTo = Space.Self)
 { //sets position and returns world position
     if (relativeTo == Space.Self)
     {
         if (factorScale)
         {
             return(Linking.TransformPoint(position * offsetScale, parentPos, parentRot, parentScale)); //WORKS!
         }
         else
         {
             return(Linking.TransformPoint(position, parentPos, parentRot)); //WORKS!
         }
     }
     else
     {
         return(position); //WORKS!
     }
 } //returns world
Exemplo n.º 3
0
 public Vector3 Translate(Vector3 translation, Space relativeTo = Space.Self)
 { //transform translate
     if (relativeTo == Space.Self)
     {
         if (factorScale)
         {
             return(operationalPosition + (Linking.TransformPoint(translation * offsetScale, parentPos, parentRot, parentScale) - parentPos)); //WORKS!
         }
         else
         {
             return(Linking.TransformPoint(operationalPosition + translation, parentPos, parentRot)); //WORKS!
         }
     }
     else
     {
         return(operationalPosition + translation); //WORKS!
     }
 }
Exemplo n.º 4
0
        } //works probably

        public Vector3 ReversePosition(Vector3 position, Quaternion rotation, Vector3 scale, Vector3?current = null)
        {
            Vector3 newPos;

            if (current != null)
            {
                newPos = (Vector3)current;
            }
            else
            {
                newPos = position;
            }

            if (variety == SpaceVariety.OneSided)
            {
                foreach (AxisApplied i in axes)
                {
                    if (space == Space.Self)
                    {
                        newPos += Linking.TransformPoint(-(Vectors.axisDirections[i.axis] * i.units), position, rotation, scale);
                    }
                    else
                    {
                        newPos += -(Vectors.axisDirections[i.axis] * i.units);
                    }
                }
            }
            else if (variety == SpaceVariety.Mixed)
            {
                foreach (AxisApplied i in axes)
                {
                    if (i.space == Space.Self)
                    {
                        newPos += Linking.TransformPoint(-(Vectors.axisDirections[i.axis] * i.units), position, rotation, scale);
                    }
                    else
                    {
                        newPos += -(Vectors.axisDirections[i.axis] * i.units);
                    }
                }
            }
            return(newPos);
        }
Exemplo n.º 5
0
 public Vector3 Translate(Vector3 from, Vector3 translation, Space relativeTo = Space.Self)
 { //transform translate
     if (relativeTo == Space.Self)
     {
         if (factorScale)
         {
             return(from + (Linking.TransformPoint(translation * offsetScale, parentPos, parentRot, parentScale) - parent.position)); //WORKS!
         }
         else
         {
             //return Vectors.DivideVector3(Linking.TransformPoint(from + translation, parentPos, parentRot, parentScale), parentScale); //WORKS!
             return(Linking.TransformPoint(from + translation, parentPos, parentRot));
         }
     }
     else
     {
         return(from + translation); //WORKS!
     }
 }
 public override void MoveToTarget()
 {
     if (enabled)
     {
         transform.position += -((transform.parent.TransformPoint(localPosition) - transform.parent.position) - (Linking.TransformPoint(localPosition, parentPos, parentRot, parentScale) - parentPos));
         transform.position += -(transform.parent.position - parentPos);
         if (!factorScale)
         {
             transform.localPosition =
                 transform.localPosition.Divide(parentScale.Divide(transform.parent.localScale));
         }
     }
 }