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


C# Vector3.ToVector2方法代码示例

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


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

示例1: DrawLine

        public void DrawLine(Vector3 v1, Vector3 v2, float width, Color color, float[,] matrix)
        {
            v1 = v1.Transform(matrix);
            v2 = v2.Transform(matrix);

            float angle = (v1.ToVector2() - v2.ToVector2()).Angle() + 90;
            Vector3 offset = new Vector2(width / 2, angle).ToCartesian().ToVector3();
            DrawTriangle(v1 + offset, v1 - offset, v2 + offset, color, Color.Transparent, Matrix.GetIdentity());
            DrawTriangle(v1 - offset, v2 - offset, v2 + offset, color, Color.Transparent, Matrix.GetIdentity());
        }
开发者ID:rubna,项目名称:3dEngine,代码行数:10,代码来源:DrawWrapper.cs

示例2: ToVector2Test

        public void ToVector2Test()
        {
            const float TestValueA = 5.722222f;
            const float TestValueB = 7.5213f;
            const float TestValueC = -72.333e-7f;

            Vector3 vectorA = new Vector3(new Vector2(TestValueA, TestValueB), TestValueC);

            Vector2 resultA = vectorA.ToVector2();

            Assert.AreEqual(resultA.X, TestValueA);
            Assert.AreEqual(resultA.Y, TestValueB);
        }
开发者ID:AleksandarDev,项目名称:LD26,代码行数:13,代码来源:VectorExtensions.cs

示例3: update_

        private void update_(Vector3 startV3)
        {
            //raycast to test how far we could go..
            Vector3 MaxRangeTestVector3 = MathEx.GetPointAt(startV3, Range, MathEx.ToRadians(DirectionDegrees));

            Vector2 RaycastTestV2;
            //we use main grid providers raycast to test since we are looking at how far we can travel and not if anything is blocking us.
            if (Navigation.MGP.Raycast(startV3.ToVector2(), MaxRangeTestVector3.ToVector2(), out RaycastTestV2))
            {//Set our endpoint at the Hit point
                MaxRangeTestVector3 = RaycastTestV2.ToVector3();
                MaxRangeTestVector3.Z = Navigation.MGP.GetHeight(MaxRangeTestVector3.ToVector2()); //adjust height acordingly!
            }
            Range = Vector3.Distance2D(ref startV3, ref MaxRangeTestVector3);

            //lets see if we can stand here at all?
            if (!Navigation.MGP.CanStandAt(MaxRangeTestVector3))
            {

                //just because raycast set our max range, we need to see if we can use that cell as a walking point!
                if (!Navigation.CanRayCast(startV3, MaxRangeTestVector3, NavCellFlags.AllowWalk))
                {
                    //loop to find a walkable range.
                    float currentRange = Range - 2.5f;
                    float directionRadianFlipped = Navigation.FindDirection(MaxRangeTestVector3, startV3, true);
                    int maxTestAttempts = (int)(currentRange / 2.5f);

                    for (int i = 0; i < maxTestAttempts; i++)
                    {
                        Vector3 newtestPoint = MathEx.GetPointAt(MaxRangeTestVector3, currentRange, directionRadianFlipped);
                        newtestPoint.Z = Navigation.MGP.GetHeight(newtestPoint.ToVector2());//update Z
                        if (Navigation.CanRayCast(startV3, newtestPoint, NavCellFlags.AllowWalk))
                        {
                            MaxRangeTestVector3 = newtestPoint;
                            break;
                        }

                        if (currentRange - 2.5f <= 0f) break;
                        currentRange = -2.5f;
                    }
                    Range = currentRange;
                }

            }

            EndingPoint = MaxRangeTestVector3;
            StartingPoint = startV3;
            Range = startV3.Distance2D(MaxRangeTestVector3); //(float)GridPoint.GetDistanceBetweenPoints(StartingPoint, EndingPoint);
            Center = MathEx.GetPointAt(startV3, Range / 2, MathEx.ToRadians(DirectionDegrees));
        }
开发者ID:herbfunk,项目名称:Funky,代码行数:49,代码来源:DirectionPoint.cs

