Exemplo n.º 1
0
        /*
         * protected void AddChildren(GameObject gameObject, TreeNode treeNode)
         * {
         *  foreach (GameObject child in gameObject.Children)
         *  {
         *      ControlSurface surface = child as ControlSurface;
         *      if (surface != null)
         *      {
         *          TreeNode node = new TreeNode(surface.Name);
         *          node.Tag = surface;
         *          AddChildren(surface, node);
         *          treeNode.Nodes.Add(node);
         *      }
         *  }
         * }
         */
        #endregion

        #region Public methods
        public void Reset()
        {
            iFlightModel.Reset();
            iFlightModel.Z = 5f;
            if (iFlightModel.AircraftParameters.HandLaunched)
            {
                iFlightModel.HandLaunch(-pilotPosition.Z, -pilotPosition.X, -pilotPosition.Y);
            }
            airplaneModel.StartEngine();
        }
Exemplo n.º 2
0
        public void LoadModel(string fileName)
        {
            // First clean up
            if (iFlightModel != null)
            {
                iFlightModel.Dispose();
                iFlightModel = null;
            }
            if (modelApi != null)
            {
                modelApi.Dispose();
                modelApi = null;
            }
            if (airplane != null)
            {
                airplane.Dispose();
                airplane = null;
            }
            if (variometer != null)
            {
                variometer.Dispose();
                variometer = null;
            }

            // Now load the actual model
            //model = new FlightModelWind();
            AircraftParameters parameters = new RCSim.DataClasses.AircraftParameters();

            parameters.File = fileName;

            if (!string.IsNullOrEmpty(Bonsai.Utils.Settings.GetValue("ApiFlightModel")))
            {
                try
                {
                    string   assemblyInfo  = Bonsai.Utils.Settings.GetValue("ApiFlightModel");
                    string[] assemblyParts = assemblyInfo.Split(',', ';');
                    Assembly assembly      = Assembly.LoadFrom(assemblyParts[0]);
                    RCDeskPilot.API.FlightModelSimple flightModelSimple =
                        assembly.CreateInstance(assemblyParts[1]) as RCDeskPilot.API.FlightModelSimple;
                    modelApi          = new FlightModelApi();
                    modelApi.ApiModel = flightModelSimple;
                    iFlightModel      = modelApi;
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(
                        string.Format("Failed to load the flightmodel plugin : {0}", ex.ToString()));
                }
            }
            else
            {
                if (parameters.Version == 2)
                {
                    iFlightModel = new FlightModelWind2();
                }
                else
                {
                    iFlightModel = new FlightModelWind();
                }
            }

            iFlightModel.AircraftParameters = parameters;
            iFlightModel.Initialize();
            iFlightModel.Reset();
            iFlightModel.Wind      = new Vector3(0, 0, 0);
            iFlightModel.Heightmap = Heightmap;
            iFlightModel.Water     = Program.Instance.Scenery.Water;
            airplane = new AirplaneModel(iFlightModel);

            CurrentModel = fileName;

            if (smoke != null)
            {
                smoke.Dispose();
                smoke = null;
            }
            smoke = new Smoke(owner, iFlightModel);

            UpdateVariometer();

            this.owner.UpdateCameras();
            this.Reset();
        }