Пример #1
0
        public void initialize()
        {
            debug = new info.FSdebugMessages(debugMode, "FSbladeLiftSurface");
            //liftTransform = part.FindModelTransform(liftTransformName);
            //referenceTransform = part.FindModelTransform(referenceTransformName);
            //debugCubeTransform = part.FindModelTransform(debugCubeName);

            liftTransform      = findTransform(liftTransformName);
            referenceTransform = findTransform(referenceTransformName);

            if (liftTransform == null)
            {
                debug.debugMessage("FSliftSurface: Can't find lift transform " + liftTransformName);
            }
            else
            {
                originalRotation = liftTransform.localRotation;
            }

            if (referenceTransform == null)
            {
                debug.debugMessage("FSliftSurface: Can't find lift transform " + liftTransformName);
            }

            //liftSurfaces = part.GetComponents<FSbladeLiftSurface>().ToList();

            initialized = true;
        }
Пример #2
0
        //[KSPEvent(guiName = "Activate Full Sim", guiActive = true, guiActiveEditor = true)]
        //public void toggleFullSimulation()
        //{
        //    fullSimulation = !fullSimulation;

        //    setFullSimulation(fullSimulation);
        //}

        public override void OnStart(PartModule.StartState state)
        {
            base.OnStart(state);
            getThrottleDelegate = getThrottle;

            debugB = new FSdebugMessages(debugMode, "FSengineBladed");

            rotorHubTransform = part.FindModelTransform(rotorHubName);
            if (rotorHubTransform == null)
            {
                debugB.debugMessage("rotorHubTransform is null");
            }
            baseTransform = part.FindModelTransform(baseTransformName);
            if (baseTransform == null)
            {
                debugB.debugMessage("baseTransform is null");
            }

            if (HighLogic.LoadedSceneIsFlight)
            {
                setupBlades();
            }

            circumeference = span * Mathf.PI * 2f;
            bladeMidPoint  = span;
            if (propTweak != null)
            {
                circumeference *= propTweak.bladeLengthSlider;
                bladeMidPoint  *= propTweak.bladeLengthSlider;
            }

            if (HighLogic.LoadedSceneIsFlight)
            {
                flightStarted = true;
            }

            Fields["maxRPM"].guiActive            = true;
            Fields["maxRPM"].guiActiveEditor      = true;
            Fields["maxThrust"].guiActiveEditor   = false;
            Fields["maxThrottle"].guiActive       = false;
            Fields["maxThrottle"].guiActiveEditor = false;

            if (tailRotor)
            {
                Fields["useThrottleKeys"].guiActive        = false;
                Fields["useThrottleKeys"].guiActiveEditor  = false;
                Fields["useThrottleState"].guiActive       = false;
                Fields["useThrottleState"].guiActiveEditor = false;
            }
        }
Пример #3
0
 private void parseObjectNames()
 {
     string[] objectBatchNames = objects.Split(';');
     if (objectBatchNames.Length < 1)
     {
         debug.debugMessage("FSmeshSwitch: Found no object names in the object list");
     }
     else
     {
         objectTransforms.Clear();
         for (int batchCount = 0; batchCount < objectBatchNames.Length; batchCount++)
         {
             List <Transform> newObjects  = new List <Transform>();
             string[]         objectNames = objectBatchNames[batchCount].Split(',');
             for (int objectCount = 0; objectCount < objectNames.Length; objectCount++)
             {
                 Transform newTransform = part.FindModelTransform(objectNames[objectCount].Trim(' '));
                 if (newTransform != null)
                 {
                     newObjects.Add(newTransform);
                     debug.debugMessage("FSmeshSwitch: added object to list: " + objectNames[objectCount]);
                 }
                 else
                 {
                     debug.debugMessage("FSmeshSwitch: could not find object " + objectNames[objectCount]);
                 }
             }
             if (newObjects.Count > 0)
             {
                 objectTransforms.Add(newObjects);
             }
         }
     }
 }