示例4: Update

 public virtual void Update()
 {
     prevPos = Pos;
     Speed.Y += Gravity * Global.Speed;
     Pos += Speed * Global.Speed;
     Scale += ScaleSpeed * Global.Speed;
     SetVertexPositions();
     //Global.Output += Pos;
     foreach (var b in Behaviors)
     {
         b.Update(this);
     }
     if (MotionStretch)
     {
         stretchRot = -MathHelper.ToDegrees(MyMath.Direction(Pos.ToVector2(), prevPos.ToVector2())) + 90;
         stretchScale = MyMath.Distance((Pos - prevPos).ToVector2().ToVector3()) * 0.04f;
     }
     else
     {
         stretchRot = Rotation;
         stretchScale = 0;
     }
     Depth += 0.000f * Global.Speed;
 }
开发者ID:RIT-Tool-Time,项目名称:Cascade,代码行数:24,代码来源:Particle.cs

示例5: GetMinionsPredictedPositions

        /// <summary>
        ///     Returns a list of predicted minion positions.
        /// </summary>
        /// <param name="minions">
        ///     Given Minion List
        /// </param>
        /// <param name="delay">
        ///     Skill-shot Delay
        /// </param>
        /// <param name="width">
        ///     Skill-shot Width
        /// </param>
        /// <param name="speed">
        ///     Skill-shot Speed
        /// </param>
        /// <param name="from">
        ///     The From
        /// </param>
        /// <param name="range">
        ///     Skill-shot Range
        /// </param>
        /// <param name="collision">
        ///     Has Collision Flag
        /// </param>
        /// <param name="stype">
        ///     Skill-shot Type
        /// </param>
        /// <param name="rangeCheckFrom">
        ///     Range check from Vector3 source
        /// </param>
        /// <returns>
        ///     List of Points in <see cref="Vector2" /> type
        /// </returns>
        public static List<Vector2> GetMinionsPredictedPositions(
            List<Obj_AI_Base> minions, 
            float delay, 
            float width, 
            float speed, 
            Vector3 from, 
            float range, 
            bool collision, 
            SkillshotType stype, 
            Vector3 rangeCheckFrom = new Vector3())
        {
            from = from.ToVector2().IsValid() ? from : ObjectManager.Player.ServerPosition;

            return (from minion in minions
                    select
                        Movement.GetPrediction(
                            new PredictionInput
                                {
                                    Unit = minion, Delay = delay, Radius = width, Speed = speed, From = @from,
                                    Range = range, Collision = collision, Type = stype, RangeCheckFrom = rangeCheckFrom
                                })
                    into pos
                    where pos.Hitchance >= HitChance.High
                    select pos.UnitPosition.ToVector2()).ToList();
        }
开发者ID:47110572,项目名称:CN,代码行数:58,代码来源:Minion.cs

示例6: Add

 /// <summary>
 ///     Converts Vector3 to 2D, then adds it to the points.
 /// </summary>
 /// <param name="point">The Point</param>
 public void Add(Vector3 point)
 {
     this.Points.Add(point.ToVector2());
 }
开发者ID:parkyoungsoo,项目名称:LeagueSharp.SDK,代码行数:8,代码来源:Polygon.cs

示例7: IsInside

 /// <summary>
 ///     Gets if the Vector3 is inside the polygon.
 /// </summary>
 /// <param name="point">The Point</param>
 /// <returns>Whether the Vector3 is inside the polygon</returns>
 public bool IsInside(Vector3 point)
 {
     return !this.IsOutside(point.ToVector2());
 }
开发者ID:parkyoungsoo,项目名称:LeagueSharp.SDK,代码行数:9,代码来源:Polygon.cs

