当前位置: 首页>>代码示例>>C#>>正文


C# Ped.GetBoneCoord方法代码示例

本文整理汇总了C#中GTA.Ped.GetBoneCoord方法的典型用法代码示例。如果您正苦于以下问题:C# Ped.GetBoneCoord方法的具体用法?C# Ped.GetBoneCoord怎么用?C# Ped.GetBoneCoord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GTA.Ped的用法示例。


在下文中一共展示了Ped.GetBoneCoord方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindGazeProjection

        private void FindGazeProjection(out Vector3 shootCoord, out Vector3 shootCoordSnap, out Vector3 shootMissileCoord, out Ped ped, out Entity target)
        {
            //debug
            Geometry.ScreenRelToWorld(new Vector2(0, 0));
            var result = GameplayCamera.Position;
            _debugOutput.DebugText3.Caption = "Point: " + Math.Round(result.X, 1) + " | " + Math.Round(result.Y, 1) +
                                              " | " + Math.Round(result.Z, 1);
            //end Debug

            target = null;
            const float joystickRadius = 0.1f;

            var controllerState = _controllerEmulation.ControllerState;

            var joystickDelta = new Vector2(controllerState.Gamepad.RightThumbX, -controllerState.Gamepad.RightThumbY)*
                                (1.0f/32768.0f)*joystickRadius;

            var w = (float)(1 - _settings.GazeFiltering * 0.9);
            _gazePointDelta = new Vector2(_gazePointDelta.X + (_lastNormalizedCenterDelta.X - _gazePointDelta.X) * w,
                _gazePointDelta.Y + (_lastNormalizedCenterDelta.Y - _gazePointDelta.Y) * w);

            _gazePlusJoystickDelta = _gazePointDelta + joystickDelta;
            _unfilteredgazePlusJoystickDelta = _lastNormalizedCenterDelta;

            Entity unfilteredEntity;
            Entity filteredEntity;
            var hitUnfiltered = Geometry.ConecastPedsAndVehicles(_unfilteredgazePlusJoystickDelta, out unfilteredEntity);
            shootMissileCoord = hitUnfiltered;
            shootCoordSnap = hitUnfiltered;

            var hitFiltered = Geometry.RaycastEverything(_gazePlusJoystickDelta, out filteredEntity, true);
            shootCoord = hitFiltered;

            if (unfilteredEntity != null
                && Util.IsEntityAPed(unfilteredEntity))
            {
                ped = unfilteredEntity as Ped;
            }
            else
            {
                ped = Geometry.SearchPed(_unfilteredgazePlusJoystickDelta);
            }

            if ((ped != null)
                && (ped.Handle != Game.Player.Character.Handle))
            {
                shootCoordSnap = ped.GetBoneCoord(Bone.SKEL_L_Clavicle);
                target = ped;
                if (_settings.SnapAtPedestriansEnabled)
                {
                    shootCoord = shootCoordSnap;

                }
            }
            else
            {
                Vehicle vehicle;
                if (unfilteredEntity != null
                    && Util.IsEntityAPed(unfilteredEntity))
                {
                    vehicle = unfilteredEntity as Vehicle;
                }
                else
                {
                    vehicle = Geometry.SearchVehicle(_unfilteredgazePlusJoystickDelta);
                }
                _debugOutput.DebugText5.Caption = "raycasing veh " + DateTime.Now;
                if (vehicle != null
                    && !((Game.Player.Character.IsInVehicle())
                        && (vehicle.Handle == Game.Player.Character.CurrentVehicle.Handle)))
                {
                    shootCoordSnap = vehicle.Position + vehicle.Velocity * 0.06f;
                    shootMissileCoord = shootCoordSnap;
                    target = vehicle;
                    _debugOutput.DebugText4.Caption = "veh " + vehicle.Handle;
                }
            }
            var playerDistToGround = Game.Player.Character.Position.Z - World.GetGroundHeight(Game.Player.Character.Position);
            var targetDir = shootMissileCoord - Game.Player.Character.Position;
            targetDir.Normalize();
            var justBeforeTarget = shootMissileCoord - targetDir;
            var targetDistToGround = shootMissileCoord.Z - World.GetGroundHeight(justBeforeTarget);
            var distToTarget = (Game.Player.Character.Position - shootMissileCoord).Length();
            if ((playerDistToGround < 2) && (playerDistToGround >= -0.5)) //on the ground
            {

                if (((targetDistToGround < 2) && (targetDistToGround >= -0.5)) //shoot too low
                    || ((targetDistToGround < 5) && (targetDistToGround >= -0.5) && (distToTarget > 70.0))) //far away add near the ground
                {
                    shootMissileCoord.Z = World.GetGroundHeight(justBeforeTarget) //ground level at target
                        + playerDistToGround; //offset
                }
            }
        }