Пример #4
0
        public void initializeData()
        {
            if (!initialized)
            {
                debug = new info.FSdebugMessages(debugMode, "FSmeshSwitch");
                // you can't have fuel switching without symmetry, it breaks the editor GUI.
                if (useFuelSwitchModule)
                {
                    updateSymmetry = true;
                }

                parseObjectNames();
                fuelTankSetupList = Tools.parseIntegers(fuelTankSetups);
                objectDisplayList = Tools.parseNames(objectDisplayNames);

                if (useFuelSwitchModule)
                {
                    fuelSwitch = part.GetComponent <FSfuelSwitch>();
                    if (fuelSwitch == null)
                    {
                        useFuelSwitchModule = false;
                        debug.debugMessage("no FSfuelSwitch module found, despite useFuelSwitchModule being true");
                    }
                }
                initialized = true;
            }
        }
Пример #5
0
        private Vector2 getLiftAndDrag()
        {
            Vector3 pointVelocity = -referenceTransform.forward.normalized * pointVelocityMagnitude;

            if (part == null)
            {
                debug.debugMessage("FSbladeLiftSurface: part is null");
                return(Vector2.zero);
            }

            commonRigidBody = part.Rigidbody;
            if (commonRigidBody != null)
            {
                partVelocity = GetVelocity(commonRigidBody, liftTransform.position);
                //bladeVelocity = partVelocity + pointVelocity;
                bladeVelocity = pointVelocity; // test
                realSpeed     = (bladeVelocity + partVelocity).magnitude;
                if (fullSimulation)
                {
                    bladeVelocity += partVelocity;
                }
                //velocity = pointVelocity; //+ (GetVelocity(commonRigidBody, liftTransform.position).magnitude * -liftTransform.up);


                speed = bladeVelocity.magnitude;
                float angleOfAttackRad = CalculateAoA(liftTransform, bladeVelocity);
                float liftCoeff        = 2f * Mathf.PI * angleOfAttackRad;
                lift = 0.5f * liftCoeff * airDensity * (speed * speed) * wingArea;
                float aspectRatio = (span * span) / wingArea;
                float dragCoeff   = zeroLiftDrag + (liftCoeff * liftCoeff) / (Mathf.PI * aspectRatio * efficiency);
                bladeDrag = 0.5f * dragCoeff * airDensity * (speed * speed) * wingArea;

                discDrag = 0.5f * dragCoeff * airDensity * (partVelocity.magnitude * partVelocity.magnitude) * wingArea;


                lift      *= power; // modified by too low blade speed //;
                discDrag  *= power;
                bladeDrag *= power;
            }
            return(new Vector2(lift, discDrag));
            //return new Vector2(lift, bladeDrag);
        }
Пример #6
0
 protected void fillResourceList(string resourceString)
 {
     string[] keyString = resourceString.Split(';');
     for (int i = 0; i < keyString.Length; i++)
     {
         string[] valueString = keyString[i].Split(',');
         if (valueString.Length > 0)
         {
             try
             {
                 resourceList.Add(new FSresource(valueString[0].Trim(' '), float.Parse(valueString[1])));
                 debug.debugMessage("Added resource " + valueString[0] + ", ratio " + valueString[1]);
             }
             catch
             {
                 debug.debugMessage("could not add resource to list: " + valueString[0]);
             }
         }
     }
 }
Пример #7
0
        private void setupBlades()
        {
            List <GameObject> newBlades = new List <GameObject>();

            propTweak = part.GetComponent <engine.FSpropellerTweak>();
            if (propTweak != null)
            {
                propTweak.initialize();

                newBlades = propTweak.blades;
            }
            else
            {
                Transform[] newBladeTransforms = part.FindModelTransforms(bladeHubName);
                for (int i = 0; i < newBladeTransforms.Length; i++)
                {
                    newBlades.Add(newBladeTransforms[i].gameObject);
                }
            }
            bladeLifts.Clear();

            foreach (GameObject blade in newBlades)
            {
                FSbladeLiftSurface bladeLift = blade.AddComponent <FSbladeLiftSurface>();
                if (bladeLift != null)
                {
                    bladeLift.thisGameObject         = blade;
                    bladeLift.liftTransformName      = liftTransformName;
                    bladeLift.referenceTransformName = referenceTransformName;
                    bladeLift.power = power;
                    if (propTweak == null)
                    {
                        bladeLift.span     = span;
                        bladeLift.wingArea = wingArea;
                    }
                    else
                    {
                        bladeLift.span     = span * propTweak.bladeLengthSlider;
                        bladeLift.wingArea = wingArea * propTweak.bladeLengthSlider;
                    }
                    bladeLift.efficiency     = efficiency;
                    bladeLift.dragMultiplier = dragMultiplier;
                    bladeLift.zeroLiftDrag   = zeroLiftDrag;
                    bladeLift.part           = part;
                    bladeLift.debugMode      = debugMode;

                    bladeLift.initialize();
                    bladeLifts.Add(bladeLift);
                }
                debugB.debugMessage(bladeLifts.Count.ToString() + " blades added to bladeLifts");
            }
        }
