Exemplo n.º 1
0
 public void ForceLegacyAeroUpdates()
 {
     if (LegacyWingModel != null)
     {
         LegacyWingModel.ForceOnVesselPartsChange();
     }
 }
Exemplo n.º 2
0
        //Returns the tinted color if active; else it returns an alpha 0 color
        private Color AeroVisualizationTintingCalculation(AeroVisualizationGUI aeroVizGUI)
        {
            // Disable tinting for low dynamic pressure to prevent flicker
            if (vessel.dynamicPressurekPa <= 0.00001)
            {
                return(new Color(0, 0, 0, 0));
            }

            // Stall tinting overrides Cl / Cd tinting
            if (LegacyWingModel != null && aeroVizGUI.TintForStall)
            {
                return(new Color((float)(LegacyWingModel.GetStall() * 100.0 / aeroVizGUI.FullySaturatedStall),
                                 0f,
                                 0f,
                                 0.5f));
            }

            if (!aeroVizGUI.TintForCl && !aeroVizGUI.TintForCd)
            {
                return(new Color(0, 0, 0, 0));
            }

            double visualizationCl = 0, visualizationCd = 0;

            if (projectedArea.totalArea > 0.0)
            {
                Vector3 worldVelNorm   = partTransform.localToWorldMatrix.MultiplyVector(partLocalVelNorm);
                Vector3 worldDragArrow = Vector3.Dot(totalWorldSpaceAeroForce, worldVelNorm) * worldVelNorm;
                Vector3 worldLiftArrow = totalWorldSpaceAeroForce - worldDragArrow;

                double invAndDynPresArea = LegacyWingModel != null ? LegacyWingModel.S : projectedArea.totalArea;
                invAndDynPresArea *= vessel.dynamicPressurekPa;
                invAndDynPresArea  = 1 / invAndDynPresArea;
                visualizationCl    = worldLiftArrow.magnitude * invAndDynPresArea;
                visualizationCd    = worldDragArrow.magnitude * invAndDynPresArea;
            }

            double fullSatCl, satCl = 0, fullSatCd, satCd = 0;

            if (LegacyWingModel != null)
            {
                fullSatCl = aeroVizGUI.FullySaturatedCl;
                fullSatCd = aeroVizGUI.FullySaturatedCd;
            }
            else
            {
                fullSatCl = aeroVizGUI.FullySaturatedClBody;
                fullSatCd = aeroVizGUI.FullySaturatedCdBody;
            }

            if (aeroVizGUI.TintForCl)
            {
                satCl = Math.Abs(visualizationCl / fullSatCl);
            }
            if (aeroVizGUI.TintForCd)
            {
                satCd = Math.Abs(visualizationCd / fullSatCd);
            }

            return(new Color((float)satCd, 0.5f * (float)(satCl + satCd), (float)satCl, 0.5f));
        }