Ejemplo n.º 1
0
        public void BakeEffectThread()
        {
            BakingSettings bakeSettings;

            bakeSettings.bakeConvolution = bakeConvolution ? Bool.True : Bool.False;
            bakeSettings.bakeParametric  = bakeParameteric ? Bool.True : Bool.False;

            foreach (ProbeBox probeBox in duringBakeProbeBoxes)
            {
                if (cancelBake)
                {
                    return;
                }

                IntPtr probeBoxPtr = IntPtr.Zero;
                try
                {
                    PhononCore.iplLoadProbeBox(probeBox.probeBoxData, probeBox.probeBoxData.Length, ref probeBoxPtr);
                    probeBoxBakingCurrently++;
                }
                catch (Exception e)
                {
                    Debug.LogError(e.Message);
                }

                PhononCore.iplBakeReverb(duringBakeEnvComponent.Environment().GetEnvironment(), probeBoxPtr, bakeSettings, bakeCallback);

                if (cancelBake)
                {
                    return;
                }

                int probeBoxSize = PhononCore.iplSaveProbeBox(probeBoxPtr, null);
                probeBox.probeBoxData = new byte[probeBoxSize];
                PhononCore.iplSaveProbeBox(probeBoxPtr, probeBox.probeBoxData);

                int probeBoxEffectSize = PhononCore.iplGetBakedDataSizeByName(probeBoxPtr, "__reverb__");
                probeBox.UpdateProbeDataMapping("__reverb__", probeBoxEffectSize);

                PhononCore.iplDestroyProbeBox(ref probeBoxPtr);
            }

            bakeStatus = BakeStatus.Complete;
        }
Ejemplo n.º 2
0
        public void BakeEffectThread()
        {
            BakingSettings bakeSettings;

            bakeSettings.bakeConvolution = bakeConvolution ? Bool.True : Bool.False;
            bakeSettings.bakeParametric  = bakeParameteric ? Bool.True : Bool.False;

            foreach (ProbeBox probeBox in duringBakeProbeBoxes)
            {
                if (cancelBake)
                {
                    return;
                }

                if (probeBox.probeBoxData == null || probeBox.probeBoxData.Length == 0)
                {
                    Debug.LogError("Skipping probe box, because probes have not been generated for it.");
                    continue;
                }

                IntPtr probeBoxPtr = IntPtr.Zero;
                try
                {
                    PhononCore.iplLoadProbeBox(probeBox.probeBoxData, probeBox.probeBoxData.Length, ref probeBoxPtr);
                    probeBoxBakingCurrently++;
                }
                catch (Exception e)
                {
                    Debug.LogError(e.Message);
                }

                if (duringBakeMode == BakingMode.Reverb)
                {
                    PhononCore.iplBakeReverb(duringBakePhononContainer.Environment().GetEnvironment(), probeBoxPtr,
                                             bakeSettings, bakeCallback);
                }
                else if (duringBakeMode == BakingMode.StaticListener)
                {
                    PhononCore.iplBakeStaticListener(duringBakePhononContainer.Environment().GetEnvironment(), probeBoxPtr,
                                                     duringBakeSphere, duringBakeIdentifier, bakeSettings, bakeCallback);
                }
                else if (duringBakeMode == BakingMode.StaticSource)
                {
                    PhononCore.iplBakePropagation(duringBakePhononContainer.Environment().GetEnvironment(), probeBoxPtr,
                                                  duringBakeSphere, duringBakeIdentifier, bakeSettings, bakeCallback);
                }

                if (cancelBake)
                {
                    return;
                }

                int probeBoxSize = PhononCore.iplSaveProbeBox(probeBoxPtr, null);
                probeBox.probeBoxData = new byte[probeBoxSize];
                PhononCore.iplSaveProbeBox(probeBoxPtr, probeBox.probeBoxData);

                string bakeDataString = "__reverb__";
                if (duringBakeMode == BakingMode.StaticListener)
                {
                    bakeDataString = bakedListenerPrefix + duringBakeIdentifier;
                }
                else if (duringBakeMode == BakingMode.StaticSource)
                {
                    bakeDataString = duringBakeIdentifier;
                }

                int probeBoxEffectSize = PhononCore.iplGetBakedDataSizeByName(probeBoxPtr, bakeDataString);
                probeBox.UpdateProbeDataMapping(bakeDataString, probeBoxEffectSize);

                PhononCore.iplDestroyProbeBox(ref probeBoxPtr);
            }

            bakeStatus = BakeStatus.Complete;
        }
