Exemplo n.º 1
0
 private void Init()
 {
     this.name                        = "unknownPart";
     this.module                      = Part.PartModule.Part;
     this.mesh                        = "model.mu";
     this.rescaleFactor               = 1.25;
     this.scale                       = 1;
     this.author                      = "Unknown";
     this.title                       = "Unknown Mystery Component";
     this.manufacturer                = "Found lying by the side of the road";
     this.description                 = "Nothing is really known about this thing. Use it at your own risk.";
     this.TechRequired                = string.Empty;
     this.bulkheadProfiles            = string.Empty;
     this.subcategory                 = "0";
     this.tags                        = "*";
     this.mass                        = 2.0;
     this.dragModelType               = Part.DragModel.CUBE;
     this.maximum_drag                = 0.1;
     this.minimum_drag                = 0.1;
     this.angularDrag                 = 2.0;
     this.crashTolerance              = 9.0;
     this.breakingForce               = 22.0;
     this.breakingTorque              = 22.0;
     this.explosionPotential          = 0.5;
     this.maxTemp                     = 2000;
     this.skinMaxTemp                 = -1;
     this.heatConductivity            = 0.12;
     this.heatConvectiveConstant      = 1.0;
     this.emissiveConstant            = 0.4;
     this.thermalMassModifier         = 1.0;
     this.skinInternalConductionMult  = 1.0;
     this.radiatorHeadroom            = 0.25;
     this.radiatorMax                 = 0.25;
     this.skinMassPerArea             = 1.0;
     this.fuelCrossFeed               = true;
     this.buoyancy                    = 1.0;
     this.buoyancyUseCubeNamed        = string.Empty;
     this.buoyancyUseSine             = true;
     this.bodyLiftMultiplier          = 1.0;
     this.iconCenter                  = Vector3.Zero;
     this.CoLOffset                   = Vector3.Zero;
     this.CoMOffset                   = Vector3.Zero;
     this.CoPOffset                   = Vector3.Zero;
     this.CenterOfBuoyancy            = Vector3.Zero;
     this.CenterOfDisplacement        = Vector3.Zero;
     this.boundsCentroidOffset        = Vector3.Zero;
     this.boundsMultiplier            = 1.0;
     this.stagingIcon                 = string.Empty;
     this.inverseStageCarryover       = true;
     this.ActivatesEvenIfDisconnected = true;
     this.initRotation                = Quaternion.Identity;
     this.maxLength                   = 10.0;
     this.attachRules                 = new AttachRules();
     this._internalConfig             = new ConfigNode();
     this._resources                  = new PartResourceList(this);
 }
Exemplo n.º 2
0
        protected void Init(Part p)
        {
            this.name = p.name;
            Rigidbody rigidbody = p.rb;

            //totalMass = rigidbody == null ? 0 : rigidbody.mass; // TODO : check if we need to use this or the one without the childMass
            totalMass             = p.mass + p.GetResourceMass();
            dryMass               = p.mass;
            shieldedFromAirstream = p.ShieldedFromAirstream;

            noDrag             = rigidbody == null && !PhysicsGlobals.ApplyDragToNonPhysicsParts;
            hasLiftModule      = p.hasLiftModule;
            bodyLiftMultiplier = p.bodyLiftMultiplier;
            dragModel          = p.dragModel;
            cubesNone          = p.DragCubes.None;

            CoM = p.transform.TransformPoint(p.CoMOffset);
            CoP = p.transform.TransformPoint(p.CoPOffset);
            CoL = p.transform.TransformPoint(p.CoLOffset);

            switch (dragModel)
            {
            case Part.DragModel.CYLINDRICAL:
            case Part.DragModel.CONIC:
                maximum_drag        = p.maximum_drag;
                minimum_drag        = p.minimum_drag;
                dragReferenceVector = p.partTransform.TransformDirection(p.dragReferenceVector);
                break;

            case Part.DragModel.SPHERICAL:
                maximum_drag = p.maximum_drag;
                break;

            case Part.DragModel.CUBE:
                if (cubesNone)
                {
                    maximum_drag = p.maximum_drag;
                }
                break;
            }

            simCurves = SimCurves.Borrow(null);

            //cubes = new DragCubeList();
            ModuleWheels.ModuleWheelDeployment wheelDeployment = p.FindModuleImplementing <ModuleWheels.ModuleWheelDeployment>();
            bool  forcedRetract = !shieldedFromAirstream && wheelDeployment != null && wheelDeployment.Position > 0;
            float gearPosition  = 0;

            if (forcedRetract)
            {
                gearPosition = wheelDeployment.Position;
                lock (wheelDeployment)
                {
                    lock (p.DragCubes)
                    {
                        p.DragCubes.SetCubeWeight("Retracted", 1);
                        p.DragCubes.SetCubeWeight("Deployed", 0);

                        lock (this.cubes)
                            CopyDragCubesList(p.DragCubes, cubes);

                        p.DragCubes.SetCubeWeight("Retracted", 1 - gearPosition);
                        p.DragCubes.SetCubeWeight("Deployed", gearPosition);
                    }
                }
            }

            else
            {
                lock (this.cubes)
                    lock (p.DragCubes)
                        CopyDragCubesList(p.DragCubes, cubes);
            }

            // Rotation to convert the vessel space vesselVelocity to the part space vesselVelocity
            // QuaternionD.LookRotation is not working...
            //partToVessel = Quaternion.LookRotation(p.vessel.GetTransform().InverseTransformDirection(p.transform.forward), p.vessel.GetTransform().InverseTransformDirection(p.transform.up));
            //vesselToPart = Quaternion.Inverse(partToVessel);
            partToVessel = p.transform.rotation;
            vesselToPart = Quaternion.Inverse(partToVessel);

            /*Debug.Log(p.name);
             * Debug.Log(p.transform.rotation);
             * Debug.Log(Quaternion.Inverse(p.transform.rotation));
             * Debug.Log(Quaternion.LookRotation(p.transform.forward, p.transform.up));
             * Debug.Log(p.transform.InverseTransformDirection(Vector3.forward) + " // " + Quaternion.Inverse(p.transform.rotation) * Vector3.forward + " // " + Quaternion.Inverse(Quaternion.LookRotation(p.transform.forward, p.transform.up)) * Vector3.forward);
             * Debug.Log(p.DragCubes.None + " " + p.dragModel);
             * Debug.Log("");*/
        }