• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# System.Vector2类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Vector2的典型用法代码示例。如果您正苦于以下问题:C# Vector2类的具体用法?C# Vector2怎么用?C# Vector2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Vector2类属于System命名空间,在下文中一共展示了Vector2类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Capture

        public unsafe void Capture(Vector2 targetSize)
        {
            if (_previousTargetSize != targetSize)
            {
                SetupBuffers(targetSize);
                _previousTargetSize = targetSize;
            }

            _pboIndex = (_pboIndex + 1) % 2;
            _nextPboIndex = (_pboIndex + 1) % 2;

            var frame = _frameCache[_cachedFramesIndex++];
            _cachedFramesIndex %= _numberOfCachedFrames;

            frame.FrameIndex = _frameIndex++;

            GL.ReadBuffer(ReadBufferMode.ColorAttachment0);
            GL.BindBuffer(BufferTarget.PixelPackBuffer, _pboIds[_pboIndex]);
            GL.ReadPixels(0, 0, (int)targetSize.X, (int)targetSize.Y, PixelFormat.Bgra, PixelType.UnsignedByte, (IntPtr)0);

            GL.BindBuffer(BufferTarget.PixelPackBuffer, _pboIds[_nextPboIndex]);
            var ptr = GL.MapBufferRange(BufferTarget.PixelPackBuffer, (IntPtr)0, (IntPtr)GetTargetSizeInBytes(targetSize), BufferAccessMask.MapReadBit);

            fixed (byte* data = frame.Bytes)
            {
                memcpy((IntPtr)data, ptr, GetTargetSizeInBytes(targetSize));
            }

            GL.UnmapBuffer(BufferTarget.PixelPackBuffer);
            GL.BindBuffer(BufferTarget.PixelPackBuffer, 0);
            GL.ReadBuffer(ReadBufferMode.Back);

            _frames.TryAdd(frame);
        }
开发者ID:BraveSirAndrew,项目名称:DualityScreenCapturePlugin,代码行数:34,代码来源:ScreenCaptureStream.cs