Ejemplo n.º 3
0
        public void BakeEffectThread()
        {
            BakingSettings bakeSettings;

            bakeSettings.bakeConvolution = bakeConvolution ? Bool.True : Bool.False;
            bakeSettings.bakeParametric  = bakeParameteric ? Bool.True : Bool.False;

#if UNITY_EDITOR
            totalObjects          = duringBakeObjects.Length;
            objectBakingCurrently = 0;
#endif

            for (int i = 0; i < duringBakeObjects.Length; ++i)
            {
                string bakeDataString = "__reverb__";
                bakingGameObjectName = "reverb";
                if (duringBakeModes[i] == BakingMode.StaticListener)
                {
                    bakeDataString       = bakedListenerPrefix + duringBakeIdentifiers[i];
                    bakingGameObjectName = duringBakeIdentifiers[i];
                }
                else if (duringBakeModes[i] == BakingMode.StaticSource)
                {
                    bakeDataString       = duringBakeIdentifiers[i];
                    bakingGameObjectName = duringBakeIdentifiers[i];
                }

                Debug.Log("START: Baking effect for " + bakingGameObjectName + ".");
                ++objectBakingCurrently;

#if UNITY_EDITOR
                totalProbeBoxes = duringBakeProbeBoxes[i].Length;
#endif

                probeBoxBakingCurrently = 0;
                foreach (ProbeBox probeBox in duringBakeProbeBoxes[i])
                {
                    if (cancelBake)
                    {
                        return;
                    }

                    if (probeBox == null)
                    {
                        Debug.LogError("Probe Box specified in list of Probe Boxes to bake is null.");
                        continue;
                    }

                    if (probeBox.probeBoxData == null || probeBox.probeBoxData.Length == 0)
                    {
                        Debug.LogError("Skipping probe box, because probes have not been generated for it.");
                        continue;
                    }

                    IntPtr probeBoxPtr = IntPtr.Zero;
                    try
                    {
                        PhononCore.iplLoadProbeBox(probeBox.probeBoxData, probeBox.probeBoxData.Length,
                                                   ref probeBoxPtr);
                        probeBoxBakingCurrently++;
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(e.Message);
                    }

                    if (duringBakeModes[i] == BakingMode.Reverb)
                    {
                        PhononCore.iplBakeReverb(duringBakePhononContainer.Environment().GetEnvironment(),
                                                 probeBoxPtr, bakeSettings, bakeCallback);
                    }
                    else if (duringBakeModes[i] == BakingMode.StaticListener)
                    {
                        PhononCore.iplBakeStaticListener(duringBakePhononContainer.Environment().GetEnvironment(),
                                                         probeBoxPtr, duringBakeSpheres[i], Common.ConvertString(bakingGameObjectName),
                                                         bakeSettings, bakeCallback);
                    }
                    else if (duringBakeModes[i] == BakingMode.StaticSource)
                    {
                        PhononCore.iplBakePropagation(duringBakePhononContainer.Environment().GetEnvironment(),
                                                      probeBoxPtr, duringBakeSpheres[i], Common.ConvertString(bakingGameObjectName),
                                                      bakeSettings, bakeCallback);
                    }

                    if (cancelBake)
                    {
                        PhononCore.iplDestroyProbeBox(ref probeBoxPtr);
                        Debug.Log("CANCELLED: Baking.");
                        return;
                    }

                    int probeBoxSize = PhononCore.iplSaveProbeBox(probeBoxPtr, null);
                    probeBox.probeBoxData = new byte[probeBoxSize];
                    PhononCore.iplSaveProbeBox(probeBoxPtr, probeBox.probeBoxData);

                    int probeBoxEffectSize = PhononCore.iplGetBakedDataSizeByName(probeBoxPtr,
                                                                                  Common.ConvertString(bakeDataString));
                    probeBox.UpdateProbeDataMapping(bakeDataString, probeBoxEffectSize);

                    PhononCore.iplDestroyProbeBox(ref probeBoxPtr);
                }

                if (duringBakeProbeBoxes[i].Length == 0)
                {
                    Debug.LogError("Probe Box component not attached or no probe boxes selected for "
                                   + bakingGameObjectName);
                }
                else
                {
                    Debug.Log("COMPLETED: Baking effect for " + bakingGameObjectName + ".");
                }
            }

            bakeStatus = BakeStatus.Complete;
        }