Esempio n. 1
0
        Vector3 findCenterOfDrag()
        {
            Cd       = 0f;
            position = Vector3.zero;

            /* setup parachutes */
            switch (RCSBuildAid.Mode)
            {
            case PluginMode.Parachutes:
                for (int i = 0; i < RCSBuildAid.Parachutes.Count; i++)
                {
                    var parachute = (ModuleParachute)RCSBuildAid.Parachutes [i];
                    var part      = parachute.part;
                    var dc        = part.DragCubes;
                    dc.SetCubeWeight("DEPLOYED", 1);
                    dc.SetCubeWeight("SEMIDEPLOYED", 0);
                    dc.SetCubeWeight("PACKED", 0);
                    dc.SetOcclusionMultiplier(0);
                    var rotation = Quaternion.LookRotation(part.partTransform.InverseTransformDirection(-VelocityDirection));
                    dc.SetDragVectorRotation(rotation);
                }
                break;
            }

            EditorUtils.RunOnAllParts(calculateDrag);

            position /= (float)Cd;
            Cd       *= PhysicsGlobals.DragMultiplier * reynoldsDragMult;
            return(position);
        }
Esempio n. 2
0
        Vector3 findCenterOfDrag()
        {
            Cd       = 0f;
            position = Vector3.zero;

            /* setup parachutes */
            switch (RCSBuildAid.Mode)
            {
            case PluginMode.Parachutes:
                for (int i = 0; i < RCSBuildAid.Parachutes.Count; i++)
                {
                    var parachute = (ModuleParachute)RCSBuildAid.Parachutes [i];
                    var part      = parachute.part;
                    var dc        = part.DragCubes;
                    #if DEBUG
                    var vector = parachute.GetComponent <VectorGraphic> ();
                    if (vector == null)
                    {
                        vector = parachute.gameObject.AddComponent <VectorGraphic> ();
                        vector.setColor(Color.blue);
                        vector.minLength = 0.6f;
                    }
                    #endif
                    dc.SetCubeWeight("DEPLOYED", 1);
                    dc.SetCubeWeight("SEMIDEPLOYED", 0);
                    dc.SetCubeWeight("PACKED", 0);
                    dc.SetOcclusionMultiplier(0);

                    /* I need to do all this since parachute's drag depends of the
                     * orientation of the canopy */
                    Transform t = part.FindModelTransform(parachute.canopyName);
                    t.rotation = Quaternion.LookRotation(-VelocityDirection, part.transform.forward);
                    if (part.symmetryCounterparts != null)
                    {
                        float angle = Mathf.Clamp(parachute.spreadAngle * (part.symmetryCounterparts.Count + 1), 0, 45);
                        t.Rotate(angle, 0, 0, Space.Self);
                    }
                    var rotation = Quaternion.LookRotation(part.partTransform.InverseTransformDirection(t.forward));
                    dc.SetDragVectorRotation(rotation);
                    #if DEBUG
                    vector.value = part.partTransform.InverseTransformDirection(dc.DragVector) * dc.AreaDrag;
                    #endif
                }
                break;
            }

            EditorUtils.RunOnAllParts(calculateDrag);

            position /= (float)Cd;
            Cd       *= PhysicsGlobals.DragMultiplier * reynoldsDragMult;
            return(position);
        }
Esempio n. 3
0
        protected override Vector3 UpdatePosition()
        {
            vectorSum = Vector3.zero;
            totalMass = 0f;

            EditorUtils.RunOnAllParts(calculateCoM);

            if (vectorSum.IsZero())
            {
                return(vectorSum);
            }

            return(vectorSum / totalMass);
        }
Esempio n. 4
0
        void LateUpdate()
        {
            if (!RCSBuildAid.Enabled)
            {
                return;
            }
            axis = RCSBuildAid.VesselForces.Torque().normalized;
            if (axis == Vector3.zero || EditorLogic.RootPart == null)
            {
                /* no torque, calculating this is meaningless */
                return;
            }
            value = 0f;

            EditorUtils.RunOnAllParts(calculateMoI);
        }