コード例 #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            CreateBoxes();

            planeBody = new PlaneBody(GraphicsDevice);
            effect    = new BasicEffect(GraphicsDevice);
            effect.VertexColorEnabled = true;

            effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, GraphicsDevice.Viewport.AspectRatio, 0.01f, 1000f);
            effect.View       = Matrix.CreateLookAt(new Vector3(20f, 5f, 5f), new Vector3(0, 0, 0), Vector3.Up);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: dark567/Module-3lesson18HW
        private void DependentCalls()
        {
            Console.WriteLine("##DEPENDENT CALLS:" + Environment.NewLine);

            Console.WriteLine("*Space Rockets Factory:");
            Factory <SpaceRocket> rocketFactory = new Factory <SpaceRocket>();

            IProduct <SpaceRocket> rocketProduct = rocketFactory.Create <Engine <SpaceRocket> >();

            rocketProduct.Operate();

            IProduct <SpacePlane> rocketAutomaticControlSystem = rocketFactory.Create <AutomaticControlSystem>();

            rocketAutomaticControlSystem.Operate();

            // Example of using a product specific function.
            RocketBody <SpaceRocket> rocketBody = rocketFactory.Create <RocketBody <SpaceRocket> >();

            rocketBody.Operate();
            rocketBody.FrameSpecificOperation();
            Console.WriteLine(new string('-', 25));


            Console.WriteLine("*Space Plane Factory:");
            Factory <SpacePlane> planeFactory = new Factory <SpacePlane>();

            IProduct <SpacePlane> planeEngineProduct = planeFactory.Create <Engine <SpacePlane> >();

            planeEngineProduct.Operate();

            IProduct <SpacePlane> planeACSProduct = planeFactory.Create <AutomaticControlSystem>();

            planeACSProduct.Operate();

            PlaneBody <SpacePlane> planeBody = planeFactory.Create <PlaneBody <SpacePlane> >();

            rocketBody.Operate();
            rocketBody.FrameSpecificOperation();

            Console.WriteLine(new string('-', 25));


            // Example of a car factory creating a plane frame.
            rocketFactory.Create <RocketBody <SpaceRocket> >();

            // Example of a plane factory creating a car frame.
            planeFactory.Create <PlaneBody <SpacePlane> >();

            Console.WriteLine(new string('*', 25));
        }
コード例 #3
0
        public void LateUpdate()
        {
            //            Debug.unityLogger.logEnabled = true;

            float deltaTime = Time.deltaTime;

            PlaneBody planeBody = PlaneSteering.GetPlane();

            if (planeBody == null)
            {
                return;
            }

            Transform planeTransform = planeBody.transform;

            Vector3    position = planeTransform.position;
            Quaternion rotation = planeTransform.rotation;

            data.packetId = packetCounter;

            if (packetCounter == uint.MaxValue - 1)
            {
                packetCounter = 0;
            }
            else
            {
                packetCounter++;
            }

            Vector3 velocity = RealisticFlying.speed;// (position - lastPosition) / deltaTime;

            lastPosition = position;

            velocity = planeTransform.InverseTransformDirection(velocity);

            Vector3 acceleration = ((velocity - lastVelocity) / deltaTime) * 0.10197162129779283f;

            lastVelocity = velocity;

            data.posX = position.x;
            data.posY = position.y;
            data.posZ = position.z;

            Vector3 pyr = rotation.eulerAngles * ((float)Mathf.PI / 180.0f);

            data.pitch = pyr.x;
            data.yaw   = pyr.y;
            data.roll  = pyr.z;

            data.velX = velocity.x;
            data.velY = velocity.y;
            data.velZ = velocity.z;

            data.accelX = acceleration.x;
            data.accelY = acceleration.y;
            data.accelZ = acceleration.z;

            data.pitchVel = CalculateAngularChange(lastRotation.x, pyr.x) / deltaTime;
            data.yawVel   = CalculateAngularChange(lastRotation.y, pyr.y) / deltaTime;
            data.rollVel  = CalculateAngularChange(lastRotation.z, pyr.z) / deltaTime;

            lastRotation = pyr;

            data.pitchAccel = (data.pitchVel - lastRotVel.x) / deltaTime;
            data.yawAccel   = (data.yawVel - lastRotVel.y) / deltaTime;
            data.rollAccel  = (data.rollVel - lastRotVel.z) / deltaTime;

            lastRotVel = new Vector3(data.pitchVel, data.yawVel, data.rollVel);

            data.paused = false;// !Mission.IsFinished() && Mission.OnAnyMission;

            data.dt = deltaTime;

            data.engineRPM = (700.0f + (planeBody.GetTrottle() * 5000.0f));

            //FIXME: use Cannon from inside PlaneBody

            byte[] bytes = data.ToByteArray();

            udpClient.SendAsync(bytes, bytes.Length);
        }