コード例 #1
0
ファイル: EnemyBoat.cs プロジェクト: nagyistoce/flightsim
        Vector3 vTarget_Position = Vector3.Zero; //position of target aircraft (aka the player)

        #endregion Fields

        #region Constructors

        public EnemyBoat(Vector3 startpos)
            : base(GameState.Get().Game.Content.Load<Model>("blahship"))
        {
            m_SpriteBatch = new SpriteBatch(GraphicsManager.Get().GraphicsDevice);
               // Capsule massCapsule = new Capsule(new Vector3(5, 0, 0), Vector3.Zero, 44);
            Capsule massCapsule = new Capsule(new Vector3(400, 0, 0), new Vector3(-100,  0, 0), 450);
            Vector3 center = Vector3.Zero;
            MassProperties mp = MassProperties.FromCapsule(05.15f, massCapsule.P1, massCapsule.P2, massCapsule.Radius, out center);
            this.MassProperties = mp;
            this.Skin.Add(new CapsulePart(massCapsule));

            this.SetWorld(100f, startpos, Quaternion.CreateFromAxisAngle(Vector3.UnitY, 0f));

            health = 100.0f;
        }
コード例 #2
0
        private void initialize()
        {
            SetWorld(7f,
                 new Vector3(0, 2, 00),
                 Quaternion.CreateFromAxisAngle(Vector3.UnitY, (float)Math.PI/5));
            LinearVelocity = Vector3.Zero;
            AngularVelocity = Vector3.Zero;

            Capsule capsule = new Capsule(new Vector3(10, 0, 0), Vector3.Zero, 5);
            Vector3 center = new Vector3(5, 0, 0);

            MassProperties mp = MassProperties.FromCapsule(100f, capsule.P1, capsule.P2, capsule.Radius, out center);
            this.MassProperties = mp;

               this.Skin.Add(new CapsulePart(capsule));
               //  this.Skin.Add(collide);
        }
コード例 #3
0
ファイル: Missile.cs プロジェクト: nagyistoce/flightsim
        public Missile(PhysicsManager physicsenabler, float damage)
            : base(GameState.Get().Game.Content.Load<Model>("missile"))
        {
            this.Damage = damage;
            this.pm = physicsenabler;
            SetWorld(1f,
                    new Vector3(110, 10, 110),
                    Quaternion.CreateFromAxisAngle(Vector3.UnitY, (float)Math.PI / 5));//* Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (float)Math.PI / 4));
            LinearVelocity = Vector3.Zero;
            AngularVelocity = Vector3.Zero;

            this.m_dragModule = new LinearDragModule(this, LINEAR_DRAG_COEFFICIENT);
            this.m_thrustModule = new ThrustModule(this, THRUST_MULTIPLIER, 1f, MAX_FUEL);
            this.m_angDragModule = new AngularDragModule(this, ANGULAR_DRAG_COEFFICIENT);

            Capsule capsule = new Capsule(new Vector3(5, 0, 0), Vector3.Zero, 1);
            Vector3 center = new Vector3(2.5f, 0, 0);
            MassProperties mp = MassProperties.FromCapsule(0.15f, capsule.P1, capsule.P2, capsule.Radius, out center);
            this.MassProperties = mp;
            this.Skin.Add(new CapsulePart(capsule));
        }
コード例 #4
0
ファイル: Capsule.cs プロジェクト: jdddog/jengasimulatorp4p
		/// <summary>
		/// Attempts to encapsulate a cloud of points within a capsule. This may not produce an optimal or exact fit. The results
		/// are approximate.
		/// </summary>
		/// <param name="points">The list of points with which to build an enclosing capsule.</param>
		/// <param name="capsule">Returns the capsule containing all points.</param>
		public static void Fit(IList<Vector3> points, out Capsule capsule)
		{
			capsule = new Capsule();
			Vector3 axis, axisNeg;
			GeometryHelper.ComputeMaxSpreadAxis(points, out axis);
			Vector3.Negate(ref axis, out axisNeg);
			if (axis.LengthSquared() < Constants.Epsilon)
				return;
			GeometryHelper.ComputeExtremePoint(points, ref axis, out capsule.P2);
			GeometryHelper.ComputeExtremePoint(points, ref axisNeg, out capsule.P1);
			Segment s = new Segment(capsule.P1, capsule.P2);
			for (int i = 0; i < points.Count; i++)
			{
				var p = points[i];
				float x = s.DistanceSquaredTo(ref p);
				if (x > capsule.Radius)
				{
					capsule.Radius = x;
				}
			}
			capsule.Radius = (float)Math.Sqrt(capsule.Radius);
			Vector3.Multiply(ref axis, capsule.Radius, out axis);
			Vector3.Negate(ref axis, out axisNeg);
			Vector3.Add(ref capsule.P1, ref axis, out capsule.P1);
			Vector3.Add(ref capsule.P2, ref axisNeg, out capsule.P2);
		}
コード例 #5
0
ファイル: Aircraft.cs プロジェクト: nagyistoce/flightsim
        private void initialize()
        {
            this.m_thrustModule = new ThrustModule(this, THRUST_MULTIPLIER * this.thrust, 1f, MAX_FUEL);//1f is fuel gain
            this.m_linDragModule = new LinearDragModule(this, LINEAR_DRAG_COEFFICIENT);
            this.m_liftModule = new LiftModule(this, LIFT_COEFFICIENT);
            this.m_angDragModule = new AngularDragModule(this, ANGULAR_DRAG_COEFFICIENT);
            this.m_dmgModule = new DamageModule(this, 0, 0, 0);
            this.m_pitchDirModule = new PitchDirectionalModule(this, LINVEL_FORWARD_CONVERSION_RATE);
            this.LastPosition = Vector3.Zero;
            this.Flaps = true;
            this.LGears = true;
            SetWorld(
                    STARTING_POSITION,
                    STARTING_ORIENTATION);//* Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (float)Math.PI / 4));
            LinearVelocity = Vector3.Zero;
            AngularVelocity = Vector3.Zero;

            Capsule massCapsule = new Capsule(new Vector3(5, 0, 0), Vector3.Zero, 1);
            Vector3 center = new Vector3(2.5f, 0, 0);
            MassProperties mp = MassProperties.FromCapsule(0.15f, massCapsule.P1, massCapsule.P2, massCapsule.Radius, out center);
            this.MassProperties = mp;
            Capsule skinCapsule = new Capsule(new Vector3(25, 0, 0), new Vector3(-25, 0, 0), 15);
            this.Skin.Add(new CapsulePart(skinCapsule));

            //this.initialize
        }
コード例 #6
0
		/// <summary>
		/// Constructs a collision part from a capsule.
		/// </summary>
		/// <param name="capsule">The capsule definition that this skin part will use.</param>
		public CapsulePart(Capsule capsule)
		{
			_body = World = capsule;
		}
コード例 #7
0
 /// <summary>
 /// Constructs a collision part from a capsule.
 /// </summary>
 /// <param name="capsule">The capsule definition that this skin part will use.</param>
 public CapsulePart(Capsule capsule)
 {
     _body = World = capsule;
 }