Beispiel #1
0
        /// <summary>
        /// Creates and displays a mesh that represents a connecting pipe between the source and the
        /// target parts.
        /// </summary>
        protected virtual void CreateLinkPipe()
        {
            var nrmTexture = pipeNormalsTexturePath != ""
        ? GetTexture(pipeNormalsTexturePath, asNormalMap: true)
        : null;
            var material = CreateMaterial(GetTexture(pipeTexturePath),
                                          mainTexNrm: nrmTexture,
                                          overrideShaderName: shaderNameOverride,
                                          overrideColor: colorOverride);

            linkPipe = Meshes.CreateCylinder(pipeDiameter, 1f, material, partModelTransform,
                                             colliderType: Colliders.PrimitiveCollider.Shape);
            Colliders.UpdateColliders(linkPipe, isPhysical: pipeColliderIsPhysical);
            if (pipeColliderIsPhysical)
            {
                CollisionManager.IgnoreCollidersOnVessel(
                    vessel, linkPipe.GetComponentsInChildren <Collider>());
                // TODO(ihsoft): Ignore the parts when migrated to the interfaces.
                Colliders.SetCollisionIgnores(sourceTransform.root, targetTransform.root, true);
            }
            linkPipeMR = linkPipe.GetComponent <Renderer>(); // To speedup OnUpdate() handling.
            SetupPipe(linkPipe.transform,
                      sourceJointNode.pipeAttach.position, targetJointNode.pipeAttach.position);
            RescaleTextureToLength(linkPipe, pipeTextureSamplesPerMeter,
                                   renderer: linkPipeMR, scaleRatio: 1 / stretchRatio);
            // Let the part know about the new mesh so that it could be properly highlighted.
            part.RefreshHighlighter();
        }
Beispiel #2
0
 /// <inheritdoc/>
 protected override void SetCollisionIgnores(Part otherPart, bool ignore)
 {
     if (pipeTransform != null)
     {
         Colliders.SetCollisionIgnores(pipeTransform, otherPart.transform, ignore);
     }
     Colliders.SetCollisionIgnores(sourceJointNode.rootModel, otherPart.transform, ignore);
     Colliders.SetCollisionIgnores(targetJointNode.rootModel, otherPart.transform, ignore);
 }