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


C# Vector3.NormalizeFast方法代码示例

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


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

示例1: Move

        /// <summary>
        /// Offset the position of the camera in coordinates relative to its current orientation
        /// </summary>
        /// <param name="x">Movement along the camera ground (left/right)</param>
        /// <param name="y">Movement along the camera axis (forward)</param>
        /// <param name="z">Height to move</param>
        public void Move(float x, float y, float z)
        {
            Vector3 offset = new Vector3();
            Vector3 forward = new Vector3((float)Math.Sin((float)Orientation.X), 0, (float)Math.Cos((float)Orientation.X));
            Vector3 right = new Vector3(-forward.Z, 0, forward.X);

            offset += x * right;
            offset += y * forward;
            offset.Y += z;

            offset.NormalizeFast();
            offset = Vector3.Multiply(offset, MoveSpeed);

            Position += offset;
        }
开发者ID:tta269,项目名称:OpenTKTutorialContent,代码行数:21,代码来源:Camera.cs

示例2: Move

        public void Move(float x, float y)
        {
            Vector3 offset = new Vector3();

            Vector3 right = new Vector3(1, 0, 0);
            Vector3 up = new Vector3(0, 1, 0);

            offset += x * right;
            offset += y * up;

            offset.NormalizeFast();
            offset = Vector3.Multiply(offset, moveSpeed);

            position += offset;
        }
开发者ID:remludar,项目名称:testing,代码行数:15,代码来源:Camera.cs

示例3: Move

        /// <summary>
        /// This function handles the movement of the camera based on OnKeyPress() method in ACWWindow.cs
        /// </summary>
        /// <param name="x">The x axis movement value</param>
        /// <param name="y">The y axis movement value</param>
        /// <param name="z">The z axis movement value</param>
        public void Move(float x, float y, float z)
        {
            Vector3 offset = new Vector3();

            Vector3 forward = new Vector3((float)Math.Sin((float)Orientation.X), 0, (float)Math.Cos((float)Orientation.X)); // Forward and backward movement on the x and z axis
            Vector3 right = new Vector3(-forward.Z, 0, forward.X); // Right and left movement on the x and z axis

            // Actually moves the camera using the parameter values
            offset += x * right;
            offset += y * forward;
            offset.Y += z;

            offset.NormalizeFast();
            offset = Vector3.Multiply(offset, MoveSpeed);

            // Sets the new position of the camera based on the above calculations
            Position += offset;
        }
开发者ID:Darth-Arminius,项目名称:The-Column,代码行数:24,代码来源:Camera.cs

示例4: Shell

        public Shell(Vector3 position, Vector3 cannonFacing, Vector3 cannonVelocity, float startSpeed, object shellOwner)
        {
            int segments = 8;
            List<Vector3> vertices = new List<Vector3>(segments + 1);

            //float unitradius = (float)Math.Sqrt(8);
            float angleStep = (float)(2 * Math.PI / segments);
            for (int i = 0; i < segments; i++)
            {
                vertices.Add(new Vector3((float)Math.Cos(angleStep * i) * radius, (float)Math.Sin(angleStep * i) * radius, 0));
            }
            vertices.Add(new Vector3(radius, 0, 0));

            graphics = GraphicsAspect.Create(this, vertices, position, 1, Color.White, Color.Red);

            // вычисляем вектор полёта снаряда - сумма импульса выстрела и собственной скорости оружия
            cannonFacing.NormalizeFast();
            Vector3 shootVelocity = cannonFacing * startSpeed + cannonVelocity;
            Vector2 shootDirection = shootVelocity.Xy;
            shootDirection.NormalizeFast();
            //physics = new PhysicsAspect(this, position, shootVelocity.Xy, startSpeed);

            physics = PhysicsAspect.Create(this, position, shootDirection, shootVelocity.LengthFast);
            bounds = BoundSetAspect.Create(this, null);
            BoundsAspect bound = CircleBoundsAspect.Create(bounds, position.Xy, radius);
            bounds.AddBound(bound);
            // снаряд будет быстродвижущимся объектом, для него особый алгоритм определения столкновений
            bounds.SetAttribute(Strings.CollisionDetectionSpeedType, Strings.CollisionDetectionSpeedTypeFast);
            damage = DamageAspect.Create(this, 1);

            //physics = new PhysicsAspect(this, position, Vector2.Zero, 0);
            //timer = DestroyByTimerAspect.Create(this, new TimeSpan(0, 0, 0, 2, 500));
            timer = DestroyByTimerAspect.Create(this, new TimeSpan(0, 0, 0, 1, 0));

            this.shellOwner = shellOwner;
            this.name = "shell";

            MessageDispatcher.RegisterHandler(typeof(SetPosition), bounds);
            MessageDispatcher.RegisterHandler(typeof(SetPosition), graphics);
            MessageDispatcher.RegisterHandler(typeof(DestroyChildrenOf), this);
            MessageDispatcher.RegisterHandler(typeof(Kill), this);

            messageHandler.Handlers.Add(typeof(Kill), HandleKill);
        }
开发者ID:Skybladev2,项目名称:Sea-battles,代码行数:44,代码来源:Shell.cs