示例8: DrawPoint

 public void DrawPoint(Vector3 point, float overrideZ, float size, Color color, float[,] matrix)
 {
     point = point.Transform(matrix);
     Vector2 min = (point.ToVector2() - new Vector2(size)).ClampVector2(Vector2.Zero, ScreenSize.ToVector2());
     Vector2 max = (point.ToVector2() + new Vector2(size)).ClampVector2(Vector2.Zero, ScreenSize.ToVector2());
     if (overrideZ == 0)
         overrideZ = point.Z;
     for (int xp = (int)min.X; xp < max.X; xp++)
         for (int yp = (int)min.Y; yp < max.Y; yp++)
             DrawPoint(new Vector3(xp ,yp, overrideZ), color, Matrix.GetIdentity());
 }
开发者ID:rubna,项目名称:3dEngine,代码行数:11,代码来源:DrawWrapper.cs

示例9: GetWorldPosition

 public Vector3 GetWorldPosition(Vector3 relativePosition)
 {
     var v2Diff = relativePosition.ToVector2() + Min;
     return new Vector3(v2Diff.X, v2Diff.Y, relativePosition.Z);
 }
开发者ID:mythsya,项目名称:db-plugins,代码行数:5,代码来源:WorldScene.cs

示例10: GetRelativePosition

 public Vector3 GetRelativePosition(Vector3 worldPosition)
 {
     var v2Diff = worldPosition.ToVector2() - Min;
     return new Vector3(v2Diff.X, v2Diff.Y, worldPosition.Z);
 }
开发者ID:mythsya,项目名称:db-plugins,代码行数:5,代码来源:WorldScene.cs

示例11: LinePoly

 /// <summary>
 ///     Initializes a new instance of the <see cref="LinePoly" /> class.
 /// </summary>
 /// <param name="start">
 ///     The Start
 /// </param>
 /// <param name="end">
 ///     The End
 /// </param>
 /// <param name="length">
 ///     Length of line(will be automatically set if -1)
 /// </param>
 public LinePoly(Vector3 start, Vector3 end, float length = -1)
     : this(start.ToVector2(), end.ToVector2(), length)
 {
 }
开发者ID:CjShu,项目名称:LeagueSharp.SDKEx,代码行数:16,代码来源:LinePoly.cs

示例12: RectanglePoly

 /// <summary>
 ///     Initializes a new instance of the <see cref="RectanglePoly" /> class.
 /// </summary>
 /// <param name="start">
 ///     The Start
 /// </param>
 /// <param name="end">
 ///     The End
 /// </param>
 /// <param name="width">
 ///     The Width
 /// </param>
 public RectanglePoly(Vector3 start, Vector3 end, float width)
     : this(start.ToVector2(), end.ToVector2(), width)
 {
 }
开发者ID:CONANLXF,项目名称:Berb.Common,代码行数:16,代码来源:RectanglePoly.cs