示例2: ListBoxTextItem

		public ListBoxTextItem(string displayName, string itemValue)
			: base(displayName)
		{
			Padding = new BorderDouble(3);
			ItemValue = itemValue;
			MinimumSize = new Vector2(Width, Height);
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:7,代码来源:ListBox.cs


示例3: SetNewState

 private void SetNewState(VelocityComponentState state)
 {
     if (_lastState != null)
         _previousState = _lastState;
     _lastState = state;
     Velocity = new Vector2(state.VelocityX, state.VelocityY);
 }
开发者ID:millpond,项目名称:space-station-14,代码行数:7,代码来源:VelocityComponent.cs


示例4: PartPreviewMainWindow

		public PartPreviewMainWindow(PrintItemWrapper printItem, View3DWidget.AutoRotate autoRotate3DView, View3DWidget.OpenMode openMode = View3DWidget.OpenMode.Viewing)
			: base(750, 550)
		{
			UseOpenGL = true;
			string partPreviewTitle = LocalizedString.Get("MatterControl");
			Title = string.Format("{0}: ", partPreviewTitle) + Path.GetFileName(printItem.Name);

			this.Name = "Part Preview Window";

			partPreviewWidget = new PartPreviewContent(printItem, View3DWidget.WindowMode.StandAlone, autoRotate3DView, openMode);
			partPreviewWidget.Closed += (sender, e) =>
			{
				Close();
			};

			this.AddChild(partPreviewWidget);

			AddHandlers();

			Width = 750;
			Height = 550;

			MinimumSize = new Vector2(400, 300);
			ShowAsSystemWindow();
		}
开发者ID:unlimitedbacon,项目名称:MatterControl,代码行数:25,代码来源:PartPreviewMainWindow.cs


示例5: OnDraw

 private static void OnDraw(EventArgs args)
 {
     if (Enabled)
     {
         foreach (
             var unit in ObjectManager.Get<Obj_AI_Hero>().Where(u => u.IsValidTarget() && u.IsHPBarRendered))
         {
             // Get damage to unit
             var damage = damageToUnit(unit);
             // Continue on 0 damage
             if (damage <= 0)
             {
                 continue;
             }
             // Get remaining HP after damage applied in percent and the current percent of health
             var damagePercentage = ((unit.Health - damage) > 0 ? (unit.Health - damage) : 0) / unit.MaxHealth;
             var currentHealthPercentage = unit.Health / unit.MaxHealth;
             // Calculate start and end point of the bar indicator
             var startPoint =
                 new Vector2(
                     (int) (unit.HPBarPosition.X + BarOffset.X + damagePercentage * BarWidth),
                     (int) (unit.HPBarPosition.Y + BarOffset.Y) - 5);
             var endPoint =
                 new Vector2(
                     (int) (unit.HPBarPosition.X + BarOffset.X + currentHealthPercentage * BarWidth) + 1,
                     (int) (unit.HPBarPosition.Y + BarOffset.Y) - 5);
             // Draw the line
             Drawing.DrawLine(startPoint, endPoint, LineThickness, DrawingColor);
         }
     }
 }
开发者ID:blacky,项目名称:LeagueSharp,代码行数:31,代码来源:DamageIndicator.cs


示例6: OnMouseMove

 public void OnMouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     var mouseState = Mouse.GetState();
     var keyboardState = Keyboard.GetState();
     var currentMouseCoordinate = new Vector2(e.X, e.Y);
     if (keyboardState.IsKeyDown(Key.ShiftLeft) && (mouseState[MouseButton.Middle] || (mouseState[MouseButton.Left] && keyboardState[Key.ControlLeft])))
     {
         var d = 5;
         var previousMouseWorldCoordinate = Maths.Project(ViewMatrix, Viewport.ProjectionMatrix, previousMouseCoordinate, (Rectangle)Viewport, Maths.ProjectionTarget.View);
         var mouseWorldCoordinate = Maths.Project(ViewMatrix, ProjectionMatrix, currentMouseCoordinate, (Rectangle)Viewport, Maths.ProjectionTarget.View);
         var delta = mouseWorldCoordinate - previousMouseWorldCoordinate;
         delta *= d;
         panTrack.Update(delta.X, delta.Y);
     }
     else if (keyboardState.IsKeyDown(Key.AltLeft) && (mouseState[MouseButton.Middle] || (mouseState[MouseButton.Left] && keyboardState[Key.ControlLeft])))
     {
         var previousMouseWorldCoordinate = Maths.Project(ViewMatrix, Viewport.ProjectionMatrix, previousMouseCoordinate, (Rectangle)Viewport, Maths.ProjectionTarget.View);
         var mouseWorldCoordinate = Maths.Project(ViewMatrix, ProjectionMatrix, currentMouseCoordinate, (Rectangle)Viewport, Maths.ProjectionTarget.View);
         var delta = mouseWorldCoordinate - previousMouseWorldCoordinate;
         delta *= 10;
         zoomTrack.Update(delta.Y);
     }
     else if (mouseState[MouseButton.Middle] || (mouseState[MouseButton.Left] && keyboardState[Key.ControlLeft]))
     {
         var delta = currentMouseCoordinate - previousMouseCoordinate;
         //delta *= 10;
         orbitTrack.Update(delta.X, delta.Y);
     }
     if (this.MouseMove != null) this.MouseMove(this, new MouseEventArgs(this, new Vector2(e.X, e.Y), default(Vector3), e.Button));
     previousMouseCoordinate = currentMouseCoordinate;
 }
开发者ID:jacksoncougar,项目名称:Moonfish-Editor,代码行数:31,代码来源:camera.cs


