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

C# LinearMath.JVector类代码示例

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

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



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

示例1: PointOnPoint

        /// <summary>
        /// Initializes a new instance of the DistanceConstraint class.
        /// </summary>
        /// <param name="body1">The first body.</param>
        /// <param name="body2">The second body.</param>
        /// <param name="anchor1">The anchor point of the first body in world space. 
        /// The distance is given by the initial distance between both anchor points.</param>
        /// <param name="anchor2">The anchor point of the second body in world space.
        /// The distance is given by the initial distance between both anchor points.</param>
        public PointOnPoint(RigidBody body, JVector localAnchor)
            : base(body, null)
        {
            localAnchor1 = localAnchor;

            this.anchor = body.position + JVector.Transform(localAnchor, body.orientation);
        }
开发者ID:onefiftyone,项目名称:jitterphysics,代码行数:16,代码来源:PointOnPoint.cs


示例2: SupportMapping

        /// <summary>
        /// SupportMapping. Finds the point in the shape furthest away from the given direction.
        /// Imagine a plane with a normal in the search direction. Now move the plane along the normal
        /// until the plane does not intersect the shape. The last intersection point is the result.
        /// </summary>
        /// <param name="direction">The direction.</param>
        /// <param name="result">The result.</param>
        public override void SupportMapping(ref JVector direction, out JVector result)
        {
            result = direction;
            result.Normalize();

            JVector.Multiply(ref result, radius, out result);
        }
开发者ID:onefiftyone,项目名称:jitterphysics,代码行数:14,代码来源:SphereShape.cs


示例3: TraceResult

 public TraceResult(RigidBody body, float distance, JVector position, JVector normal)
 {
     this.Body = body;
     this.Distance = distance;
     this.Position = position;
     this.Normal = normal;
 }
开发者ID:MasterQ32,项目名称:BlocksWorld,代码行数:7,代码来源:TraceResult.cs


示例4: DrawAabb

        public void DrawAabb(JVector from, JVector to, Color color)
        {
            JVector halfExtents = (to - from) * 0.5f;
            JVector center = (to + from) * 0.5f;

            JVector edgecoord = new JVector(1f, 1f, 1f), pa, pb;
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    pa = new JVector(edgecoord.X * halfExtents.X, edgecoord.Y * halfExtents.Y,
                        edgecoord.Z * halfExtents.Z);
                    pa += center;

                    int othercoord = j % 3;
                    SetElement(ref edgecoord, othercoord, GetElement(edgecoord, othercoord) * -1f);
                    pb = new JVector(edgecoord.X * halfExtents.X, edgecoord.Y * halfExtents.Y,
                        edgecoord.Z * halfExtents.Z);
                    pb += center;

                    DrawLine(pa, pb, color);
                }
                edgecoord = new JVector(-1f, -1f, -1f);
                if (i < 3)
                    SetElement(ref edgecoord, i, GetElement(edgecoord, i) * -1f);
            }
        }
开发者ID:JacobNorlin,项目名称:project-duck,代码行数:27,代码来源:DebugDrawer.cs


示例5: Iterate

        public override void Iterate()
        {
            deltaVelocity = TargetVelocity - Body1.LinearVelocity;
            deltaVelocity.Y = 0.0f;

            // determine how 'stiff' the character follows the target velocity
            deltaVelocity *= 0.005f;

            if (deltaVelocity.LengthSquared() != 0.0f)
            {
                // activate it, in case it fall asleep :)
                Body1.IsActive = true;
                Body1.ApplyImpulse(deltaVelocity * Body1.Mass);
            }

            if (shouldIJump)
            {
                Body1.IsActive = true;
                Body1.ApplyImpulse(JumpVelocity * JVector.Up * Body1.Mass);
                System.Diagnostics.Debug.WriteLine("JUMP! " + DateTime.Now.Second.ToString());

                if (!BodyWalkingOn.IsStatic)
                {
                    BodyWalkingOn.IsActive = true;
                    // apply the negative impulse to the other body
                    BodyWalkingOn.ApplyImpulse(-1.0f * JumpVelocity * JVector.Up * Body1.Mass);
                }

            }
        }
