public SkyboxSceneObjectComponent(string location, SkyboxType type) { _skyboxLocation = location; skyboxType = type; switch (skyboxType) { case SkyboxType.cubemap: { _shader = new ShaderProg("vs_cubemap.glsl", "fs_cubemap.glsl", true); break; } case SkyboxType.hdr: { _shader = new ShaderProg("vs_hdr.glsl", "fs_hdr.glsl", true); break; } default: break; } }
public SkyboxSceneObjectComponent(string location, ShaderProg Shader, SkyboxType type) { _skyboxLocation = location; _shader = Shader; skyboxType = type; }
public void SetSkyboxType(SkyboxType skyboxType) { _bufferedSettings.SkyboxType = skyboxType; }
void Transition(SkyboxType type, float time) { StartCoroutine(crTransition(type, time)); }
void Transition(SkyboxType type, Color color, float time) { StartCoroutine(crTransition(color, time)); StartCoroutine(crTransition(type, time)); }
IEnumerator crTransition(SkyboxType type, float time) { if (skyboxTexTrans) yield break; Texture[] textures; switch (type) { case SkyboxType.NIGHT: { textures = nightSkybox; break; } default: { textures = daySkybox; break; } } tSkybox = createSkybox("skybox", textures); tSkybox.parent = gSkybox.parent; MeshRenderer gmr = (MeshRenderer)gSkybox.GetComponent("MeshRenderer"); MeshRenderer tmr = (MeshRenderer)tSkybox.GetComponent("MeshRenderer"); Color color = new Color( gmr.materials[0].color.r, gmr.materials[0].color.g, gmr.materials[0].color.b, 0.0f); for (int i = 0; i < 6; i++) tmr.materials[i].color = color; skyboxTexTrans = true; float j = 0.0f; while (j <= 1.0f) { gmr.materials[0].color = new Color( gmr.materials[0].color.r, gmr.materials[0].color.g, gmr.materials[0].color.b, 1.0f - j); tmr.materials[0].color = new Color( gmr.materials[0].color.r, gmr.materials[0].color.g, gmr.materials[0].color.b, j); for (int i = 1; i < 6; i++) { gmr.materials[i].color = gmr.materials[0].color; tmr.materials[i].color = tmr.materials[0].color; } j += Time.deltaTime / time; yield return null; } tmr.materials[0].color = new Color( gmr.materials[0].color.r, gmr.materials[0].color.g, gmr.materials[0].color.b, 1.0f); for (int i = 1; i < 6; i++) tmr.materials[i].color = tmr.materials[0].color; GameObject.Destroy(gSkybox.gameObject); gSkybox = tSkybox; tSkybox = null; skyboxTexTrans = false; }
IEnumerator crTransition(SkyboxType type, float time) { if (skyboxTexTrans) { yield break; } Texture[] textures; switch (type) { case SkyboxType.NIGHT: { textures = nightSkybox; break; } default: { textures = daySkybox; break; } } tSkybox = createSkybox("skybox", textures); tSkybox.parent = gSkybox.parent; MeshRenderer gmr = (MeshRenderer)gSkybox.GetComponent("MeshRenderer"); MeshRenderer tmr = (MeshRenderer)tSkybox.GetComponent("MeshRenderer"); Color color = new Color( gmr.materials[0].color.r, gmr.materials[0].color.g, gmr.materials[0].color.b, 0.0f); for (int i = 0; i < 6; i++) { tmr.materials[i].color = color; } skyboxTexTrans = true; float j = 0.0f; while (j <= 1.0f) { gmr.materials[0].color = new Color( gmr.materials[0].color.r, gmr.materials[0].color.g, gmr.materials[0].color.b, 1.0f - j); tmr.materials[0].color = new Color( gmr.materials[0].color.r, gmr.materials[0].color.g, gmr.materials[0].color.b, j); for (int i = 1; i < 6; i++) { gmr.materials[i].color = gmr.materials[0].color; tmr.materials[i].color = tmr.materials[0].color; } j += Time.deltaTime / time; yield return(null); } tmr.materials[0].color = new Color( gmr.materials[0].color.r, gmr.materials[0].color.g, gmr.materials[0].color.b, 1.0f); for (int i = 1; i < 6; i++) { tmr.materials[i].color = tmr.materials[0].color; } GameObject.Destroy(gSkybox.gameObject); gSkybox = tSkybox; tSkybox = null; skyboxTexTrans = false; }
/// <summary> /// Changes the sky that is displayed in the specified area. /// nSkyBox = SKYBOX_* constants (associated with skyboxes.2da) /// If no valid area (or object) is specified, it uses the area of caller. /// If an object other than an area is specified, will use the area that the object is currently in. /// </summary> public static void SetSkyBox(SkyboxType nSkyBox, uint oArea = OBJECT_INVALID) { Internal.NativeFunctions.StackPushObject(oArea); Internal.NativeFunctions.StackPushInteger(nSkyBox.InternalValue); Internal.NativeFunctions.CallBuiltIn(777); }