Ejemplo n.º 1
0
        public DoLoop(Vector3 currentPosition, Quaternion currentRotation, float omega = GlobalManager.defaultLoopOmega, float r = GlobalManager.defaultLoopRadius)
        {
            Vector3 currentForward = currentRotation * Vector3.forward;

            r         *= MapMovement.Instance.AbsoluteZoomRatio;
            centerX    = currentPosition.x;
            centerY    = currentPosition.y + r;
            centerZ    = currentPosition.z;
            this.omega = omega;
            this.r     = r;
            startTime  = Time.time;
            //The minus sign is because our hercules model's forward vector is towards its tail
            zComponentOfHorizontal = Vector3.Dot(-currentForward, Vector3.forward);
            xComponentOfHorizontal = Vector3.Dot(-currentForward, Vector3.right);
            correctPoseManeuver    = new CorrectPoseManeuver(currentRotation, Quaternion.LookRotation(-new Vector3((float)(-xComponentOfHorizontal * Math.Sin(omega * GlobalManager.timeToCorrectPose + phase)), (float)Math.Cos(omega * GlobalManager.timeToCorrectPose + phase), (float)(-zComponentOfHorizontal * Math.Sin(omega * GlobalManager.timeToCorrectPose + phase))), -new Vector3(xComponentOfHorizontal * r * (float)Math.Cos(omega * GlobalManager.timeToCorrectPose + phase) + centerX, r * (float)Math.Sin(omega * GlobalManager.timeToCorrectPose + phase) + centerY, zComponentOfHorizontal * r * (float)Math.Cos(omega * GlobalManager.timeToCorrectPose + phase) + centerZ) + new Vector3(centerX, centerY, centerZ)));
        }