예제 #1
0
    public void BuildLODs()
    {
        ClearLODs();

        if (numberLODs == 0)
        {
            return;
        }

        if (m_rootLODs == null)
        {
            m_rootLODs = this.transform.Find("LODs");
        }

        int sidesPrev = sides;

        for (int i = 0; i < numberLODs; i++)
        {
            float koeff    = koeffLOD * (i + 1);
            int   tris     = (int)((float)triangles / koeff);
            int   newsides = CalculateParametersByPolycount(tris, hasThickness, m_splines.Samples.Count);
            if (newsides < sidesPrev)
            {
                TubeSettings settings = new TubeSettings()
                {
                    hasThickness = hasThickness,
                    radius       = radius,
                    samples      = m_splines.Samples,
                    shellType    = shellType,
                    sides        = newsides,
                    thickness    = thickness
                };
                MeshBuilder            builder = new MeshBuilder(settings);
                MeshBuilder.CustomMesh mesh    = builder.Build();

                TubeObject lod = new TubeObject();
                lod.SetTube(this.m_rootLODs);
                lod.WriteMesh(mesh);

                lod.go.name = "lod" + (i + 1);

                lods.Add(lod);

                sidesPrev = newsides;
            }
            else
            {
                Debug.LogWarning("You are reached a triangles limit!");
            }
        }
    }
예제 #2
0
 void WriteMesh(MeshBuilder.CustomMesh cmesh)
 {
     m_tube.WriteMesh(cmesh);
 }