开发者ID:apeape,项目名称:Xen-Game-Client,代码行数:30,代码来源:CharacterController.cs


示例6: Iterate

        public override void Iterate()
        {
            deltaVelocity = TargetVelocity - Body1.LinearVelocity;
            deltaVelocity.Y = 0.0f;

            // determine how 'stiff' the character follows the target velocity
            deltaVelocity *= 0.02f;

            if (deltaVelocity.LengthSquared() != 0.0f)
            {
                // activate it, in case it fall asleep :)
                Body1.IsActive = true;
                Body1.ApplyImpulse(deltaVelocity * Body1.Mass);
            }

            if (shouldIJump)
            {
                Body1.IsActive = true;
                Body1.ApplyImpulse(jumpVelocity * JVector.Up * Body1.Mass);

                if (!BodyWalkingOn.IsStatic)
                {
                    BodyWalkingOn.IsActive = true;
                    // apply the negative impulse to the other body
                    BodyWalkingOn.ApplyImpulse(-1.0f * jumpVelocity * JVector.Up * Body1.Mass);
                }
            }
        }
开发者ID:kkestell,项目名称:nyx-1.0,代码行数:28,代码来源:ImpulseConstraint.cs


示例7: CanJump

        public bool CanJump(RigidBody body)
        {
            Body = WorldItems[body];

            Jitter.Dynamics.RigidBody resultingBody = null;
            JVector normal;
            float fraction;

            var positions = new JVector[] { new JVector(body.Position.X, body.Position.Y, body.Position.Z),
                                            new JVector(body.Position.X + 0.5f, body.Position.Y, body.Position.Z),
                                            new JVector(body.Position.X - 0.5f, body.Position.Y, body.Position.Z),
                                            new JVector(body.Position.X, body.Position.Y, body.Position.Z - 0.5f),
                                            new JVector(body.Position.X, body.Position.Y, body.Position.Z + 0.5f)};

            for (int i = 0; i < positions.Length; i++)
            {
                bool result = World.CollisionSystem.Raycast(new JVector(positions[i].X, positions[i].Y, positions[i].Z),
                                                            new JVector(0, -1, 0),
                                                            RaycastCallback,
                                                            out resultingBody,
                                                            out normal,
                                                            out fraction);

                if (result && fraction <= 1.3f && Body.LinearVelocity.Y < 0.5f)
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:JohanGl,项目名称:Outworld-XNA,代码行数:31,代码来源:CollisionSystem.cs


示例8: AddCar

        public void AddCar(JVector position)
        {
            car = new CarObject(Demo);
            this.Demo.Components.Add(car);

            car.carBody.Position = position;
        }
开发者ID:RainsSoft,项目名称:jitterphysics,代码行数:7,代码来源:Scene.cs


示例9: Iterate

        public override void Iterate()
        {
            DeltaVelocity = TargetVelocity - Body1.LinearVelocity;
            DeltaVelocity.Y = 0.0f;

            var fraction = 0.02f;
            if (WalkingOn == null)
                fraction = 0.0001f;
            DeltaVelocity *= fraction;

            if (DeltaVelocity.LengthSquared() != 0.0f)
            {
                Body1.IsActive = true;
                Body1.ApplyImpulse(DeltaVelocity * Body1.Mass);
            }

            if (ShouldJump)
            {
                Body1.IsActive = true;
                Body1.ApplyImpulse(JumpVelocity * JVector.Up * Body1.Mass);

                if (!WalkingOn.IsStatic)
                {
                    WalkingOn.IsActive = true;
                    WalkingOn.ApplyImpulse(-1.0f * JumpVelocity * JVector.Up * Body1.Mass);
                }
            }
        }
开发者ID:johang88,项目名称:triton,代码行数:28,代码来源:CharacterControllerConstraint.cs


示例10: Update

 protected override void Update()
 {
     base.Update();
     if (form.MouseClickedHappenend)
     {
         form.MouseClickedHappenend = false;
         var screenPosition = new JVector(
             -1f + 2* (form.MouseClickPosition.x / form.ClientSize.Width),
             1, -1f + 2 * ((form.MouseClickPosition.y / form.ClientSize.Height)));
         var projectionMatrix = Common.ProjectionMatrix;
         JMatrix jMatrix = new JMatrix(
             projectionMatrix.M11, projectionMatrix.M12, projectionMatrix.M13,
             projectionMatrix.M21, projectionMatrix.M22, projectionMatrix.M23,
             projectionMatrix.M31, projectionMatrix.M32, projectionMatrix.M33);
         JMatrix invertedJMatrix;
     JMatrix.Invert(ref jMatrix, out invertedJMatrix);
         var rayDirection = JVector.Transform(screenPosition, invertedJMatrix);
         RigidBody body;
         JVector normal;
         float fraction;
         Entities.world3D.CollisionSystem.Raycast(JitterDatatypes.ToJVector(Common.CameraPosition),
             rayDirection, null, out body, out normal, out fraction);
         if (body != null && !body.IsStatic)
             body.ApplyImpulse(rayDirection * 200);
     }
 }
开发者ID:BenjaminNitschke,项目名称:PhysicsCourse,代码行数:26,代码来源:JointsPhysics3D.cs


示例11: Build

        public override void Build()
        {
            AddGround();

            for (int i = 0; i < 11; i++)
            {
                RigidBody box = new RigidBody(new BoxShape(1,0.01f,1));
                this.Demo.World.AddBody(box);
                JVector boxPos = new JVector(-15 + i * 3 + 1, 5, 0);

                box.Position = boxPos;
                box.IsStatic = true;

                RigidBody sphere = new RigidBody(new SphereShape(0.5f));
                this.Demo.World.AddBody(sphere);

                sphere.Position = boxPos + JVector.Up * 30;
                sphere.EnableSpeculativeContacts = true;

                // set restitution
                sphere.Material.Restitution = box.Material.Restitution = 1.0f / 10.0f * i;
                sphere.LinearVelocity = new JVector(0, 0, 0);
    

                sphere.Damping = RigidBody.DampingType.Angular;
            }

         
        }
开发者ID:RainsSoft,项目名称:jitterphysics,代码行数:29,代码来源:Restitution.cs


示例12: Buoyancy

 /// <summary>
 /// Creates a new instance of the FluidVolume class.
 /// </summary>
 /// <param name="world">The world.</param>
 public Buoyancy(World world)
     : base(world)
 {
     Density = 2.0f;
     Damping = 0.1f;
     Flow = JVector.Zero;
 }
开发者ID:RainsSoft,项目名称:jitterphysics,代码行数:11,代码来源:Buoyancy.cs


示例13: TransformedShape

 /// <summary>
 /// Creates a new instance of the TransformedShape struct.
 /// </summary>
 /// <param name="shape">The shape.</param>
 /// <param name="orientation">The orientation this shape should have.</param>
 /// <param name="position">The position this shape should have.</param>
 public TransformedShape(Shape shape, JMatrix orientation, JVector position)
 {
     this.position = position;
     this.orientation = orientation;
     JMatrix.Transpose(ref orientation, out invOrientation);
     this.shape = shape;
 }
开发者ID:tpb3d,项目名称:TPB3D,代码行数:13,代码来源:CompoundShape.cs


示例14: HandleCollision

        /// <summary>
        /// This method handles explicit object collision logic. Is registered to physics engine CollisionDetected event handler.
        /// Fired on any detected collision, so must check if the collision applies to this object
        /// </summary>
        /// <param name="body1"></param>
        /// <param name="body2"></param>
        /// <param name="point1"></param>
        /// <param name="point2"></param>
        /// <param name="normal"></param>
        /// <param name="penetration"></param>
        virtual public void HandleCollision(RigidBody body1, RigidBody body2, JVector point1, JVector point2, JVector normal, float penetration)
        {
            // work out which, if any, of the collided bodies is this object, and name them semantically
            RigidBody other;
            var self = this.PhysicsDescription;
            if (body1 == self)
                other = body2;
            else if (body2 == self)
                other = body1;
            else return;

            if (other == this.flock.level.endGoal.PhysicsDescription) // we've collided with the end zone
            {
                // be careful of what you modify in this handler as it may be called during an Update()
                // attempting to modify any list (such as destroying game objects, etc) will cause an exception

                if (!ToDestroy) // incremement score once before destroy
                {
                    this.game.incScore(10);
                }
                this.Destroy(true); // remove self
            }    

            Collision(other); // do other collision stuff
        }
开发者ID:nuclearpidgeon,项目名称:graphicsproj2,代码行数:35,代码来源:Boid.cs


示例15: ToMatrix4

 public static Matrix4 ToMatrix4(JMatrix orientation, JVector position)
 {
     return new Matrix4(
         orientation.M11, orientation.M12, orientation.M13, 0,
         orientation.M21, orientation.M22, orientation.M23, 0,
         orientation.M31, orientation.M32, orientation.M33, 0,
         position.X, position.Y, position.Z, 1);
 }
开发者ID:BenjaminNitschke,项目名称:PhysicsCourse,代码行数:8,代码来源:JitterMath.cs


示例16: ToMatrix4

 public static Matrix4 ToMatrix4(JMatrix m, JVector position)
 {
     return new Matrix4(
         m.M11, m.M12, m.M13, 0,
         m.M21, m.M22, m.M23, 0,
         m.M31, m.M32, m.M33, 0,
         position.X, position.Y, position.Z, 1);
 }
开发者ID:BenjaminNitschke,项目名称:PhysicsCourse,代码行数:8,代码来源:JitterDatatypes.cs


示例17: DrawPoint

 public void DrawPoint(JVector pos)
 {
     GL.End();
     GL.Begin(BeginMode.Points);
     GL.Vertex3(pos.X, pos.Y, pos.Z);
     GL.End();
     GL.Begin(BeginMode.Lines);
 }
开发者ID:jyunfan2015,项目名称:Calcifer,代码行数:8,代码来源:DebugDrawNode.cs


示例18: HandleInput

        public void HandleInput(GameTime gameTime)
        {
            currentTime += (float)gameTime.ElapsedGameTime.Milliseconds;

            KeyboardState keys = Keyboard.GetState();

            if (keys.IsKeyDown(Keys.Up))
            {
                float x = (float)Math.Sin(facing);
                float z = (float)Math.Cos(facing);

                JVector newPath = new JVector(x, 0f, z) * speed;
                newPath = newPath * currentTime;
                newPath.Normalize();

                forward = newPath;

                body.AddForce(newPath*100f);
                //position = body.Position;
                //position += newPath;

                //body.Position = position;
            }

            if (keys.IsKeyDown(Keys.Left))
            {
                facing -= 0.05f;
            }

            if (keys.IsKeyDown(Keys.Right))
            {
                facing += 0.05f;
            }

            if (keys.IsKeyDown(Keys.Down))
            {
                float x = (float)Math.Sin(facing);
                float z = (float)Math.Cos(facing);

                JVector newPath = new JVector(x, 0f, z) * speed;
                newPath = newPath * currentTime;
                newPath.Normalize();

                body.AddForce(newPath * -100f);
            }

            if (keys.IsKeyDown(Keys.Space))
            {
                body.AddForce(JVector.Up * 100f);
            }

            /*if (keys.IsKeyDown(Keys.A))

            if (keys.IsKeyDown(Keys.S))

            if (keys.IsKeyDown(Keys.W))
            */
        }
开发者ID:scy7he,项目名称:Pong,代码行数:58,代码来源:Player.cs


示例19: LimitedHingeJoint

        /// <summary>
        /// Initializes a new instance of the HingeJoint class.
        /// </summary>
        /// <param name="world">The world class where the constraints get added to.</param>
        /// <param name="body1">The first body connected to the second one.</param>
        /// <param name="body2">The second body connected to the first one.</param>
        /// <param name="position">The position in world space where both bodies get connected.</param>
        /// <param name="hingeAxis">The axis if the hinge.</param>
        public LimitedHingeJoint(World world, RigidBody body1, RigidBody body2, JVector position, JVector hingeAxis,
            float hingeFwdAngle, float hingeBckAngle)
            : base(world)
        {
            // Create the hinge first, two point constraints

            worldPointConstraint = new PointOnPoint[2];

            hingeAxis *= 0.5f;

            JVector pos1 = position; JVector.Add(ref pos1, ref hingeAxis, out pos1);
            JVector pos2 = position; JVector.Subtract(ref pos2, ref hingeAxis, out pos2);

            worldPointConstraint[0] = new PointOnPoint(body1, body2, pos1);
            worldPointConstraint[1] = new PointOnPoint(body1, body2, pos2);


            // Now the limit, one max distance constraint

            hingeAxis.Normalize();

            // choose a direction that is perpendicular to the hinge
            JVector perpDir = JVector.Up;

            if (JVector.Dot(perpDir, hingeAxis) > 0.1f) perpDir = JVector.Right;

            // now make it perpendicular to the hinge
            JVector sideAxis = JVector.Cross(hingeAxis, perpDir);
            perpDir = JVector.Cross(sideAxis, hingeAxis);
            perpDir.Normalize();

            // the length of the "arm" TODO take this as a parameter? what's
            // the effect of changing it?
            float len = 10.0f * 3;

            // Choose a position using that dir. this will be the anchor point
            // for body 0. relative to hinge
            JVector hingeRelAnchorPos0 = perpDir * len;


            // anchor point for body 2 is chosen to be in the middle of the
            // angle range.  relative to hinge
            float angleToMiddle = 0.5f * (hingeFwdAngle - hingeBckAngle);
            JVector hingeRelAnchorPos1 = JVector.Transform(hingeRelAnchorPos0, JMatrix.CreateFromAxisAngle(hingeAxis, -angleToMiddle / 360.0f * 2.0f * JMath.Pi));

            // work out the "string" length
            float hingeHalfAngle = 0.5f * (hingeFwdAngle + hingeBckAngle);
            float allowedDistance = len * 2.0f * (float)System.Math.Sin(hingeHalfAngle * 0.5f / 360.0f * 2.0f * JMath.Pi);

            JVector hingePos = body1.Position;
            JVector relPos0c = hingePos + hingeRelAnchorPos0;
            JVector relPos1c = hingePos + hingeRelAnchorPos1;

            distance = new PointPointDistance(body1, body2, relPos0c, relPos1c);
            distance.Distance = allowedDistance;
            distance.Behavior = PointPointDistance.DistanceBehavior.LimitMaximumDistance;

        }
开发者ID:RainsSoft,项目名称:jitterphysics,代码行数:66,代码来源:LimitedHingeJoint.cs


示例20: PointOnPoint

        /// <summary>
        /// Initializes a new instance of the DistanceConstraint class.
        /// </summary>
        /// <param name="body1">The first body.</param>
        /// <param name="body2">The second body.</param>
        /// <param name="anchor1">The anchor point of the first body in world space. 
        /// The distance is given by the initial distance between both anchor points.</param>
        /// <param name="anchor2">The anchor point of the second body in world space.
        /// The distance is given by the initial distance between both anchor points.</param>
        public PointOnPoint(RigidBody body1, RigidBody body2, JVector anchor)
            : base(body1, body2)
        {
            JVector.Subtract(ref anchor, ref body1.position, out localAnchor1);
            JVector.Subtract(ref anchor, ref body2.position, out localAnchor2);

            JVector.Transform(ref localAnchor1, ref body1.invOrientation, out localAnchor1);
            JVector.Transform(ref localAnchor2, ref body2.invOrientation, out localAnchor2);
        }
开发者ID:MagistrAVSH,项目名称:my-spacegame-engine,代码行数:18,代码来源:PointOnPoint.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# LinearMath.JVector类代码示例发布时间:2022-05-26
下一篇:
C# LinearMath.JMatrix类代码示例发布时间: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