Example #1
0
        public GameObject[] generatePanels(Transform parent)
        {
            //each panelEdgeGroup should now contain the vertical edge loops for each vertical panel grouping
            //from here, need to generate meshes for panels depending upon splitPanels setting
            int len = panelGroups.Length;

            GameObject[] gos = new GameObject[panels];
            for (int i = 0; i < len; i++)
            {
                gos[i] = parent.FindOrCreate("FairingPanel-" + i).gameObject;
                SSTUUtils.destroyChildren(gos[i].transform);//remove any existing colliders
                MeshFilter mf = gos[i].GetComponent <MeshFilter>();
                if (mf == null)
                {
                    mf = gos[i].AddComponent <MeshFilter>();
                }
                mf.mesh = panelGroups[i].generatePanels(offset, outsideUV, insideUV, edgesUV);
                if (colliders)
                {
                    GameObject[] cols = panelGroups[i].generateColliders(offset, facesPerCollider);
                    for (int k = 0; k < cols.Length; k++)
                    {
                        cols[k].transform.NestToParent(gos[i].transform);
                    }
                }
                MeshRenderer mr = gos[i].GetComponent <MeshRenderer>();
                if (mr == null)
                {
                    mr = gos[i].AddComponent <MeshRenderer>();
                }
                gos[i].transform.parent        = parent;
                gos[i].transform.localPosition = Vector3.zero;
                gos[i].transform.rotation      = parent.rotation;
            }
            Transform[] trs;
            for (int i = len; i < 8; i++)//destroy extra unused panels
            {
                trs = parent.transform.FindChildren("FairingPanel-" + i);
                for (int k = 0; k < trs.Length; k++)
                {
                    GameObject.Destroy(trs[k].gameObject);
                }
            }
            return(gos);
        }
        public void enable(Transform root, float yOffset)
        {
            SSTUUtils.destroyChildren(root);
            int len = positions.Length;

            rootTransforms = new Transform[len];
            models         = new SingleModelData[len];
            Vector3 pos;

            for (int i = 0; i < len; i++)
            {
                rootTransforms[i] = new GameObject(root.name + "-" + i).transform;
                pos    = positions[i].position.CopyVector();
                pos.y += yOffset;
                rootTransforms[i].parent        = root;
                rootTransforms[i].position      = root.position;
                rootTransforms[i].rotation      = root.rotation;
                rootTransforms[i].localPosition = pos;
                rootTransforms[i].Rotate(positions[i].rotation, Space.Self);
                models[i] = new SingleModelData(modelName);
                models[i].setupModel(rootTransforms[i], ModelOrientation.TOP);
                rootTransforms[i].localScale = positions[i].scale;
            }
        }
Example #3
0
 public void destroyModel()
 {
     SSTUUtils.destroyChildren(root.transform);
 }
Example #4
0
 public void destroyExistingPanels()
 {
     SSTUUtils.destroyChildren(rootObject.transform);
 }