示例5: Move

        /// <summary>
        /// Moves the camera in local space
        /// </summary>
        /// <param name="x">Distance to move along the screen's x axis</param>
        /// <param name="y">Distance to move along the axis of the camera</param>
        /// <param name="z">Distance to move along the screen's y axis</param>
        public void Move(float x, float y, float z)
        {
            /** When the camera moves, we don't want it to move relative to the world coordinates
             * (like the XYZ space its position is in), but instead relative to the camera's view.
             * Like the view angle, this requires a bit of trigonometry. */

            Vector3 offset = new Vector3();

            Vector3 forward = new Vector3((float)Math.Sin((float)Orientation.X), 0, (float)Math.Cos((float)Orientation.X));
            Vector3 right = new Vector3(-forward.Z, 0, forward.X);

            offset += x * right;
            offset += y * forward;
            offset.Y += z;

            offset.NormalizeFast();
            offset = Vector3.Multiply(offset, MoveSpeed);

            Position += offset;
        }
开发者ID:tta269,项目名称:OpenTKTutorialContent,代码行数:26,代码来源:Camera.cs

示例6: IsOutOfBounds

 public bool IsOutOfBounds(Vector3 obj)
 {
     Vector3 normalized = new Vector3(obj.X, obj.Y, obj.Z);
     normalized.NormalizeFast();
     float norm = obj.LengthFast;
     //Vector3 abs = new Vector3(Math.Abs(obj.X), Math.Abs(obj.Y), Math.Abs(obj.Z));
     if (norm > _playerLimitRange)//- Math.Abs(normalized.Z*500))//+ normalized.X * _playerLimitEccentricityX + normalized.Z * _playerLimitEccentricityZ)
         return true;
     else
         return false;
 }
开发者ID:fakkoweb,项目名称:AsTKoids,代码行数:11,代码来源:Survival_AsteroidField.cs

示例7: MoveDreadnaught

        private void MoveDreadnaught()
        {

            // ORIENTATION
            if (InputManager.Mouse.RightClickdown)      //Follow cursor position when right click is down or set new orientation if just right click
            {
                _savedPlayerCursorPosition = new Vector3(_playerCursor.Position.X, _playerCursor.Position.Y, _playerCursor.Position.Z);
            }
            _dreadnaught.AlignTo(_savedPlayerCursorPosition);


            // POSITION LIMIT CHECK
            bool commandsEnabled = true;
            Vector3 command = new Vector3(0, 0, 0);
            Vector3 repelForce = new Vector3(0, 0, 0);

            if (!IsOutOfBounds(_dreadnaught.Position))   //if dreadnaught is in bounds, enable controls (player can accelerate spaceship)
            {
                commandsEnabled = true;
            }
            else
            {
                //If out of bounds, disable controls and apply a small "force" towards the origin, until spaceship changes direction
                if (Vector3.Dot(_dreadnaught.Velocity, _dreadnaught.Position) > 0)
                {
                    commandsEnabled = false;
                    repelForce = new Vector3(-_dreadnaught.Position.X, -_dreadnaught.Position.Y, -_dreadnaught.Position.Z);
                    repelForce.NormalizeFast();
                }//If out of bounds but spaceship has changed direction, enable commands (to allow player to get back)
                else
                {
                    commandsEnabled = true;
                }
            }

            // USER COMMANDS CATCH
            if (commandsEnabled)
            {
                if (InputManager.Keyboard.Sdown)
                    if (InputManager.Keyboard.ShiftLeftdown)
                        _camera.Move(_camera.Down, _camera.PositionSpeed * 100);
                    else
                        command.Z -= 1;

                if (InputManager.Keyboard.Wdown)
                    if (InputManager.Keyboard.ShiftLeftdown)
                        _camera.Move(_camera.Up, _camera.PositionSpeed * 100);
                    else
                        command.Z += 1;

                if (InputManager.Keyboard.Adown)
                    if (InputManager.Keyboard.ShiftLeftdown)
                        _camera.Move(_camera.Left, _camera.PositionSpeed * 100);
                    else
                        command.X += 1;

                if (InputManager.Keyboard.Ddown)
                    if (InputManager.Keyboard.ShiftLeftdown)
                        _camera.Move(_camera.Left, _camera.PositionSpeed * 100);
                    else
                        command.X -= 1;
            }

            // POSITION
            command.NormalizeFast();
            command += repelForce;      //apply repelforce (if any)
            Vector3 nextVelocity = _dreadnaught.Velocity + (command * _dreadnaught.MaxAcceleration * Game.DeltaTime);   //SPEED LAW
            if (Math.Abs(nextVelocity.X) > _dreadnaught.MaxSpeed) nextVelocity.X = _dreadnaught.Velocity.X;     //limit max speed on X
            if (Math.Abs(nextVelocity.Z) > _dreadnaught.MaxSpeed) nextVelocity.Z = _dreadnaught.Velocity.Z;     //limit max speed on Z 
            _dreadnaught.Velocity = nextVelocity;   //new speed vector apply
            _dreadnaught.Position = _dreadnaught.Position + _dreadnaught.Velocity;  //POSITION LAW

        }
开发者ID:fakkoweb,项目名称:AsTKoids,代码行数:73,代码来源:Survival_AsteroidField.cs

示例8: OrthoNormalize

 /// <summary>
 /// Applies Gram-Schmitt Ortho-normalization to the given two input Vectro3 objects. 
 /// </summary>
 /// <param name="vec1">The first Vector3 objects to be ortho-normalized</param>
 /// <param name="vec2">The secound Vector3 objects to be ortho-normalized</param>
 public static void OrthoNormalize(ref Vector3 vec1, ref Vector3 vec2)
 {
     vec1.NormalizeFast();
     vec2 = Vector3.Subtract(vec2, ProjectAndCreate(vec2, vec1));
     vec2.NormalizeFast();
 }
开发者ID:jamesrrowland,项目名称:Qualisys-Unity-SDK,代码行数:11,代码来源:Vector3Helper.cs


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