Exemplo n.º 1
0
        void ProcessCommon(GameObject go, bool genLightmapUV, int lod)
        {
            MeshFilter[] mfs = go.GetComponentsInChildren <MeshFilter>();
            foreach (var mf in mfs)
            {
                if (mf && mf.sharedMesh)
                {
                    MeshTool mt = new MeshTool(mf.sharedMesh);

                    var normalMappedLogo = go.name.StartsWith("knob") && !go.name.EndsWith("C");

                    if (lod == 0)
                    {
                        mt.GenerateChamfer(1.0f / mf.transform.localScale.x);
                    }

                    if (normalMappedLogo)
                    {
                        mt.GenerateKnobNormalMapUVs();
                    }
                    else
                    {
                        mt.ClearNormalMapUVs();
                    }

                    mt.ApplyTo(mf.sharedMesh, normalMappedLogo, genLightmapUV);

                    EditorUtility.SetDirty(mf.sharedMesh);

                    System.GC.Collect();
                }
            }
        }
Exemplo n.º 2
0
        void ProcessNew(GameObject go, bool genLightmapUV, int lod)
        {
            MeshFilter[] mfs = go.GetComponentsInChildren <MeshFilter>();
            foreach (var mf in mfs)
            {
                if (mf && mf.sharedMesh)
                {
                    // Get rid of knob, pin and tube geometry.
                    if (mf.name.StartsWith("knob_") || mf.name.StartsWith("pin_") || mf.name.StartsWith("tube_"))
                    {
                        Object.DestroyImmediate(mf.sharedMesh);
                        continue;
                    }

                    MeshTool mt = new MeshTool(mf.sharedMesh);

                    var decoration = mf.name.StartsWith("VME_");

                    // Skip decoration surfaces.
                    if (!decoration)
                    {
                        if (lod == 0)
                        {
                            mt.GenerateChamfer(1.0f / mf.transform.localScale.x);
                        }
                        mt.ClearNormalMapUVs();
                    }

                    mt.ApplyTo(mf.sharedMesh, false, genLightmapUV);

                    EditorUtility.SetDirty(mf.sharedMesh);

                    System.GC.Collect();
                }
            }

            // Get rid of knob and tube parent transforms.
            var knobs = go.transform.Find("Knobs");

            if (knobs)
            {
                Object.DestroyImmediate(knobs.gameObject);
            }
            var tubes = go.transform.Find("Tubes");

            if (tubes)
            {
                Object.DestroyImmediate(tubes.gameObject);
            }
        }
Exemplo n.º 3
0
        void ProcessCommon(GameObject go, bool genLightmapUV, int lod)
        {
            MeshFilter[] mfs = go.GetComponentsInChildren <MeshFilter>();
            foreach (var mf in mfs)
            {
                if (mf && mf.sharedMesh)
                {
                    MeshTool mt = new MeshTool(mf.sharedMesh);

                    var normalMappedLogo = go.name.StartsWith("knob") && !go.name.EndsWith("C");

                    // Generate lowest possible LOD.
                    var bounds = mf.sharedMesh.bounds;
                    var knob   = go.name.StartsWith("knob");
                    var hollow = knob ? go.name.EndsWith("C") : go.name.StartsWith("tube");
                    PartUtility.CreateCommonPartLod2(go.name, bounds.size.y, bounds.extents.x, knob, hollow, bounds.extents.x - 0.08f, genLightmapUV);

                    if (lod == 0)
                    {
                        mt.GenerateChamfer(1.0f / mf.transform.localScale.x);
                    }

                    if (normalMappedLogo)
                    {
                        mt.GenerateKnobNormalMapUVs();
                    }
                    else
                    {
                        mt.ClearNormalMapUVs();
                    }

                    mt.ApplyTo(mf.sharedMesh, normalMappedLogo, genLightmapUV);

                    EditorUtility.SetDirty(mf.sharedMesh);

                    System.GC.Collect();
                }
            }
        }