Esempio n. 1
0
 /**
  * Buds only
  */
 public static SPPMessage SetType(AmbientType type)
 {
     byte[] payload = new byte[1];
     payload[0] = (byte)type;
     return(new SPPMessage(SPPMessage.MessageIds.MSG_ID_AMBIENT_VOICE_FOCUS,
                           SPPMessage.MsgType.Request, payload));
 }
Esempio n. 2
0
        void OnGUI()
        {
            _aType = (AmbientType)EditorGUILayout.EnumPopup("AmbientType", _aType);

            switch (_aType)
            {
            case AmbientType.SkyBox:
                _map    = (Cubemap)EditorGUILayout.ObjectField("EnvTex: ", _map, typeof(Cubemap), false);
                _rotate = EditorGUILayout.Slider("EnvTexRotate", _rotate, 0, 360);
                if (GUILayout.Button("Generate!"))
                {
                    _shData = SHLightGeneratorLib.GenSHBySkyBox(_map, _rotate);
                }

                break;

            case AmbientType.TriLight:
                _skyColor     = EditorGUILayout.ColorField("Sky", _skyColor);
                _equatorColor = EditorGUILayout.ColorField("Equator", _equatorColor);
                _groundColor  = EditorGUILayout.ColorField("Ground", _groundColor);
                if (GUILayout.Button("Generate!"))
                {
                    _shData = SHLightGeneratorLib.GenSHByTriLight(_skyColor, _equatorColor, _groundColor);
                }

                break;
            }

            EditorGUILayout.Space();
            if (_shData)
            {
                GUILayout.Label("SHAr: " + _shData.SHAr);
                GUILayout.Label("SHAg: " + _shData.SHAg);
                GUILayout.Label("SHAb: " + _shData.SHAb);
                GUILayout.Label("SHBr: " + _shData.SHBr);
                GUILayout.Label("SHBg: " + _shData.SHBg);
                GUILayout.Label("SHBb: " + _shData.SHBb);
                GUILayout.Label("SHC: " + _shData.SHC);
                if (GUILayout.Button("SaveSHData"))
                {
                    string path = EditorUtility.SaveFilePanel("SaveSHData", Application.dataPath, "SHData", "asset");
                    if (!string.IsNullOrEmpty(path))
                    {
                        if (!path.Contains(Application.dataPath))
                        {
                            Debug.LogError("Invalid Path");
                            return;
                        }

                        path = "Assets" + path.Replace(Application.dataPath, "");
                        AssetDatabase.CreateAsset(_shData, path);
                        Selection.activeObject = _shData;
                    }
                }
            }
        }
Esempio n. 3
0
    public void changeSkybox(AmbientType skyNumber)
    {
        cameraObject.GetComponent <Skybox>().material = skyboxMaterials[(int)skyNumber];

        if (skyNumber == AmbientType.AMBIENT_SKYBOX_SUNNY)
        {
            lightObject.GetComponent <Light>().intensity = 0.5f;
            spotLightObject.SetActive(false);
            changeShadow(true);
        }
        else if (skyNumber == AmbientType.AMBIENT_SKYBOX_CLOUD)
        {
            lightObject.GetComponent <Light>().intensity = 0.3f;
            spotLightObject.SetActive(false);
            changeShadow(true);
        }
        else if (skyNumber == AmbientType.AMBIENT_SKYBOX_NIGHT)
        {
            lightObject.GetComponent <Light>().intensity = 0.1f;
            spotLightObject.SetActive(true);
            changeShadow(false);
        }
    }
Esempio n. 4
0
    public void changeSkybox(AmbientType skyNumber)
    {
        cameraObject.GetComponent<Skybox>().material = skyboxMaterials[(int)skyNumber];

        if (skyNumber == AmbientType.AMBIENT_SKYBOX_SUNNY)
        {
            lightObject.GetComponent<Light>().intensity = 0.5f;
            spotLightObject.SetActive(false);
            changeShadow(true);
        }
        else if (skyNumber == AmbientType.AMBIENT_SKYBOX_CLOUD)
        {
            lightObject.GetComponent<Light>().intensity = 0.3f;
            spotLightObject.SetActive(false);
            changeShadow(true);
        }
        else if (skyNumber == AmbientType.AMBIENT_SKYBOX_NIGHT)
        {
            lightObject.GetComponent<Light>().intensity = 0.1f;
            spotLightObject.SetActive(true);
            changeShadow(false);
        }
    }
