Constraint which attempts to restrict the relative angular velocity of two entities to some value. Can use a target relative orientation to apply additional force.
Inheritance: SingleEntityConstraint, I3DImpulseConstraintWithError
Esempio n. 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;
        }
Esempio n. 2
0
        /// <summary>
        /// Constructs a new EntityRotator.
        /// </summary>
        /// <param name="e">Entity to move.</param>
        public EntityRotator(Entity e)
        {
            IsUpdatedSequentially = false;
            AngularMotor = new SingleEntityAngularMotor(e);
            Entity = e;

            AngularMotor.Settings.Mode = MotorMode.Servomechanism;
            TargetOrientation = e.Orientation;
        }
        /// <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;
        }
Esempio n. 4
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();
        }