示例13: InitVelocityConstraints

        internal override void InitVelocityConstraints(TimeStep step)
        {
            Body b1 = _body1;
            Body b2 = _body2;

            if (_enableMotor || _enableLimit)
            {
                // You cannot create a rotation limit between bodies that
                // both have fixed rotation.
                Box2DXDebug.Assert(b1._invI > 0.0f || b2._invI > 0.0f);
            }

            // Compute the effective mass matrix.
            Vector2 r1 = b1.GetTransform().TransformDirection(_localAnchor1 - b1.GetLocalCenter());
            Vector2 r2 = b2.GetTransform().TransformDirection(_localAnchor2 - b2.GetLocalCenter());

            // J = [-I -r1_skew I r2_skew]
            //     [ 0       -1 0       1]
            // r_skew = [-ry; rx]

            // Matlab
            // K = [ m1+r1y^2*i1+m2+r2y^2*i2,  -r1y*i1*r1x-r2y*i2*r2x,          -r1y*i1-r2y*i2]
            //     [  -r1y*i1*r1x-r2y*i2*r2x, m1+r1x^2*i1+m2+r2x^2*i2,           r1x*i1+r2x*i2]
            //     [          -r1y*i1-r2y*i2,           r1x*i1+r2x*i2,                   i1+i2]

            float m1 = b1._invMass, m2 = b2._invMass;
            float i1 = b1._invI, i2 = b2._invI;

            _mass.Col1.x = m1 + m2 + r1.y * r1.y * i1 + r2.y * r2.y * i2;
            _mass.Col2.x = -r1.y * r1.x * i1 - r2.y * r2.x * i2;
            _mass.Col3.x = -r1.y * i1 - r2.y * i2;
            _mass.Col1.y = _mass.Col2.x;
            _mass.Col2.y = m1 + m2 + r1.x * r1.x * i1 + r2.x * r2.x * i2;
            _mass.Col3.y = r1.x * i1 + r2.x * i2;
            _mass.Col1.z = _mass.Col3.x;
            _mass.Col2.z = _mass.Col3.y;
            _mass.Col3.z = i1 + i2;

            _motorMass = 1.0f / (i1 + i2);

            if (_enableMotor == false)
            {
                _motorImpulse = 0.0f;
            }

            if (_enableLimit)
            {
                float jointAngle = b2._sweep.A - b1._sweep.A - _referenceAngle;
                if (Box2DXMath.Abs(_upperAngle - _lowerAngle) < 2.0f * Settings.AngularSlop)
                {
                    _limitState = LimitState.EqualLimits;
                }
                else if (jointAngle <= _lowerAngle)
                {
                    if (_limitState != LimitState.AtLowerLimit)
                    {
                        _impulse.z = 0.0f;
                    }
                    _limitState = LimitState.AtLowerLimit;
                }
                else if (jointAngle >= _upperAngle)
                {
                    if (_limitState != LimitState.AtUpperLimit)
                    {
                        _impulse.z = 0.0f;
                    }
                    _limitState = LimitState.AtUpperLimit;
                }
                else
                {
                    _limitState = LimitState.InactiveLimit;
                    _impulse.z = 0.0f;
                }
            }
            else
            {
                _limitState = LimitState.InactiveLimit;
            }

            if (step.WarmStarting)
            {
                // Scale impulses to support a variable time step.
                _impulse *= step.DtRatio;
                _motorImpulse *= step.DtRatio;

                Vector2 P = _impulse.ToVector2();

                b1._linearVelocity -= m1 * P;
                b1._angularVelocity -= i1 * (r1.Cross(P) + _motorImpulse + _impulse.z);

                b2._linearVelocity += m2 * P;
                b2._angularVelocity += i2 * (r2.Cross(P) + _motorImpulse + _impulse.z);
            }
            else
            {
                _impulse = Vector3.zero;
                _motorImpulse = 0.0f;
            }
        }
开发者ID:imnotanderson,项目名称:Box2dUnity,代码行数:99,代码来源:RevoluteJoint.cs

示例14: OnSceneGUI