Esempio n. 5
0
        internal bool Setup(SndInfoParser parser)
        {
            // Read index
            if (!parser.ReadSignedInt(ref index))
            {
                // Not numeric!
                parser.ReportError("Expected $ambient <index> value");
                return(false);
            }

            // Check index
            //INFO: Up to 64 ambient sounds can be used in the Doom map format and 256 in Hexen format. UDMF maps have no limit.
            //TODO: can index be zero/negative in UDMF?
            if (General.Map.DOOM && (index < 1 || index > 64))
            {
                parser.ReportError("$ambient <index> must be in [1..64] range");
                return(false);
            }
            if (General.Map.HEXEN && (index < 1 || index > 256))
            {
                parser.ReportError("$ambient <index> must be in [1..256] range");
                return(false);
            }

            // Read name
            if (!parser.SkipWhitespace(true))
            {
                return(false);
            }
            soundname = parser.StripTokenQuotes(parser.ReadToken(false));
            if (string.IsNullOrEmpty(soundname))
            {
                parser.ReportError("Expected $ambient <logicalsound> value");
                return(false);
            }

            // Next token can be either [type] or <mode>...
            if (!parser.SkipWhitespace(true))
            {
                return(false);
            }
            string token = parser.ReadToken(false).ToLowerInvariant();

            // Can be [type]
            if (token == "point" || token == "surround" || token == "world")
            {
                // Next token may be attenuation...
                if (token == "point")
                {
                    if (!parser.SkipWhitespace(false))
                    {
                        return(false);
                    }
                    string next = parser.ReadToken(false);
                    if (!parser.ReadSignedFloat(next, ref attenuation) || attenuation < 0f)
                    {
                        // Rewind so this structure can be read again
                        parser.DataStream.Seek(-next.Length - 1, SeekOrigin.Current);
                    }
                }

                // Store type
                switch (token)
                {
                case "point": type = AmbientType.POINT; break;

                case "surround": type = AmbientType.SURROUND; break;

                case "world": type = AmbientType.WORLD; break;
                }

                // Read next token
                if (!parser.SkipWhitespace(false))
                {
                    return(false);
                }
                token = parser.ReadToken(false).ToLowerInvariant();
            }

            // Sould be <mode>
            if (token == "continuous" || token == "random" || token == "periodic")
            {
                // Next 2 tokens must be minsecs and maxsecs
                if (token == "random")
                {
                    if (!parser.SkipWhitespace(false))
                    {
                        return(false);
                    }
                    if (!parser.ReadSignedFloat(ref minsecs) || minsecs < 0f)
                    {
                        parser.ReportError("Expected $ambient <minsecs> value");
                        return(false);
                    }

                    if (!parser.SkipWhitespace(false))
                    {
                        return(false);
                    }
                    if (!parser.ReadSignedFloat(ref maxsecs) || maxsecs < 0f)
                    {
                        parser.ReportError("Expected $ambient <maxsecs> value");
                        return(false);
                    }
                }
                // Next token must be secs
                else if (token == "periodic")
                {
                    if (!parser.SkipWhitespace(false))
                    {
                        return(false);
                    }
                    if (!parser.ReadSignedFloat(ref secs) || secs < 0f)
                    {
                        parser.ReportError("Expected $ambient <secs> value");
                        return(false);
                    }
                }

                // Store mode
                switch (token)
                {
                case "continuous": mode = AmbientMode.CONTINUOUS; break;

                case "random": mode = AmbientMode.RANDOM; break;

                case "periodic": mode = AmbientMode.PERIODIC; break;
                }
            }
            else
            {
                parser.ReportError("Expected ambient sound <mode> or [type]");
                return(false);
            }

            // Read volume
            if (!parser.SkipWhitespace(false))
            {
                return(false);
            }
            if (!parser.ReadSignedFloat(ref volume) || volume < 0f)
            {
                parser.ReportError("Expected ambient sound <volume> value");
                return(false);
            }

            // There can be multiple different ambient sounds with the same sound name, so build a description containing the index
            // and the name to differentiate them. See https://github.com/jewalky/UltimateDoomBuilder/issues/390
            sounddescription = index.ToString() + ": " + soundname + " (" + type.ToString().ToLowerInvariant();

            if (type == AmbientType.POINT)
            {
                sounddescription += ", attenuation: " + attenuation;
            }

            if (mode == AmbientMode.CONTINUOUS)
            {
                sounddescription += ", " + mode.ToString().ToLowerInvariant();
            }
            else if (mode == AmbientMode.RANDOM)
            {
                sounddescription += ", every " + minsecs + " to " + maxsecs + " seconds";
            }
            else if (mode == AmbientMode.PERIODIC)
            {
                sounddescription += ", every " + secs + " seconds";
            }

            sounddescription += ", " + volume * 100 + "% volume)";

            return(true);
        }