Constraint which tries to push an entity to a desired location.
Inheritance: SingleEntityConstraint, I3DImpulseConstraintWithError
Example #1
0
        public Rocket(RocketData data, Vector3 position, Quaternion orientation)
            : base(new Sphere(position, data.HitboxRadius, 5),data.ModelID)
        {
            Data = data;
            float x = (float)(ProjectileData.pRandom.NextDouble() - 0.5f) * data.BulletSpread;
            float y = (float)(ProjectileData.pRandom.NextDouble() - 0.5f) * data.BulletSpread;
            Quaternion random = Quaternion.CreateFromYawPitchRoll(MathHelper.ToRadians(x), MathHelper.ToRadians(y), 0);
            orientation = random * orientation;
            Vector3 velocity = Vector3.Transform(new Vector3(0,0,-Data.MuzzleVel), orientation);
            Entity.LinearVelocity = velocity;
            forwardVel = Data.MuzzleVel;
            Entity.Orientation = orientation;

            currentFuel = Data.Fuel;
            currentLife = Data.Lifetime;

            rocketMotor = new SingleEntityLinearMotor(Entity, Entity.Position);
            rocketMotor.Settings.Mode = MotorMode.VelocityMotor;
            Sector.Redria.Space.Add(rocketMotor);
            trackingMotor = new SingleEntityAngularMotor(Entity);
            trackingMotor.Settings.Mode = MotorMode.Servomechanism;
            trackingMotor.Settings.Servo.MaxCorrectiveVelocity = 1.5f;
            trackingMotor.Settings.Servo.Goal = orientation;
            Sector.Redria.Space.Add(trackingMotor);
            Entity.CollisionInformation.Events.InitialCollisionDetected += Events_InitialCollisionDetected;
        }
Example #2
0
        /// <summary>
        /// Constructs a new EntityMover.
        /// </summary>
        /// <param name="e">Entity to move.</param>
        public EntityMover(Entity e)
        {
            IsUpdatedSequentially = false;
            LinearMotor = new SingleEntityLinearMotor(e, e.Position);
            Entity = e;

            LinearMotor.Settings.Mode = MotorMode.Servomechanism;
            TargetPosition = e.Position;
        }
Example #3
0
        /// <summary>
        /// Constructs a new EntityMover.
        /// </summary>
        /// <param name="e">Entity to move.</param>
        /// <param name="linearMotor">Motor to use for linear motion if the entity is dynamic.</param>
        public EntityMover(Entity e, SingleEntityLinearMotor linearMotor)
        {
            IsUpdatedSequentially = false;
            LinearMotor = linearMotor;
            Entity = e;

            linearMotor.Entity = Entity;
            linearMotor.Settings.Mode = MotorMode.Servomechanism;
            TargetPosition = e.Position;
        }
        /// <summary>
        /// Constructs a grab constraint.
        /// </summary>
        public MotorizedGrabSpring()
        {
            //Note that when the motor is created using the empty constructor,
            //it starts deactivated.  This prevents explosions from attempting
            //to update it without being configured.
            linearMotor = new SingleEntityLinearMotor();
            angularMotor = new SingleEntityAngularMotor();
            linearMotor.Settings.Mode = MotorMode.Servomechanism;

            //The stiffness, damping, and maximum force could be assigned during setup if the motor
            //needs to behave similarly for entities of varying masses.  When using a fixed configuration,
            //the grabspring will behave weakly when trying to move extremely heavy objects, while staying
            //very responsive for sufficiently light objects.

            IsUpdating = false;
        }
Example #5
0
        public ShipObj(Vector3 position, Quaternion orientation, ShipData data)
            : base()
        {
            Data = data;
            Data.ComposeHitbox();
            Data.Hitbox.Position = position;
            Data.Hitbox.Orientation = orientation;
            this.SetEntity(Data.Hitbox, 2);

            Health = Data.TotalArmor;
            Thrusters = new SingleEntityLinearMotor(Entity, Position);
            ControlSurfaces = new SingleEntityAngularMotor(Entity);
            ControlSurfaces.Settings.Mode = MotorMode.Servomechanism;

            Thrusters.Settings.Mode = MotorMode.VelocityMotor;
            Thrusters.Settings.VelocityMotor.Softness = 0.002f;
            Entity.IsAffectedByGravity = true;

            Sector.Redria.Space.Add(Thrusters);
            Sector.Redria.Space.Add(ControlSurfaces);
            Network.AddShip();
        }