Ejemplo n.º 1
0
        private void InitGameObject()
        {
            gao = new GameObject("[PO]");
            for (int i = 0; i < visualSet.Length; i++)
            {
                if (visualSet[i].obj == null)
                {
                    continue;
                }

                switch (visualSet[i].obj)
                {
                case GeometricObject m:
                    if (m.name != "Mesh")
                    {
                        Gao.name = "[PO] " + m.name;
                    }
                    break;

                case PatchGeometricObject mod:
                    if (mod.mesh != null && mod.mesh.name != "Mesh")
                    {
                        Gao.name = "[PO] " + mod.mesh.name;
                    }
                    Gao.name += " - Patch";
                    break;
                }
                // Initialize children
                if (visualSet[i].obj.Gao != null)
                {
                    visualSet[i].obj.Gao.transform.parent = Gao.transform;
                }
            }

            if (visualSet.Length > 1)   // = number of LOD
            {
                LODComponent lod = Gao.AddComponent <LODComponent>();
                lod.visualSet   = visualSet;
                lod.gameObjects = visualSet.Select(v => v.obj.Gao).ToArray();

                /*float bestLOD = po.visualSet.Min(v => v.LODdistance);
                 * foreach (VisualSetLOD lod in po.visualSet) {
                 *  if (lod.obj.Gao != null && lod.LODdistance != bestLOD) lod.obj.Gao.SetActive(false);
                 * }*/
            }
            if (collideMesh != null && collideMesh.Gao != null)
            {
                collideMesh.Gao.transform.parent = Gao.transform;
            }
        }
Ejemplo n.º 2
0
        public void SetVisualsActive(bool active)
        {
            if (Gao == null)
            {
                return;
            }
            Renderer[] renderers = Gao.GetComponentsInChildren <Renderer>(includeInactive: true);
            foreach (Renderer ren in renderers)
            {
                ren.enabled = active;
            }

            /*if (subblocks != null) {
             *  foreach (ICollideGeometricElement subblock in subblocks) {
             *      GameObject child = subblock.Gao;
             *      if (child != null) {
             *          Renderer mainRen = child.GetComponent<Renderer>();
             *      }
             *      //subblock.Gao
             *  }
             * }*/
        }