当前位置: 首页>>代码示例>>C#>>正文


C# Part.FindModelTransform方法代码示例

本文整理汇总了C#中Part.FindModelTransform方法的典型用法代码示例。如果您正苦于以下问题:C# Part.FindModelTransform方法的具体用法?C# Part.FindModelTransform怎么用?C# Part.FindModelTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Part的用法示例。


在下文中一共展示了Part.FindModelTransform方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: switchLight

 public static void switchLight(Part p, String lightName, bool state)
 {
     Transform lightTransform = p.FindModelTransform(lightName);
     if (lightTransform != null) {
         Light light = lightTransform.GetComponent<Light>();
         if (light != null)
             light.intensity = (state ? 1 : 0);
     }
 }
开发者ID:khr15714n,项目名称:KerbalSmartParts,代码行数:9,代码来源:Utility.cs

示例2: LocateCamera

 private bool LocateCamera(Part thatpart, string transformName)
 {
     Transform location = thatpart.FindModelTransform(transformName);
     if (location != null)
     {
         cameraTransform = location.gameObject;
         cameraPart = thatpart;
         return true;
     }
     return false;
 }
开发者ID:Tahvohck,项目名称:RasterPropMonitor,代码行数:11,代码来源:FlyingCamera.cs

示例3: IntegratedIntakeEngineCrossSectionAdjuster

        public IntegratedIntakeEngineCrossSectionAdjuster(ModuleResourceIntake intake, Matrix4x4 worldToVesselMatrix)
        {
            this.part = intake.part;
            //ModuleResourceIntake intake = intake;

            intakeTrans = part.FindModelTransform(intake.intakeTransformName);
            vehicleBasisForwardVector = Vector3.forward;//intakeTrans.forward;

            foreach (AttachNode node in part.attachNodes)
                if (node.nodeType == AttachNode.NodeType.Stack && Vector3.Dot(node.position, (part.transform.worldToLocalMatrix * intakeTrans.localToWorldMatrix).MultiplyVector(Vector3.forward)) > 0)
                {
                    frontNode = node;
                    break;
                }

            thisToVesselMatrix = worldToVesselMatrix * intakeTrans.localToWorldMatrix;

            vehicleBasisForwardVector = thisToVesselMatrix.MultiplyVector(vehicleBasisForwardVector);

            intakeArea = INTAKE_AREA_SCALAR * intake.area;
        }
开发者ID:Nitebomber,项目名称:Ferram-Aerospace-Research-x64-hack,代码行数:21,代码来源:IntegratedIntakeEngineCrossSectionAdjuster.cs

示例4: GuessUpVector

        public static Vector3 GuessUpVector(Part part)
        {
            // For intakes, use the intake vector
            if (part.Modules.Contains("ModuleResourceIntake"))
            {
                ModuleResourceIntake i = part.Modules["ModuleResourceIntake"] as ModuleResourceIntake;
                Transform intakeTrans = part.FindModelTransform(i.intakeTransformName);
                return part.transform.InverseTransformDirection(intakeTrans.forward);
            }
            // If surface attachable, and node normal is up, check stack nodes or use forward
            else if (part.srfAttachNode != null &&
                     part.attachRules.srfAttach &&
                     Mathf.Abs(part.srfAttachNode.orientation.normalized.y) > 0.9f)
            {
                // When the node normal is exactly Vector3.up, the editor orients forward along the craft axis
                Vector3 dir = Vector3.forward;
                bool first = true;

                foreach (AttachNode node in part.attachNodes)
                {
                    // Doesn't seem to ever happen, but anyway
                    if (node.nodeType == AttachNode.NodeType.Surface)
                        continue;

                    // If all node orientations agree, use that axis
                    if (first)
                    {
                        first = false;
                        dir = node.orientation.normalized;
                    }
                    // Conflicting node directions - bail out
                    else if (Mathf.Abs(Vector3.Dot(dir, node.orientation.normalized)) < 0.9f)
                        return Vector3.up;
                }

                if (debug)
                    MonoBehaviour.print(part.partInfo.title + ": Choosing axis " + dir + " for KJR surface attach" + (first ? "" : " from node") + ".");

                return dir;
            }
            else
            {
                return Vector3.up;
            }
        }
开发者ID:Boris-Barboris,项目名称:Kerbal-Joint-Reinforcement,代码行数:45,代码来源:KJRJointUtils.cs

示例5: GetArmor

 public static BDArmor GetArmor(Collider collider, Part hitPart)
 {
     if (!hitPart)
         return null;
     var nodes = hitPart.partInfo.partConfig.GetNodes("BDARMOR");
     for (int i = 0; i < nodes.Length; i++)
     {
         var current = nodes[i];
         Transform transform;
         if (current.HasValue("ArmorRootTransform"))
             transform = hitPart.FindModelTransform(current.GetValue("ArmorRootTransform"));
         else
             transform = hitPart.partTransform;
         if (!transform)
         {
             Debug.LogError("Armor Transform not found!");
             return null;
         }
         if (collider.transform == transform || collider.transform.IsChildOf(transform))
         {
             return new BDArmor(nodes[i]);
         }
     }
     return null;
 }