开发者ID:leftas,项目名称:gta5eyetracking,代码行数:94,代码来源:Gta5EyeTracking.cs

示例2: FindGazeProjection

        private void FindGazeProjection(out Vector3 shootCoord, out Vector3 shootCoordSnap, out Vector3 shootMissileCoord, out Ped ped)
        {
            const float joystickRadius = 0.1f;

            var controllerState = _controllerEmulation.ControllerState;

            var joystickDelta = new Vector2(controllerState.Gamepad.RightThumbX, -controllerState.Gamepad.RightThumbY)*
                                (1.0f/32768.0f)*joystickRadius;

            var w = (float)(1 - _settings.GazeFiltering * 0.9);
            _gazePointDelta = new Vector2(_gazePointDelta.X + (_lastNormalizedCenterDelta.X - _gazePointDelta.X) * w,
                _gazePointDelta.Y + (_lastNormalizedCenterDelta.Y - _gazePointDelta.Y) * w);

            _gazePlusJoystickDelta = _gazePointDelta + joystickDelta;
            _unfilteredgazePlusJoystickDelta = _lastNormalizedCenterDelta;

            var hitUnfiltered = Geometry.RaycastEverything(_unfilteredgazePlusJoystickDelta);
            shootMissileCoord = hitUnfiltered;
            shootCoordSnap = hitUnfiltered;

            var hitFiltered = Geometry.RaycastEverything(_gazePlusJoystickDelta);
            shootCoord = hitFiltered;

            ped = Geometry.RaycastPed(_unfilteredgazePlusJoystickDelta);
            if ((ped != null)
                && (ped.Handle != Game.Player.Character.Handle))
            {
                shootCoordSnap = ped.GetBoneCoord(Bone.SKEL_L_Clavicle);

                if (_settings.SnapAtPedestriansEnabled)
                {
                    shootCoord = shootCoordSnap;
                }
            }
            else
            {
                var vehicle = Geometry.RaycastVehicle(_unfilteredgazePlusJoystickDelta);
                if (vehicle != null
                    && !((Game.Player.Character.IsInVehicle())
                        && (vehicle.Handle == Game.Player.Character.CurrentVehicle.Handle)))
                {
                    shootCoordSnap = vehicle.Position + vehicle.Velocity * 0.06f;
                    shootMissileCoord = shootCoordSnap;
                }
            }
            var playerDistToGround = Game.Player.Character.Position.Z - World.GetGroundHeight(Game.Player.Character.Position);
            var targetDir = shootMissileCoord - Game.Player.Character.Position;
            targetDir.Normalize();
            var justBeforeTarget = shootMissileCoord - targetDir;
            var targetDistToGround = shootMissileCoord.Z - World.GetGroundHeight(justBeforeTarget);
            var distToTarget = (Game.Player.Character.Position - shootMissileCoord).Length();
            if ((playerDistToGround < 2) && (playerDistToGround >= -0.5)) //on the ground
            {

                if (((targetDistToGround < 2) && (targetDistToGround >= -0.5)) //shoot too low
                    || ((targetDistToGround < 5) && (targetDistToGround >= -0.5) && (distToTarget > 70.0))) //far away add near the ground
                {
                    shootMissileCoord.Z = World.GetGroundHeight(justBeforeTarget) //ground level at target
                        + playerDistToGround; //offset
                }
            }

            if (!_menuOpen
                && (controllerState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.DPadDown)
                || User32.IsKeyPressed(VirtualKeyStates.VK_LMENU)))
            {
                //character selection
            }
            else if (!_isInVehicle && controllerState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.LeftShoulder))
            {
                _radialMenu.Process(_lastNormalizedCenterDelta, _aspectRatio);
            }
            else
            {
                _freelook.Process(_lastNormalizedCenterDelta, ped, _aspectRatio);
            }
        }
开发者ID:Guad,项目名称:gta5eyetracking,代码行数:77,代码来源:Gta5EyeTracking.cs

