Ejemplo n.º 1
0
        /// <summary>
        /// Grab orientation by looking ahead of path, returns rotation in world space.
        /// </summary>
        public static Quaternion GetOrientation(OrientMode orientMode, AxisFlags orientLockAxis, Transform trans, TweenPlugPath path, float t)
        {
            var lookatPt = GetLookAhead(trans, t, path);

            if (trans.parent)
            {
                lookatPt = trans.parent.TransformPoint(lookatPt);
            }

            return(GetOrientation(orientMode, orientLockAxis, trans, lookatPt));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Only uses modes: TwoDimension*. Grab orientation by looking ahead of path, returns rotation (Z) in world space.
        /// </summary>
        public static float GetOrientation2D(OrientMode orientMode, Transform trans, TweenPlugPath path, float t)
        {
            var lookatPt = GetLookAhead(trans, t, path);

            if (trans.parent)
            {
                lookatPt = trans.parent.TransformPoint(lookatPt);
            }

            return(GetOrientation2D(orientMode, trans, lookatPt));
        }
Ejemplo n.º 3
0
 public Physics(ComponentManager Manager, string name, Matrix localTransform, Vector3 boundingBoxExtents, Vector3 boundingBoxPos, float mass, float i, float linearDamping, float angularDamping, Vector3 gravity, OrientMode orientation = OrientMode.Fixed) :
     base(Manager, name, localTransform, boundingBoxExtents, boundingBoxPos)
 {
     Mass            = mass;
     Velocity        = Vector3.Zero;
     AngularVelocity = Vector3.Zero;
     I                = i;
     LinearDamping    = linearDamping;
     AngularDamping   = angularDamping;
     Gravity          = gravity;
     Restitution      = 0.01f;
     Friction         = 0.99f;
     IsSleeping       = false;
     PreviousPosition = LocalTransform.Translation;
     PreviousVelocity = Vector3.Zero;
     IsInLiquid       = false;
     CollisionType    = CollisionType.Dynamic;
     CollideMode      = CollisionMode.All;
     Orientation      = orientation;
     SleepTimer       = new Timer(5.0f, true, Timer.TimerMode.Real);
     WakeTimer        = new Timer(0.01f, true, Timer.TimerMode.Real);
 }
Ejemplo n.º 4
0
 public Physics(string name, GameComponent parent, Matrix localTransform, Vector3 boundingBoxExtents, Vector3 boundingBoxPos, float mass, float i, float linearDamping, float angularDamping, Vector3 gravity, OrientMode orientation = OrientMode.Fixed)
     : base(name, parent, localTransform, boundingBoxExtents, boundingBoxPos)
 {
     Mass = mass;
     Velocity = Vector3.Zero;
     AngularVelocity = Vector3.Zero;
     I = i;
     LinearDamping = linearDamping;
     AngularDamping = angularDamping;
     Gravity = gravity;
     Restitution = 0.01f;
     Friction = 0.99f;
     IsSleeping = false;
     PreviousPosition = LocalTransform.Translation;
     PreviousVelocity = Vector3.Zero;
     IsInLiquid = false;
     CollisionType = CollisionManager.CollisionType.Dynamic;
     CollideMode = CollisionMode.All;
     Orientation = orientation;
     SleepTimer = new Timer(5.0f, true);
     CurrentVoxel = new Voxel();
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Only uses modes: TwoDimension*. Grab orientation by direction torwards lookatPt (world space), returns rotation (Z) in world space.
        /// </summary>
        public static float GetOrientation2D(OrientMode orientMode, Transform trans, Vector3 lookatPt)
        {
            switch (orientMode)
            {
            case OrientMode.TwoDimension:
                var rotZ = Angle2DRight(trans.position, lookatPt);
                if (rotZ < 0f)
                {
                    rotZ = 360f + rotZ;
                }
                return(rotZ);

            case OrientMode.TwoDimensionUp:
                rotZ = Angle2DUp(trans.position, lookatPt);
                if (rotZ < 0f)
                {
                    rotZ = 360f + rotZ;
                }
                return(rotZ);

            default:
                return(trans.eulerAngles.z);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Grab orientation by direction torwards lookatPt (world space), returns rotation in world space.
        /// </summary>
        public static Quaternion GetOrientation(OrientMode orientMode, AxisFlags orientLockAxis, Transform trans, Vector3 lookatPt)
        {
            switch (orientMode)
            {
            case OrientMode.ThreeDimension:
                Vector3 up;
                ApplyLockAxis(orientLockAxis, trans, ref lookatPt, out up);

                var dpos = lookatPt - trans.position;
                if (dpos == Vector3.zero)
                {
                    return(trans.rotation);
                }

                return(Quaternion.LookRotation(dpos, up));

            case OrientMode.TwoDimension:
                var rotZ = Angle2DRight(trans.position, lookatPt);
                if (rotZ < 0f)
                {
                    rotZ = 360f + rotZ;
                }
                return(Quaternion.Euler(0f, 0f, rotZ));

            case OrientMode.TwoDimensionUp:
                rotZ = Angle2DUp(trans.position, lookatPt);
                if (rotZ < 0f)
                {
                    rotZ = 360f + rotZ;
                }
                return(Quaternion.Euler(0f, 0f, rotZ));

            default:
                return(trans.rotation);
            }
        }
Ejemplo n.º 7
0
        public bool       lookAtIsLocal; //if true, convert lookAtPt to world via target's parent

        void IPlugOptions.Reset()
        {
            orientMode    = OrientMode.None;
            lockAxis      = AxisFlags.None;
            lookAtIsLocal = false;
        }
Ejemplo n.º 8
0
 void IPlugOptions.Reset()
 {
     orientMode = OrientMode.None;
     lockAxis   = AxisFlags.None;
 }