开发者ID:gomker,项目名称:BDArmory,代码行数:25,代码来源:BDArmor.cs

示例6: GuessUpVector

        public static Vector3 GuessUpVector(Part part)
        {
            // For intakes, use the intake vector
            if (part.Modules.Contains("ModuleResourceIntake"))
            {
                ModuleResourceIntake i = part.Modules["ModuleResourceIntake"] as ModuleResourceIntake;
                Transform intakeTrans = part.FindModelTransform(i.intakeTransformName);
                return part.transform.InverseTransformDirection(intakeTrans.forward);
            }
            // If surface attachable, and node normal is up, check stack nodes or use forward
            else if (part.srfAttachNode != null &&
                     part.attachRules.srfAttach &&
                     Mathf.Abs(part.srfAttachNode.orientation.normalized.y) > 0.9f)
            {
                // When the node normal is exactly Vector3.up, the editor orients forward along the craft axis
                Vector3 dir = Vector3.forward;
                String dirname = null;

                foreach (AttachNode node in part.attachNodes)
                {
                    // Doesn't seem to ever happen, but anyway
                    if (node.nodeType == AttachNode.NodeType.Surface)
                        continue;

                    if(node.id.ToLowerInvariant() == "strut")
                        continue;

                    // If all node orientations agree, use that axis
                    String name = UpVectorFromDir(node.orientation);

                    if (dirname == null)
                    {
                        dirname = name;
                        dir = node.orientation;
                    }
                    // Conflicting node directions - bail out
                    else if (dirname != name)
                        return Vector3.up;
                }

                Debug.Log(part.partInfo.title + ": Choosing " + (dirname == null ? "heuristic forward" : dirname) + " axis for FAR drag model.");
                return dir;
            }
            else
            {
                return Vector3.up;
            }
        }
开发者ID:vosechu,项目名称:Ferram-Aerospace-Research,代码行数:48,代码来源:FARGeoUtil.cs

示例7: ProcFairingHide

 private void ProcFairingHide(VesselElementViewOptions ol, VesselElementViewOption o, Part part)
 {
     MonoBehaviour.print("Hiding Procedural Fairing: " + part.ToString());
     var nct = part.FindModelTransform("nose_collider");
     if (!nct) return;
     var forward = EditorLogic.startPod.transform.forward;
     var right = EditorLogic.startPod.transform.right;
     if (Vector3.Dot(nct.right, -(forward + right).normalized) > 0f)
     {
         var renderer = part.GetComponentInChildren<Renderer>();
         if (renderer) renderer.enabled = false;
     }
 }
开发者ID:EdwardWongHau,项目名称:ksp-kronalutils,代码行数:13,代码来源:VesselViewConfig.cs

示例8: ProcFairingExplode

 private void ProcFairingExplode(VesselElementViewOptions ol, VesselElementViewOption o, Part part)
 {
     MonoBehaviour.print("Exploding Procedural Fairing: " + part.ToString());
     var nct = part.FindModelTransform("nose_collider");
     if (!nct) return;
     MeshFilter mf;
     Vector3 extents = (mf = part.gameObject.GetComponentInChildren<MeshFilter>()) ? mf.mesh.bounds.size : new Vector3(o.valueParam, o.valueParam, o.valueParam);
     part.transform.Translate(Vector3.Scale(nct.right, extents), Space.World);
 }
开发者ID:EdwardWongHau,项目名称:ksp-kronalutils,代码行数:9,代码来源:VesselViewConfig.cs

示例9: ProcFairingHide

        private void ProcFairingHide(VesselElementViewOptions ol, VesselElementViewOption o, Part part)
        {
            if (hasMod("ProceduralFairings"))
            {
                var nct = part.FindModelTransform("nose_collider");
                if (!nct) return;
                var forward = EditorLogic.RootPart.transform.forward;
                var right = EditorLogic.RootPart.transform.right;

                if (Vector3.Dot(nct.right, -(forward).normalized) > 0f)
                {
                    var renderer = part.GetComponentInChildren<Renderer>();
                    if (renderer) renderer.enabled = false;
                }
            }
        }
开发者ID:bigorangemachine,项目名称:ksp-kronalutils,代码行数:16,代码来源:VesselViewConfig.cs

示例10: ProcFairingExplode

 private void ProcFairingExplode(VesselElementViewOptions ol, VesselElementViewOption o, Part part)
 {
     if (hasMod("ProceduralFairings"))
     {
         var nct = part.FindModelTransform("nose_collider");
         if (!nct) return;
         this.procFairingOffset = o.valueParam;
         Vector3 extents = new Vector3(o.valueParam, o.valueParam, o.valueParam);
         part.transform.Translate(Vector3.Scale(nct.right, extents), Space.World);
     }
 }