//.........这里部分代码省略.........
            if(Event.current.button == 0)
            {
                //draw the dragwindow
                if(GUIUtility.hotControl == controlID)
                {
                    Ray worldRay = HandleUtility.GUIPointToWorldRay (Event.current.mousePosition);
                    mouseDragRectEndPos =  new Vector2(worldRay.origin.x, worldRay.origin.y);

                    float selectionRectangleWidth = mouseDragRectEndPos.x - mouseDragRectStartPos.x;
                    float selectionRectangleHeight = mouseDragRectEndPos.y - mouseDragRectStartPos.y;

                    if(!drawSelectionRectangle)
                        drawSelectionRectangle = true;

                    selectionRectangleVerts[0] = new Vector3(mouseDragRectStartPos.x,
                                                             mouseDragRectStartPos.y,
                                                             0f);
                    selectionRectangleVerts[1] = new Vector3(mouseDragRectStartPos.x + selectionRectangleWidth,
                                                             mouseDragRectStartPos.y,
                                                             0f);
                    selectionRectangleVerts[2] = new Vector3(mouseDragRectStartPos.x + selectionRectangleWidth,
                                                             (mouseDragRectStartPos.y + selectionRectangleHeight),
                                                             0f);
                    selectionRectangleVerts[3] = new Vector3(mouseDragRectStartPos.x,
                                                             (mouseDragRectStartPos.y + selectionRectangleHeight),
                                                             0f);
                }
            }

            Event.current.Use();
            break;

        case EventType.MouseUp:

            if(GUIUtility.hotControl == controlID)
            {
                GUIUtility.hotControl = 0;

                //Selection Rectangle Position
                List<Vector2> selectionPositions = new List<Vector2>();

                if(drawSelectionRectangle)
                {
                    //Get a collection of all the vert indexes that are within the rectangle valume just drawn
                    List <int> indexesOfVertsWithinSelectionRectangleNew = new List<int>();
                    for(int i = 0; i < generatedMesh.verts.Length; i++)
                    {
                        if(generatedMesh.verts[i].ToVector2().isPositionWithinRectangleVolume(mouseDragRectStartPos - meshPosition,
                                                                                                      mouseDragRectEndPos - meshPosition))
                        {
                            indexesOfVertsWithinSelectionRectangleNew.Add(i);
                            selectionPositions.Add(generatedMesh.verts[i].ToVector2());
                        }
                    }

                    if(indexesOfVertsWithinSelectionRectangle.Count > 0)
                        indexesOfVertsWithinSelectionRectangle.Clear();

                    indexesOfVertsWithinSelectionRectangle = indexesOfVertsWithinSelectionRectangleNew;

                    selectedVertsCentrePoint = selectionPositions.GetCenterPointFromCollection() + meshPosition.ToVector2();

                    drawSelectionRectangle = false;
                }
                else
                    if(indexesOfVertsWithinSelectionRectangle.Count > 0)
                        indexesOfVertsWithinSelectionRectangle.Clear();
            }

            Event.current.Use();
            break;

            //Exit the selection of this gameobject
        case EventType.KeyDown:

            Event e = Event.current;
            if(e.keyCode == KeyCode.Escape)
                Selection.activeGameObject = null;

            //If multiple verts are currently selected, delete them
            if(e.keyCode == KeyCode.Delete)
            {
                if(indexesOfVertsWithinSelectionRectangle.Count > 0)
                {
                    generatedMesh.DeleteVertPositions(indexesOfVertsWithinSelectionRectangle.ToArray());
                    indexesOfVertsWithinSelectionRectangle.Clear();
                    generatedMesh.CalculateVerts();
                }
            }

            GUIUtility.hotControl = 0;
            Event.current.Use();
            break;
        }

        #endregion

        if(GUI.changed)
            EditorUtility.SetDirty(target);
    }
开发者ID:matski53,项目名称:2DPolyGen,代码行数:101,代码来源:MeshGen2DEditor.cs

示例15: Update

    void Update()
    {
        // Read input
        if (Input.GetButtonDown("Inventory")) {
            SetHUDVisable(true);
        }

        if (isOpen) {
            for (int slot = 1; slot <= 4; slot++) {
                if (hoverKey == slot - 1 && Input.GetButtonUp("Slot " + slot)) {
                    SetHUDVisable(false);
                    inventory.Equip(hoverKey);
                    return;
                }
            }

            // Hotkeys
            bool allUp = true;
            for (int slot = 1; slot <= 4; slot++) {
                if (Input.GetButtonDown("Slot " + slot)) {
                    hoverKey = slot - 1;
                }
                if (Input.GetButton("Slot "+ slot)) {
                    allUp = false;
                }
            }
            if (allUp) hoverKey = -1;

            // Mouse
            if (hoverKey == -1) {
                mouseDelta = CalcMouseDelta();
                hoverMouse = CalcSelected(mouseDelta.ToVector2());

                if (hoverMouse != -1 && Input.GetMouseButtonUp(0)) {
                    SetHUDVisable(false);
                    inventory.Equip(hoverMouse);
                    return;
                }
            }

            SetHover(hoverKey == -1 ? hoverMouse : hoverKey);

            // Close inventory
            if (Input.GetButtonUp("Inventory")) {
                SetHUDVisable(false);
                if (hoverKey != -1)
                    inventory.Equip(hoverKey);
                else if (inventory.equipped != null && inventory.equipped is _CoreItem)
                    inventory.Unequip();
            }
        }
    }
开发者ID:Turnary-Games,项目名称:Battery-Golem,代码行数:52,代码来源:PlayerHUD.cs


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