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


C# LinearMath.JVector类代码示例

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


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


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