示例7: TrackBallController

		public TrackBallController(Vector2 screenCenter, double trackBallRadius)
		{
			rotationStart = new Vector3();
			rotationCurrent = new Vector3();
			this.screenCenter = screenCenter;
			this.rotationTrackingRadius = trackBallRadius;
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:7,代码来源:TrackBallController.cs


示例8: IsOnScreen

 public static bool IsOnScreen(this Vector2 start, Vector2 end)
 {
     if (start.X > 0 && start.X < Drawing.Width && start.Y > 0 && start.Y < Drawing.Height && end.X > 0 &&
         end.X < Drawing.Width && end.Y > 0 && end.Y < Drawing.Height)
     {
         return true;
     }
     if (start.Intersection(end, new Vector2(0, 0), new Vector2(Drawing.Width, 0)).Intersects)
     {
         return true;
     }
     if (start.Intersection(end, new Vector2(0, 0), new Vector2(0, Drawing.Height)).Intersects)
     {
         return true;
     }
     if (
         start.Intersection(end, new Vector2(0, Drawing.Height), new Vector2(Drawing.Width, Drawing.Height))
             .Intersects)
     {
         return true;
     }
     return
         start.Intersection(end, new Vector2(Drawing.Width, 0), new Vector2(Drawing.Width, Drawing.Height))
             .Intersects;
 }
开发者ID:Lizzaran,项目名称:LeagueSharp-Standalones,代码行数:25,代码来源:VectorExtensions.cs


示例9: SignedDistance

        internal override float SignedDistance(ref Vector3 position, float lodVoxelSize, IMyModule macroModulator, IMyModule detailModulator)
        {
            Vector3 localPosition = position - m_translation;
            Vector3.Transform(ref localPosition, ref m_invRotation, out localPosition);

            var primaryDistance = new Vector2(localPosition.X, localPosition.Z).Length() - m_primaryRadius;
            var signedDistance = new Vector2(primaryDistance, localPosition.Y).Length() - m_secondaryRadius;

            var potentialHalfDeviation = m_potentialHalfDeviation + lodVoxelSize;
            if (signedDistance > potentialHalfDeviation)
                return 1f;
            else if (signedDistance < -potentialHalfDeviation)
                return -1f;

            if (m_enableModulation)
            {
                Debug.Assert(m_deviationFrequency != 0f);
                float normalizer = 0.5f * m_deviationFrequency;
                var tmp = localPosition * normalizer;
                float halfDeviationRatio = (float)macroModulator.GetValue(tmp.X, tmp.Y, tmp.Z);
                signedDistance -= halfDeviationRatio * m_secondaryHalfDeviation;
            }

            if (m_enableModulation && -m_detailSize < signedDistance && signedDistance < m_detailSize)
            {
                Debug.Assert(m_detailFrequency != 0f);
                float normalizer = 0.5f * m_detailFrequency;
                var tmp = localPosition * normalizer;
                signedDistance += m_detailSize * (float)detailModulator.GetValue(tmp.X, tmp.Y, tmp.Z);
            }

            return signedDistance / lodVoxelSize;
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:33,代码来源:MyCsgShapeTorus.cs


示例10: OnUpdate

        public override void OnUpdate(long msec)
        {
            var g2d = Graphics2D.GetInstance ();
            var pos = g2d.GetMousePosition ();

            if (Input.GetKeyDown (KeyCode.Mouse0)) {
                var start = new Vector3 (pos.X, pos.Y, 1000);
                var end = new Vector3 (pos.X, pos.Y, -1000);
                var node = World.Pick (start, end);
                if (node != null) {
                    this.picked = node;
                    this.delta = pos - new Vector2 (node.Position.X, node.Position.Y);
                }
            }
            if (Input.GetKeyUp(KeyCode.Mouse0)) {
                this.picked = null;
            }

            if (picked != null) {
                var t = pos - delta;
                picked.Translation = new Vector3(t.X, t.Y, 0);
            }

            base.OnUpdate (msec);
        }
开发者ID:weimingtom,项目名称:erica,代码行数:25,代码来源:MyFloor.cs


示例11: FindNearestLineCircleIntersections

        public static Vector2 FindNearestLineCircleIntersections(this Vector2 start,
            Vector2 end,
            Vector2 circlePos,
            float radius)
        {
            float t;
            var dx = end.X - start.X;
            var dy = end.Y - start.Y;

            var a = dx * dx + dy * dy;
            var b = 2 * (dx * (start.X - circlePos.X) + dy * (start.Y - circlePos.Y));
            var c = (start.X - circlePos.X) * (start.X - circlePos.X) +
                    (start.Y - circlePos.Y) * (start.Y - circlePos.Y) - radius * radius;

            var det = b * b - 4 * a * c;
            if ((a <= 0.0000001) || (det < 0))
            {
                return Vector2.Zero;
            }
            if (det.Equals(0f))
            {
                t = -b / (2 * a);
                return new Vector2(start.X + t * dx, start.Y + t * dy);
            }

            t = (float)((-b + Math.Sqrt(det)) / (2 * a));
            var intersection1 = new Vector2(start.X + t * dx, start.Y + t * dy);
            t = (float)((-b - Math.Sqrt(det)) / (2 * a));
            var intersection2 = new Vector2(start.X + t * dx, start.Y + t * dy);

            return Vector2.Distance(intersection1, ObjectManager.Player.Position.LSTo2D()) >
                   Vector2.Distance(intersection2, ObjectManager.Player.Position.LSTo2D())
                ? intersection2
                : intersection1;
        }
开发者ID:CainWolf,项目名称:PortAIO,代码行数:35,代码来源:VectorExtensions.cs


示例12: LogoElement

        public LogoElement(InterfaceElement parent, Vector2 location)
            : base(parent, location)
        {
            Opacity = 1f;

            Size = Program.Logo.Size;
        }
开发者ID:andi2,项目名称:ld32-1,代码行数:7,代码来源:LogoElement.cs


示例13: BindWindow

        /// <summary>
        /// Binds to specific events of the provided CoreWindow
        /// </summary>
        /// <param name="nativeWindow">A reference to <see cref="CoreWindow"/> or <see cref="UIElement"/> class.</param>
        /// <exception cref="ArgumentNullException">Is thrown when <paramref name="nativeWindow"/> is null.</exception>
        /// <exception cref="ArgumentException">Is thrown when <paramref name="nativeWindow"/> is not a <see cref="CoreWindow"/> and not an <see cref="UIElement"/></exception>
        protected override void BindWindow(object nativeWindow)
        {
            if (nativeWindow == null) throw new ArgumentNullException("nativeWindow");
            var window = nativeWindow as CoreWindow;
            if (window != null)
            {
                windowSize = new Size2F((float)window.Bounds.Width, (float)window.Bounds.Height);
                var position = window.PointerPosition;
                pointerPosition = new Vector2((float)position.X/windowSize.Width, (float)position.Y / windowSize.Height);

                window.PointerPressed += HandleWindowPointerEvent;
                window.PointerReleased += HandleWindowPointerEvent;
                window.PointerWheelChanged += HandleWindowPointerEvent;
                window.PointerMoved += HandleWindowPointerEvent;
                window.SizeChanged += window_SizeChanged;
                return;
            }

            uiElement = nativeWindow as FrameworkElement;
            if (uiElement != null)
            {
                windowSize = new Size2F((float)uiElement.ActualWidth, (float)uiElement.ActualHeight);
                uiElement.Loaded += HandleLoadedEvent;
                uiElement.SizeChanged += HandleSizeChangedEvent;
                uiElement.PointerPressed += HandleUIElementPointerEvent;
                uiElement.PointerReleased += HandleUIElementPointerEvent;
                uiElement.PointerWheelChanged += HandleUIElementPointerEvent;
                uiElement.PointerMoved += HandleUIElementPointerEvent;
                uiElement.PointerEntered += HandleUIElementPointerEvent;
                return;
            }

            throw new ArgumentException("Should be an instance of either CoreWindow or UIElement", "nativeWindow");
        }
开发者ID:chantsunman,项目名称:Toolkit,代码行数:40,代码来源:MousePlatformWinRt.cs


示例14: PCircle

 public PCircle( Vector2 position, float radius, int sides, bool filled )
     : base(filled)
 {
     this.position = position;
     this.radius = radius;
     this.sides = sides;
 }
开发者ID:adamxi,项目名称:SharpDXFramework,代码行数:7,代码来源:PCircle.cs


示例15: Offset

 internal Offset(Vector2 vec, int width, int height)
 {
     X = vec.X;
     Y = vec.Y;
     Width = width;
     Height = height;
 }
开发者ID:Deprive,项目名称:Private,代码行数:7,代码来源:Drawings.cs


示例16: AddEnemy

        /// <summary>
        /// Adds the enemy.
        /// </summary>
        /// <param name="position">The position.</param>
        public void AddEnemy(Vector2 position)
        {
            Enemy enemy = this.enemies[this.enemyIndex];
            enemy.Position = position;

            this.enemyIndex = (this.enemyIndex + 1) % this.enemyMax;
        }
开发者ID:dezol,项目名称:QuickStarters,代码行数:11,代码来源:EnemyEmiter.cs


示例17: TickCore

        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            int cooldown;
            if (state == null) cooldown = 1000;
            else cooldown = (int)state;

            Status = CycleStatus.NotStarted;

            if (host.HasConditionEffect(ConditionEffects.Paralyzed)) return;

            var player = (Player)host.GetNearestEntity(distance, null);
            if (player != null)
            {
                Vector2 vect;
                vect = new Vector2(player.X - host.X, player.Y - host.Y);
                vect.Normalize();
                float dist = host.GetSpeed(speed) * (time.thisTickTimes / 1000f);
                host.ValidateAndMove(host.X + (-vect.X) * dist, host.Y + (-vect.Y) * dist);
                host.UpdateCount++;

                if (cooldown <= 0)
                {
                    Status = CycleStatus.Completed;
                    cooldown = 1000;
                }
                else
                {
                    Status = CycleStatus.InProgress;
                    cooldown -= time.thisTickTimes;
                }
            }

            state = cooldown;
        }
开发者ID:RoxyLalonde,项目名称:Phoenix-Realms,代码行数:34,代码来源:StayBack.cs


示例18: Update

        public override void Update(GameTime gameTime)
        {
            if (mouseDelta == Vector2.Zero)
                return;

            Vector3 cameraDirection = camera.Direction;
            float length = cameraDirection.Length();
            cameraDirection.Normalize();

            Vector3 cameraNormalDirection = Vector3.Cross(camera.UpVector, cameraDirection);

            Vector3 cameraTargetNormalDirectionUp = Vector3.Cross(cameraDirection, cameraNormalDirection);
            cameraTargetNormalDirectionUp.Normalize();

            Vector3 newTargetRelative = cameraDirection;

            if (mouseDelta.X != 0)
                newTargetRelative -= cameraNormalDirection * mouseDelta.X * mouseSensivity * 1.0f / gameTime.ElapsedMiliseconds;

            if (mouseDelta.Y != 0)
                newTargetRelative -=
                    cameraTargetNormalDirectionUp * mouseDelta.Y *
                    mouseSensivity * mouseYInverted * 1.0f/gameTime.ElapsedMiliseconds;

            newTargetRelative = Vector3.Multiply(newTargetRelative, length);
            camera.Target = camera.Position + newTargetRelative;

            Cursor.Position = Master.I.form.PointToScreen(new Point(Master.I.form.ClientSize.Width / 2, Master.I.form.ClientSize.Height / 2));
            Cursor.Hide();
            mouseDelta = Vector2.Zero;
        }
开发者ID:catdawg,项目名称:Ch0nkEngine,代码行数:31,代码来源:MouseComponent.cs


示例19: AddWall

 public void AddWall(Vector2 p1, Vector2 p2)
 {
     double angle1, angle2;
     angle1 = Math.Atan2(p1.Y, p1.X);
     angle2 = Math.Atan2(p2.Y, p2.X);
     double adiff = angle2 - angle1;
     if (adiff < 0) adiff += Math.PI * 2.0;
     if (adiff > Math.PI)
     {
         Vector2 tmp = p2; p2 = p1; p1 = tmp;
         double tmp2 = angle1; angle1 = angle2; angle2 = tmp2;
     }
     if (angle1 < 0) angle1 += Math.PI * 2.0;
     if (angle2 < 0) angle2 += Math.PI * 2.0;
     if (angle2 < angle1)
     {
         float tmp = getinetersecty0(p1, p2);
         addit(tmp, 0.0f, p2.Length(), (float)angle2);
         addit(p1.Length(), (float)angle1, tmp, (float)Math.PI * 2.0f);
     }
     else
     {
         addit(p1.Length(), (float)angle1, p2.Length(), (float)angle2);
     }
 }
开发者ID:blmarket,项目名称:lib4bpp,代码行数:25,代码来源:Shadow.cs


示例20: RecreateControls

        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            

            AddCaption(MySpaceTexts.ScreenCaptionWorkshopTags);

            Vector2 origin = new Vector2(0f, -0.025f * (m_activeTags.Count + 2));
            Vector2 offset = new Vector2(0f,  0.05f);

            m_checkboxes.Clear();

            foreach (var pair in m_activeTags)
            {
                AddLabeledCheckbox(origin += offset, pair.Key, pair.Value);
                if (m_typeTag == MySteamWorkshop.WORKSHOP_MOD_TAG)
                {
                    var name = pair.Key.Replace(" ", string.Empty);
                    var path = Path.Combine(MyFileSystem.ContentPath, "Textures", "GUI", "Icons", "buttons", name + ".dds");
                    if (File.Exists(path))
                    {
                        AddIcon(origin + new Vector2(-0.05f, 0f), path, new Vector2(0.04f, 0.05f));
                    }
                }
            }

            origin += offset;

            Controls.Add(m_okButton = MakeButton(origin += offset, MySpaceTexts.Ok, MySpaceTexts.Ok, OnOkClick, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER));
            Controls.Add(m_cancelButton = MakeButton(origin, MySpaceTexts.Cancel, MySpaceTexts.Cancel, OnCancelClick, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));

            CloseButtonEnabled = true;
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:34,代码来源:MyGuiScreenWorkshopTags.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# System.Vector3类代码示例发布时间:2022-05-26
下一篇:
C# System.Variant类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap