Exemplo n.º 1
0
        internal static int GetWindows()
        {
            GameObject[] rObjs = ALUtils.GetRootObjects().ToArray();

            int wCount = 0;

            foreach (GameObject rootObj in rObjs)
            {
                Renderer   childRenderer = rootObj.GetComponent <Renderer>();
                Renderer[] allRenderers  = rootObj.GetComponentsInChildren <Renderer>();
                //allRenderers.Add(childRenderer);
                allRenderers.AddItem(childRenderer);

                foreach (Renderer renderer in allRenderers)
                {
                    if (!renderer.gameObject.name.Contains("_XPZ_Window"))
                    {
                        foreach (Material mat in renderer.materials)
                        {
                            if (mat.name.ToLower().Contains("glow") && !renderer.gameObject.name.ToLower().Contains("truck") && !renderer.gameObject.name.ToLower().Contains("car") && !renderer.gameObject.name.ToLower().Contains("lamp"))
                            {
                                gameWindows.Add(renderer);
                                renderer.gameObject.name += "_XPZ_Window";

                                WindowsCastShadow(renderer.gameObject);
                                renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                                renderer.receiveShadows    = false;

                                wCount++;
                                break;
                            }
                        }
                    }
                }
            }

            return(wCount);
        }
Exemplo n.º 2
0
        /****** SCENE *****/
        internal static void PrepareSceneShadows()
        {
            GameObject[] rObjs = ALUtils.GetRootObjects().ToArray();

            foreach (GameObject rootObj in rObjs)
            {
                MeshRenderer   childRenderer = rootObj.GetComponent <MeshRenderer>();
                MeshRenderer[] allRenderers  = rootObj.GetComponentsInChildren <MeshRenderer>();
                //allRenderers.Add(childRenderer);
                allRenderers.AddItem(childRenderer);

                foreach (MeshRenderer renderer in allRenderers)
                {
                    //Remove glass from sun layer
                    Material[] mats = renderer.materials;

                    foreach (Material mat in mats)
                    {
                        if (mat.name.ToLower().Contains("glass"))
                        {
                            renderer.gameObject.layer = 7;
                            continue;
                        }
                    }

                    //Ignore
                    if (renderer == null || renderer.gameObject.name.Contains("XPZ_Wall") || renderer.gameObject.name.Contains("XPZ_BaseWindow") ||
                        (renderer.gameObject.name.StartsWith("OBJ_") && !renderer.gameObject.name.ToLower().Contains("door") && !renderer.gameObject.name.ToLower().Contains("curtain") && !renderer.gameObject.name.ToLower().Contains("car")) ||
                        renderer.gameObject.name.StartsWith("GEAR_") ||
                        renderer.gameObject.name.StartsWith("FX_") ||
                        renderer.gameObject.name.StartsWith("CONTAINER_") ||
                        renderer.gameObject.name.StartsWith("INTERACTIVE_")
                        )
                    {
                        continue;
                    }

                    //Hide
                    if (renderer.gameObject.name.ToLower().Contains("shadow_caster") ||
                        (renderer.gameObject.name.ToLower().Contains("cylinder") && !renderer.material.name.StartsWith("FX_")) ||
                        renderer.gameObject.name.ToLower().Contains("sphere")
                        )
                    {
                        renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                        renderer.gameObject.SetActive(false);

                        continue;
                    }

                    //Glass-Glow
                    if ((renderer.gameObject.name.ToLower().Contains("glass") || renderer.gameObject.name.ToLower().Contains("glow")) && (!renderer.gameObject.name.ToLower().Contains("shadow") && !renderer.gameObject.name.ToLower().Contains("truck") && !renderer.gameObject.name.ToLower().Contains("car") && !renderer.gameObject.name.ToLower().Contains("xpz_window")))
                    {
                        renderer.gameObject.name += "_XPZ_BaseWindow";

                        renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;

                        continue;
                    }
                    else if (renderer.gameObject.name.ToLower().Contains("glow") && renderer.gameObject.name.ToLower().Contains("shadow"))
                    {
                        renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                        renderer.gameObject.SetActive(false);

                        continue;
                    }

                    if (renderer.gameObject.name.ToLower().Contains("decal"))
                    {
                        renderer.receiveShadows = true;
                        qd_Decal decalInst = renderer.GetComponent <qd_Decal>();

                        vp_Layer.Set(renderer.gameObject, 7, false);

                        continue;
                    }

                    //Rest - Cast shadows if not transparent
                    if (renderer.shadowCastingMode == UnityEngine.Rendering.ShadowCastingMode.Off || renderer.shadowCastingMode == UnityEngine.Rendering.ShadowCastingMode.On)
                    {
                        //Material[] mats = renderer.materials;

                        renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.TwoSided;

                        /*foreach (Material mat in mats)
                         * {
                         *  if (mat.name.ToLower().Contains("glass"))
                         *  {
                         *      renderer.gameObject.layer = 7;
                         *      continue;
                         *  }
                         * }*/
                    }
                    else if (renderer.shadowCastingMode == UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly)
                    {
                        FlipMesh(renderer.gameObject);
                    }
                }
            }
        }