예제 #1
0
        public static Vector3 DirectionToRotation(Vector3 direction)
        {
            direction.Normalize();

            var x = Math.Atan2(direction.Z, Math.Sqrt(direction.Y * direction.Y + direction.X * direction.X));
            var y = 0;
            var z = -Math.Atan2(direction.X, direction.Y);

            return(new Vector3
            {
                X = (float)RadToDeg(x),
                Y = (float)RadToDeg(y),
                Z = (float)RadToDeg(z)
            });
        }
예제 #2
0
        public static Vector3 DirectionToRotation(Vector3 direction)
        {
            direction.Normalize();

            var x = (float)Math.Atan2(direction.Z, Math.Sqrt(direction.Y * direction.Y + direction.X * direction.X));
            var y = 0;
            var z = (float)-Math.Atan2(direction.X, direction.Y);

            return(new Vector3
            {
                X = Mathf.Rad2Deg * x,
                Y = Mathf.Rad2Deg * y,
                Z = Mathf.Rad2Deg * z
            });
        }
예제 #3
0
        internal static void SetCamera(GTA.Math.Vector3 Position, GTA.Math.Vector3 Direction, float FOV)
        {
            Direction.Normalize();

            Application.Console.WriteLine("[Tools.SetCamera]: setting camera to (" + Position.X + " | " + Position.Y + " | " + Position.Z +
                                          ") (" + Direction.X + " | " + Direction.Y + " | " + Direction.Z + ")");

            var cameraScript = Application.Scripts.OfType <CameraScript>().First();

            cameraScript.ControlledPosition  = Position;
            cameraScript.ControlledDirection = Direction;
            cameraScript.ControlledFOV       = FOV;

            Application.Console.WriteLine("set camera to position (" + World.RenderingCamera.Position.X + " | " + World.RenderingCamera.Position.Y + " | " + World.RenderingCamera.Position.Z +
                                          ") (" + World.RenderingCamera.Direction.X + " | " + World.RenderingCamera.Direction.Y + " | " + World.RenderingCamera.Direction.Z + ")");
            Application.Console.WriteLine("set player to position (" + Game.PlayerPed.Position.X + " | " + Game.PlayerPed.Position.Y + " | " + Game.PlayerPed.Position.Z +
                                          ") (" + Game.PlayerPed.Rotation.X + " | " + Game.PlayerPed.Rotation.Y + " | " + Game.PlayerPed.Rotation.Z + ")");
        }
예제 #4
0
        public static GTA.Math.Vector3 RaycastFromCoord(float x, float y, Entity ignore, float maxDist, float failDist, out RaycastResult res) // 0, 0 is center screen
        {
            Camera camera = World.RenderingCamera;

            GTA.Math.Vector3 position     = camera.Position;
            GTA.Math.Vector2 screenCoords = new GTA.Math.Vector2(x, y);

            GTA.Math.Vector3 WorldCoord = ScreenToWorld(screenCoords, camera);

            GTA.Math.Vector3 vector31 = WorldCoord - position;
            vector31.Normalize();

            res = World.Raycast(position + (vector31 * 1.0f), position + (vector31 * maxDist), (IntersectFlags)287, ignore);
            if (res.DidHit)
            {
                return(res.HitPosition);
            }
            return(position + (vector31 * failDist));
        }
예제 #5
-1
        public static Vector3 DirectionToRotation(Vector3 direction)
        {
            direction.Normalize();

            var x = (float)Math.Atan2(direction.Z, Math.Sqrt(direction.Y * direction.Y + direction.X * direction.X));
            var y = 0;
            var z = (float)-Math.Atan2(direction.X, direction.Y);

            return new Vector3
            {
                X = Mathf.Rad2Deg * x,
                Y = Mathf.Rad2Deg * y,
                Z = Mathf.Rad2Deg * z
            };
        }