开发者ID:bigorangemachine,项目名称:ksp-kronalutils,代码行数:11,代码来源:VesselViewConfig.cs

示例11: Actuator

        public Actuator(string configData, ActuatorType creatingType, Part thatPart)
        {
            savedNodePosition = faraway;

            type = creatingType;
            string remainder;
            if (configData.StartsWith ("!", StringComparison.Ordinal)) {
                inverted = true;
                remainder = configData.Substring (1).Trim ();
            } else {
                inverted = false;
                remainder = configData;
            }

            string[] tokens = remainder.Split (',');
            switch (type) {
            case ActuatorType.PartComponent:
                moduleID = remainder;
                JUtil.LogMessage (this, "Controlling PartComponent with moduleID {0}, {1}", moduleID, inverted ? "inverted" : "regular");
                break;
            case ActuatorType.PartComponentGroup:
                moduleID = remainder;
                JUtil.LogMessage (this, "Controlling PartComponentGroup with groupID {0}, {1}", moduleID, inverted ? "inverted" : "regular");
                break;
            case ActuatorType.PartModule:
                int moduleIndex = int.Parse (remainder.Split (',') [1]);
                var thoseModules = new List<PartModule> ();
                foreach (PartModule thatModule in thatPart.Modules) {
                    if (thatModule.ClassName == tokens [0].Trim ()) {
                        thoseModules.Add (thatModule);
                    }
                }
                if (moduleIndex < thoseModules.Count) {
                    controlledModule = thoseModules [moduleIndex];
                } else {
                    JUtil.LogErrorMessage (this, "Could not find PartModule named {2} number {0} in part {1}", moduleIndex, thatPart.name, tokens [0].Trim ());
                }
                JUtil.LogMessage (this, "Controlling PartModule named {0}, {1}", controlledModule.ClassName, inverted ? "inverted" : "regular");
                break;
            case ActuatorType.TransformTexture:

                if (tokens.Length == 3 || tokens.Length == 4) {
                    targetTransform = thatPart.FindModelTransform (tokens [0].Trim ());
                    if (targetTransform == null) {
                        throw new ArgumentException ("Could not find model transform.");
                    }
                    if (GameDatabase.Instance.ExistsTexture (tokens [1].Trim ()) && GameDatabase.Instance.ExistsTexture (tokens [2].Trim ())) {
                        falseString = tokens [1].Trim ();
                        trueString = tokens [2].Trim ();
                        JUtil.LogMessage (this, "Controlling texture on transform '{0}', {1}", tokens [0].Trim (), inverted ? "inverted" : "regular");
                    } else {
                        throw new ArgumentException ("Textures not found.");
                    }
                    if (tokens.Length == 4) {
                        textureLayer = tokens [3].Trim ();
                    }
                } else {
                    throw new ArgumentException ("Bad arguments.");
                }
                break;
            case ActuatorType.TransformShader:
                if (tokens.Length == 3) {
                    targetTransform = thatPart.FindModelTransform (tokens [0].Trim ());
                    if (targetTransform == null) {
                        throw new ArgumentException ("Could not find model transform.");
                    }
                    if (Shader.Find (tokens [1].Trim ()) && Shader.Find (tokens [2].Trim ())) {
                        falseString = tokens [1].Trim ();
                        trueString = tokens [2].Trim ();
                        JUtil.LogMessage (this, "Controlling shader on transform '{0}', {1}", tokens [0].Trim (), inverted ? "inverted" : "regular");
                    } else {
                        throw new ArgumentException ("Shaders not found.");
                    }
                } else {
                    throw new ArgumentException ("Bad arguments.");
                }
                break;
            case ActuatorType.StraightParameter:
                if (tokens.Length == 2) {
                    if (float.TryParse (tokens [1], out addToParameterWhenEnabled)) {
                        if (Array.IndexOf (knownStraightParameters, tokens [0].Trim ()) >= 0) {
                            nameOfParameter = tokens [0].Trim ();
                            originalParameterValue = GetParameter (nameOfParameter, thatPart);
                            JUtil.LogMessage (this, "Controlling parameter '{0}' on part {1}, {2}", nameOfParameter, thatPart.partName, inverted ? "inverted" : "regular");
                        } else {
                            throw new ArgumentException ("Bad arguments, unknown straight parameter " + tokens [0]);
                        }
                    } else {
                        throw new ArgumentException ("Bad argument, maxTemp must be a float.");
                    }
                } else {
                    throw new ArgumentException ("Bad arguments.");
                }
                break;
            case ActuatorType.Resource:
                if (tokens.Length == 2) {
                    if (float.TryParse (tokens [1], out maxAmount)) {
                        bool found = false;
                        resourceName = tokens [0].Trim ();
                        foreach (PartResourceDefinition thatResource in PartResourceLibrary.Instance.resourceDefinitions) {
//.........这里部分代码省略.........
开发者ID:Kerbas-ad-astra,项目名称:PartUtilities,代码行数:101,代码来源:Actuator.cs


注:本文中的Part.FindModelTransform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。