Пример #1
0
        // Use this for initialization
        void Start()
        {
            if (parent)
            {
                TelescopeElement parentElement = parent.getChildElement(parentElementNum);
                transform.parent = parentElement.transform;

                if (!keepLocalPositionOnStart)
                {
                    transform.localPosition = parentElement.getAttachmentLocation(offsetAlongParent);
                    transform.localRotation = parentElement.getAttachmentRotation(offsetAlongParent);
                }
            }

            /*
             * GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
             * sphere.transform.parent = transform;
             * sphere.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
             * sphere.transform.localPosition = Vector3.zero; */

            line = gameObject.AddComponent <LineRenderer>();
            line.useWorldSpace = false;
            line.material      = DesignerController.instance.defaultLineMaterial;
            line.SetWidth(0.1f, 0.1f);

            List <Vector3> points       = new List <Vector3>();
            int            numNeighbors = 0;

            if (parentSegment)
            {
                points.Add(parentSegment.LastShell.transform.position - transform.position);
                points.Add(Vector3.zero);
                numNeighbors++;
            }

            foreach (TelescopeSegment seg in childSegments)
            {
                points.Add(seg.FirstShell.transform.position - transform.position);
                points.Add(Vector3.zero);
            }

            numNeighbors += childSegments.Count;

            line.SetVertexCount(points.Count);
            line.SetPositions(points.ToArray());

            // If this bulb is a dead end, make it a sphere.
            junctureType = (numNeighbors <= 1) ? JunctureType.Sphere : JunctureType.ConvexHull;
            previousType = JunctureType.None;

            if (!mFilter)
            {
                mFilter = gameObject.AddComponent <MeshFilter>();
            }
            if (!meshRenderer)
            {
                meshRenderer          = gameObject.AddComponent <MeshRenderer>();
                meshRenderer.material = DesignerController.instance.defaultTelescopeMaterial;
            }
        }
Пример #2
0
        public void SetParentToSegmentEnd(TelescopeSegment segment)
        {
            parent           = segment;
            parentElementNum = segment.shells.Count - 1;

            parentSegment = segment;
            //SetParent(segment, segment.shells.Count - 1, 1);
        }
Пример #3
0
 void Start()
 {
     if (parent)
     {
         TelescopeElement element = parent.getChildElement(parentElementNumber);
         this.transform.parent = element.transform;
         if (keepLocalPositionOnStart)
         {
             offsetFromParent = this.transform.position - element.transform.position;
         }
         else
         {
             this.transform.position = element.transform.position + offsetFromParent;
         }
     }
 }
Пример #4
0
        public void SetParent(TelescopeElement element, int parentElementNum, float attachmentPoint)
        {
            if (element == null)
            {
                transform.parent = null;
                return;
            }

            parent = element;
            TelescopeElement parentElement = element.getChildElement(parentElementNum);

            this.parentElementNum        = parentElementNum;
            this.offsetAlongParent       = attachmentPoint;
            this.transform.parent        = parentElement.transform;
            this.transform.localPosition = parentElement.getAttachmentLocation(attachmentPoint);
            this.transform.localRotation = parentElement.getAttachmentRotation(attachmentPoint);
        }
Пример #5
0
 public void SetParent(TelescopeJuncture bulb)
 {
     parent = bulb;
     parentElementNumber = 0;
 }