Exemplo n.º 1
0
        private static void CreateCells(Parachute p)
        {
            // Layout n number of cells from left to right around the top section of an ellipse
            // Todo: current algorithm does not preserve planform area as it warps the wing around the ellipse
            // Todo: GUI planform area should report post-warp area, including tapering and such

            var config   = p.Config;
            var centroid = ParachuteMaths.GetCanopyCentroid(config);

            // Todo: model induced drag based on aspect ratio and shape tapering
            float aspectRatio = ParachuteMaths.GetAspectRatio(p.Config);

            for (int i = 0; i < config.NumCells; i++)
            {
                float areaMultiplier = 1f;//config.PlanformAreaEllipse.Evaluate(i/(float) (config.NumCells - 1));

                var cell = CreateCell(p, areaMultiplier, aspectRatio);
                var t    = ParachuteMaths.GetCellTransform(config, centroid, i);
                LayoutCell(cell, t);
                cell.name = "Cell_" + i;
                p.Sections.Add(new Section()
                {
                    Cell = cell
                });
            }
        }
Exemplo n.º 2
0
        private Vector3 GetOrbitCenter()
        {
            // Bug: watch out for Gizmos-related feedback loops

            Vector3 centroid = _target.Root.TransformPoint(ParachuteMaths.GetCanopyCentroid(_target.Config));

            centroid = Vector3.Lerp(centroid, _target.Root.position, 0.33f);
            return(centroid);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Takes an existing parachute system and resets it to factory state
        /// </summary>
        /// <param name="p"></param>
        public static void LayoutCells(Parachute p)
        {
            var config   = p.Config;
            var centroid = ParachuteMaths.GetCanopyCentroid(config);

            for (int i = 0; i < config.NumCells; i++)
            {
                var cell = p.Sections[i].Cell;
                var t    = ParachuteMaths.GetCellTransform(config, centroid, i);
                LayoutCell(cell, t);
            }
        }
Exemplo n.º 4
0
        public static Parachute Create(ParachuteConfig config, ImmutableTransform transform, string name)
        {
            ParachuteMaths.ValidateConfig(config);
            Parachute p = CreateNewInstance(config, transform, name);

            // Todo: Differentiate between game use and editor use

            CreateCells(p);
            CreateInterCellJoints(p);
            CreateRiggingLines(p);
            CreateControlGroups(p);
            p.CalculateCanopyBounds();
            AddSounds(p);

            return(p);
        }
Exemplo n.º 5
0
        private void UpdateEditorState <TMeasureSystem>(
            ParachuteConfig config,
            ParachuteProperties <TMeasureSystem> props)
            where TMeasureSystem : MeasureSystem
        {
            var editorOrigin        = transform.MakeImmutable();
            var canopyCentroidWorld = editorOrigin.TranslateLocally(ParachuteMaths.GetCanopyCentroid(config));

            _heightOffsetWidget.transform.Set(editorOrigin.TranslateLocally(y: 1f));
            _heightOffsetText.transform.Set(editorOrigin.TranslateLocally(y: config.HeightOffset + 1f, z: -0.5f));
            _heightOffsetText.Text.Clear();
            props.HeightOffset.FormatTo(_heightOffsetText.Text, precision: 2);

            _riggingAngleGizmo.transform.Set(canopyCentroidWorld);

            _cellColorPicker.CurrentColor = config.Color;

            _summaryText.Text.Clear();
            _summaryText.Text
            .Append("Difficulty level: ")
            .Append(ParachuteMaths.GetDifficulty(config).Stringify())
            .Append("\n")
            .Append(config.NumCells)
            .Append(" cells (")
            .Append(config.NumToggleControlledCells)
            .Append(" braked), ");
            props.CanopyMass.FormatTo(_summaryText.Text, precision: 1);
            _summaryText.Text.Append("\n");
            props.Span.FormatTo(_summaryText.Text, precision: 1);
            _summaryText.Text.Append(" × ");
            props.Chord.FormatTo(_summaryText.Text, precision: 1);
            _summaryText.Text.Append(" = ");
            props.Area.FormatTo(_summaryText.Text, precision: 0);
            _summaryText.transform.Set(canopyCentroidWorld.TranslateLocally(new Vector3(-3f, 2.5f, 0f)));

            // TODO Use mutable strings
            _riggingAngle.transform.Set(canopyCentroidWorld);
            _riggingAngle.Text.Clear();
            props.RiggingAngle.FormatTo(_riggingAngle.Text, precision: 0);

//            _rigAttachPositionText.text = string.Format("{0:0.##}, {1:0.##}, {2:0.##}",
//                props.RigAttachPosition.Value.x,
//                props.RigAttachPosition.Value.y,
//                props.RigAttachPosition.Value.z);
//            _rigAttachPositionText.transform.Set(rigAttachPositionTransform);

            var pilotWeightTransform = editorOrigin.TranslateLocally(y: -0.8f);

            _pilotWeight.transform.Set(pilotWeightTransform.TranslateLocally(y: -0.4f));
            _pilotWeightGizmo.transform.Set(pilotWeightTransform);

            _pilotWeight.Text.Clear();
            props.PilotWeight.FormatTo(_pilotWeight.Text, precision: 0);
            _pilotWeight.Text.Append(" (");
            props.WingLoading.FormatTo(_pilotWeight.Text, precision: 2);
            _pilotWeight.Text.Append(")");

            var pilotWeightShiftTransform = editorOrigin;

            _weightShiftMagnitudeGizmo.transform.Set(pilotWeightShiftTransform);
            _pilotWeightShiftMagnitude.transform.Set(pilotWeightShiftTransform.TranslateLocally(x: -1.1f));
            _weightShiftVisualizer.transform.position = pilotWeightShiftTransform.Position;
            _weightShiftVisualizer.Radius             = config.WeightshiftMagnitude;

            _pilotWeightShiftMagnitude.Text.Clear();
            props.WeightShiftMagnitude.FormatTo(_pilotWeightShiftMagnitude.Text, precision: 2);

            _radiusGizmo.UpdateState();
            _heightOffsetWidget.UpdateState();
            _rigAttachPosition.UpdateState();
            _pilotWeightGizmo.UpdateState();
            _weightShiftMagnitudeGizmo.UpdateState();
        }