コード例 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="world"></param>
        public ForceGenerator(World world)
        {
            this.world = world;

            preStep = new World.WorldStep(PreStep);
            postStep = new World.WorldStep(PostStep);

            world.Events.PostStep += postStep;
            world.Events.PreStep += preStep;
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="world"></param>
        public ForceGenerator(World world)
        {
            this.world = world;

            preStep  = new World.WorldStep(PreStep);
            postStep = new World.WorldStep(PostStep);

            world.Events.PostStep += postStep;
            world.Events.PreStep  += preStep;
        }
コード例 #3
0
ファイル: DefaultCar.cs プロジェクト: tpb3d/TPB3D
        /// <summary>
        /// Initializes a new instance of the DefaultCar class.
        /// </summary>
        /// <param name="world">The world the car should be in.</param>
        /// <param name="shape">The shape of the car. Recommend is a box shape.</param>
        public DefaultCar(World world,Shape shape) : base(shape)
        {
            this.world = world;
            postStep = new World.WorldStep(world_PostStep);

            world.Events.PostStep += postStep;

            // set some default values
            this.AccelerationRate = 5.0f;
            this.SteerAngle = 20.0f;
            this.DriveTorque = 50.0f;
            this.SteerRate = 5.0f;

            // create default wheels
            wheels[(int)WheelPosition.FrontLeft] = new Wheel(world, this, JVector.Left + 1.8f * JVector.Forward + 0.8f * JVector.Down,0.4f);
            wheels[(int)WheelPosition.FrontRight] = new Wheel(world, this, JVector.Right + 1.8f * JVector.Forward + 0.8f * JVector.Down, 0.4f);
            wheels[(int)WheelPosition.BackLeft] = new Wheel(world, this, JVector.Left + 1.8f * JVector.Backward + 0.8f * JVector.Down, 0.4f);
            wheels[(int)WheelPosition.BackRight] = new Wheel(world, this, JVector.Right + 1.8f * JVector.Backward + 0.8f * JVector.Down, 0.4f);

            AdjustWheelValues();
        }
コード例 #4
0
ファイル: Wheel.cs プロジェクト: tpb3d/TPB3D
        /// <summary>
        /// Creates a new instance of the Wheel class.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="car">The RigidBody on which to apply the wheel forces.</param>
        /// <param name="position">The position of the wheel on the body (in body space).</param>
        /// <param name="radius">The wheel radius.</param>
        public Wheel(World world,RigidBody car,JVector position,float radius)
        {
            this.world = world;
            this.car = car;
            this.Position = position;
            
            raycast = new RaycastCallback(RaycastCallback);

            preStep = new World.WorldStep(PreStep);
            postStep = new World.WorldStep(PostStep);

            world.Events.PreStep += preStep;
            world.Events.PostStep += postStep;

            // set some default values.
            this.SideFriction = 1.5f;
            this.ForwardFriction = 1f;
            this.Radius = radius;
            this.Inertia = 1.0f;
            this.WheelTravel = 0.2f;
            this.MaximumAngularVelocity = 200;
            this.NumberOfRays = 5;
        }