Пример #8
0
        public void initialize()
        {
            debug = new info.FSdebugMessages(debugMode, "FSbladeLiftSurface");
            //liftTransform = part.FindModelTransform(liftTransformName);            
            //referenceTransform = part.FindModelTransform(referenceTransformName);
            //debugCubeTransform = part.FindModelTransform(debugCubeName);

            liftTransform = findTransform(liftTransformName);
            referenceTransform = findTransform(referenceTransformName);            

            if (liftTransform == null)
            {
                debug.debugMessage("FSliftSurface: Can't find lift transform " + liftTransformName);
            }
            else
            {
                originalRotation = liftTransform.localRotation;
            }

            if (referenceTransform == null)
            {
                debug.debugMessage("FSliftSurface: Can't find lift transform " + liftTransformName);
            }            

            //liftSurfaces = part.GetComponents<FSbladeLiftSurface>().ToList();

            initialized = true;
        }
Пример #9
0
        public void initializeData()
        {
            if (!initialized)
            {
                debug = new info.FSdebugMessages(debugMode, "FSmeshSwitch");
                // you can't have fuel switching without symmetry, it breaks the editor GUI.
                if (useFuelSwitchModule) updateSymmetry = true;

                parseObjectNames();
                fuelTankSetupList = Tools.parseIntegers(fuelTankSetups);
                objectDisplayList = Tools.parseNames(objectDisplayNames);

                if (useFuelSwitchModule)
                {
                    fuelSwitch = part.GetComponent<FSfuelSwitch>();
                    if (fuelSwitch == null)
                    {
                        useFuelSwitchModule = false;
                        debug.debugMessage("no FSfuelSwitch module found, despite useFuelSwitchModule being true");
                    }
                }
                initialized = true;
            }
        }
Пример #10
0
        //[KSPEvent(guiName = "Activate Full Sim", guiActive = true, guiActiveEditor = true)]
        //public void toggleFullSimulation()
        //{
        //    fullSimulation = !fullSimulation;

        //    setFullSimulation(fullSimulation);
        //}

        public override void OnStart(PartModule.StartState state)
        {
            base.OnStart(state);
            getThrottleDelegate = getThrottle;

            debugB = new FSdebugMessages(debugMode, "FSengineBladed");

            rotorHubTransform = part.FindModelTransform(rotorHubName);
            if (rotorHubTransform == null) debugB.debugMessage("rotorHubTransform is null");
            baseTransform = part.FindModelTransform(baseTransformName);
            if (baseTransform == null) debugB.debugMessage("baseTransform is null");

            if (HighLogic.LoadedSceneIsFlight)
            {
                setupBlades();
            }

            circumeference = span * Mathf.PI * 2f;
            bladeMidPoint = span;
            if (propTweak != null)
            {
                circumeference *= propTweak.bladeLengthSlider;
                bladeMidPoint *= propTweak.bladeLengthSlider;
            }

            if (HighLogic.LoadedSceneIsFlight)
                flightStarted = true;

            Fields["maxRPM"].guiActive = true;
            Fields["maxRPM"].guiActiveEditor = true;
            Fields["maxThrust"].guiActiveEditor = false;
            Fields["maxThrottle"].guiActive = false;
            Fields["maxThrottle"].guiActiveEditor = false;

            if (tailRotor)
            {
                Fields["useThrottleKeys"].guiActive = false;
                Fields["useThrottleKeys"].guiActiveEditor = false;
                Fields["useThrottleState"].guiActive = false;
                Fields["useThrottleState"].guiActiveEditor = false;
            }
        }