示例3: ThirdPersonAimFreelook

        public void ThirdPersonAimFreelook(Vector2 gazeNormalizedCenterDelta, Ped ped, double aspectRatio)
        {
            _relativeHeadingVehicle = 0;
            _relativePitchVehicle = 0;

            if (!GameplayCamera.IsRendering) return;

            double deltaX = 0;
            double deltaY = 0;
            if (_settings.ThirdPersonFreelookEnabled
                && (!IsInFixedDeadzone(gazeNormalizedCenterDelta, aspectRatio)))
            {
                var freelookDeltaVector = new Vector2(gazeNormalizedCenterDelta.X, gazeNormalizedCenterDelta.Y);

                if (ped != null && ped != Game.Player.Character)
                {
                    Vector2 screenCoords;
                    var pos = ped.GetBoneCoord(Bone.SKEL_L_Clavicle);
                    Geometry.WorldToScreenRel(pos, out screenCoords);
                    freelookDeltaVector = screenCoords;
                }

                deltaX = freelookDeltaVector.X * (float)(_settings.AimingSensitivity);
                deltaY = freelookDeltaVector.Y * (float)(_settings.AimingSensitivity);
            }

            EmulateHid(deltaX, deltaY);
        }
开发者ID:leftas,项目名称:gta5eyetracking,代码行数:28,代码来源:Freelook.cs

示例4: FindGazeProjection

        public void FindGazeProjection(
			Vector2 gazePoint,
			Vector2 joystickDelta,
            out Vector3 shootCoord, 
			out Vector3 shootCoordSnap, 
			out Vector3 shootMissileCoord, 
			out Ped ped, 
			out Entity missileTarget
			)
        {
            Entity target = null;

            var w = (float)(1 - _settings.GazeFiltering * 0.9);
            _filteredGazePoint = new Vector2(_filteredGazePoint.X + (gazePoint.X - _filteredGazePoint.X) * w,
                _filteredGazePoint.Y + (gazePoint.Y - _filteredGazePoint.Y) * w);

            var filteredGazePointPlusJoystickDelta = _filteredGazePoint + joystickDelta;
            var unfilteredGazePointPlusJoystickDelta = gazePoint;

            Entity unfilteredEntity;
            Entity filteredEntity;
            var hitUnfiltered = Geometry.ConecastPedsAndVehicles(unfilteredGazePointPlusJoystickDelta, out unfilteredEntity);
            shootMissileCoord = hitUnfiltered;
            shootCoordSnap = hitUnfiltered;

            var hitFiltered = Geometry.RaycastEverything(filteredGazePointPlusJoystickDelta, out filteredEntity, true);
            shootCoord = hitFiltered;

            if (unfilteredEntity != null
                && ScriptHookExtensions.IsEntityAPed(unfilteredEntity)
                && unfilteredEntity.IsAlive)
            {
                ped = unfilteredEntity as Ped;
            }
            else
            {
                if (_frameSkip == 0)
                {
                    ped = Geometry.SearchPed(unfilteredGazePointPlusJoystickDelta); //Too slow :(
                    _lastPed = ped;
                }
                else
                {
                    ped = _lastPed;
                }
            }

            if ((ped != null)
                && (ped.Handle != Game.Player.Character.Handle))
            {
                shootCoordSnap = ped.GetBoneCoord(Bone.SKEL_L_Clavicle);
                target = ped;
                if (_settings.SnapAtTargetsEnabled)
                {
                    shootCoord = shootCoordSnap;
                }
            }
            else
            {

                Vehicle vehicle;
                if (unfilteredEntity != null
                    && ScriptHookExtensions.IsEntityAVehicle(unfilteredEntity)
                    && unfilteredEntity.IsAlive)
                {
                    vehicle = unfilteredEntity as Vehicle;
                }
                else
                {
                    if (_frameSkip == 0)
                    {
                        vehicle = Geometry.SearchVehicle(unfilteredGazePointPlusJoystickDelta); // Too slow :(
                        _lastVehicle = vehicle;
                    }
                    else
                    {
                        vehicle = _lastVehicle;
                    }
                }

                if (vehicle != null
                    && !((Game.Player.Character.IsInVehicle())
                        && (vehicle.Handle == Game.Player.Character.CurrentVehicle.Handle)))
                {
                    shootCoordSnap = vehicle.Position + vehicle.Velocity * 0.06f;
                    shootMissileCoord = shootCoordSnap;
                    target = vehicle;
                }
            }

            ProcessMissileLock(target);

            missileTarget = _missileTarget;
            _frameSkip++;
            if (_frameSkip > _maxSkipFrames)
            {
                _frameSkip = 0;
            }
        }
开发者ID:alex8b,项目名称:gta5eyetracking,代码行数:99,代码来源:GazeProjector.cs


注:本文中的GTA.Ped.GetBoneCoord方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。