コード例 #1
0
        public void DebugDrawEarlyReflections(UnityEngine.GameObject gameObject, bool firstOrder, bool secondOrder, bool higherOrder)
        {
            if (AkSoundEngine.QueryIndirectPaths(gameObject, pathsParams, indirectPathInfoArray, (uint)indirectPathInfoArray.Count()) != AKRESULT.AK_Success)
            {
                return;
            }

            for (var idxPath = (int)pathsParams.numValidPaths - 1; idxPath >= 0; --idxPath)
            {
                var path  = indirectPathInfoArray[idxPath];
                var order = path.numReflections;

                var colorLight = colorLightRed;
                var colorDark  = colorDarkRed;

                if (order == 1)
                {
                    if (!firstOrder)
                    {
                        continue;
                    }

                    colorLight = colorLightYellow;
                    colorDark  = colorDarkYellow;
                }
                else if (order == 2)
                {
                    if (!secondOrder)
                    {
                        continue;
                    }

                    colorLight = colorLightOrange;
                    colorDark  = colorDarkOrange;
                }
                else if (order > 2 && !higherOrder)
                {
                    continue;
                }

                var emitterPos = ConvertVector(pathsParams.emitterPos);
                var listenerPt = ConvertVector(pathsParams.listenerPos);

                for (var idxSeg = (int)path.numPathPoints - 1; idxSeg >= 0; --idxSeg)
                {
                    var pt = ConvertVector(path.GetPathPoint((uint)idxSeg));

                    UnityEngine.Debug.DrawLine(listenerPt, pt, path.isOccluded ? colorLightGrey : colorLight);

                    UnityEngine.Gizmos.color = path.isOccluded ? colorLightGrey : colorLight;
                    UnityEngine.Gizmos.DrawWireSphere(pt, radiusSphere / 2 / order);

                    if (!path.isOccluded)
                    {
                        var surface = path.GetAcousticSurface((uint)idxSeg);
                        DrawLabelInFrontOfCam(pt, surface.strName, 100000, colorDark);
                    }

                    float dfrnAmount = path.GetDiffraction((uint)idxSeg);
                    if (dfrnAmount > 0)
                    {
                        string dfrnAmountStr = dfrnAmount.ToString("0.#%");
                        DrawLabelInFrontOfCam(pt, dfrnAmountStr, 100000, colorDark);
                    }

                    listenerPt = pt;
                }

                if (!path.isOccluded)
                {
                    // Finally the last path segment towards the emitter.
                    UnityEngine.Debug.DrawLine(listenerPt, emitterPos, path.isOccluded ? colorLightGrey : colorLight);
                }
                else
                {
                    var occlusionPt = ConvertVector(path.occlusionPoint);
                    UnityEngine.Gizmos.color = colorDarkGrey;
                    UnityEngine.Gizmos.DrawWireSphere(occlusionPt, radiusSphere / order);
                }
            }
        }
コード例 #2
0
    private void DebugDrawEarlyReflections()
    {
        if (AkSoundEngine.QueryIndirectPaths(gameObject, pathsParams, indirectPathInfoArray,
                                             (uint)indirectPathInfoArray.Count()) == AKRESULT.AK_Success)
        {
            for (var idxPath = (int)pathsParams.numValidPaths - 1; idxPath >= 0; --idxPath)
            {
                var path  = indirectPathInfoArray[idxPath];
                var order = path.numReflections;

                if (drawFirstOrderReflections && order == 1 || drawSecondOrderReflections && order == 2 ||
                    drawHigherOrderReflections && order > 2)
                {
                    UnityEngine.Color32 colorLight;
                    UnityEngine.Color32 colorDark;

                    switch (order - 1)
                    {
                    case 0:
                        colorLight = colorLightBlue;
                        colorDark  = colorDarkBlue;
                        break;

                    case 1:
                        colorLight = colorLightYellow;
                        colorDark  = colorDarkYellow;
                        break;

                    case 2:
                    default:
                        colorLight = colorLightRed;
                        colorDark  = colorDarkRed;
                        break;
                    }

                    var emitterPos = ConvertVector(pathsParams.emitterPos);
                    var listenerPt = ConvertVector(pathsParams.listenerPos);

                    for (var idxSeg = (int)path.numPathPoints - 1; idxSeg >= 0; --idxSeg)
                    {
                        var pt = ConvertVector(path.GetPathPoint((uint)idxSeg));

                        UnityEngine.Debug.DrawLine(listenerPt, pt, path.isOccluded ? colorLightGrey : colorLight);

                        UnityEngine.Gizmos.color = path.isOccluded ? colorLightGrey : colorLight;
                        UnityEngine.Gizmos.DrawWireSphere(pt, radiusSphere / 2 / order);

                        if (!path.isOccluded)
                        {
                            var surface = path.GetAcousticSurface((uint)idxSeg);
                            DrawLabelInFrontOfCam(pt, surface.strName, 100000, colorDark);
                        }

                        float dfrnAmount = path.GetDiffraction((uint)idxSeg);
                        if (dfrnAmount > 0)
                        {
                            string dfrnAmountStr = dfrnAmount.ToString("0.#%");
                            DrawLabelInFrontOfCam(pt, dfrnAmountStr, 100000, colorDark);
                        }

                        listenerPt = pt;
                    }

                    if (!path.isOccluded)
                    {
                        // Finally the last path segment towards the emitter.
                        UnityEngine.Debug.DrawLine(listenerPt, emitterPos, path.isOccluded ? colorLightGrey : colorLight);
                    }
                    else
                    {
                        var occlusionPt = ConvertVector(path.occlusionPoint);
                        UnityEngine.Gizmos.color = colorDarkGrey;
                        UnityEngine.Gizmos.DrawWireSphere(occlusionPt, radiusSphere / order);
                    }
                }
            }
        }
    }
コード例 #3
0
    private void DebugDrawEarlyReflections()
    {
        if (AkSoundEngine.QueryIndirectPaths(gameObject, indirectPathsParams, indirectPathInfoArray,
                                             (uint)indirectPathInfoArray.Count()) == AKRESULT.AK_Success)
        {
            for (var idxPath = (int)indirectPathsParams.numValidPaths - 1; idxPath >= 0; --idxPath)
            {
                var path  = indirectPathInfoArray.GetSoundPathInfo(idxPath);
                var order = path.numReflections;

                if (drawFirstOrderReflections && order == 1 || drawSecondOrderReflections && order == 2 ||
                    drawHigherOrderReflections && order > 2)
                {
                    UnityEngine.Color32 colorLight;
                    UnityEngine.Color32 colorDark;

                    switch (order - 1)
                    {
                    case 0:
                        colorLight = colorLightBlue;
                        colorDark  = colorDarkBlue;
                        break;

                    case 1:
                        colorLight = colorLightYellow;
                        colorDark  = colorDarkYellow;
                        break;

                    case 2:
                    default:
                        colorLight = colorLightRed;
                        colorDark  = colorDarkRed;
                        break;
                    }

                    var emitterPos = ConvertVector(indirectPathsParams.emitterPos);
                    var listenerPt = ConvertVector(indirectPathsParams.listenerPos);

                    for (var idxSeg = (int)path.numReflections - 1; idxSeg >= 0; --idxSeg)
                    {
                        var reflectionPt = ConvertVector(path.GetReflectionPoint((uint)idxSeg));

                        UnityEngine.Debug.DrawLine(listenerPt, reflectionPt, path.isOccluded ? colorLightGrey : colorLight);

                        UnityEngine.Gizmos.color = path.isOccluded ? colorLightGrey : colorLight;
                        UnityEngine.Gizmos.DrawWireSphere(reflectionPt, radiusSphere / 2 / order);

                        if (!path.isOccluded)
                        {
                            var triangle = path.GetTriangle((uint)idxSeg);

                            var triPt0 = ConvertVector(triangle.point0);
                            var triPt1 = ConvertVector(triangle.point1);
                            var triPt2 = ConvertVector(triangle.point2);

                            UnityEngine.Debug.DrawLine(triPt0, triPt1, colorDark);
                            UnityEngine.Debug.DrawLine(triPt1, triPt2, colorDark);
                            UnityEngine.Debug.DrawLine(triPt2, triPt0, colorDark);

                            DrawLabelInFrontOfCam(reflectionPt, path.GetTriangle((uint)idxSeg).strName, 100000, colorDark);
                        }

                        listenerPt = reflectionPt;
                    }

                    if (!path.isOccluded)
                    {
                        // Finally the last path segment towards the emitter.
                        UnityEngine.Debug.DrawLine(listenerPt, emitterPos, path.isOccluded ? colorLightGrey : colorLight);
                    }
                    else
                    {
                        var occlusionPt = ConvertVector(path.occlusionPoint);
                        UnityEngine.Gizmos.color = colorDarkGrey;
                        UnityEngine.Gizmos.DrawWireSphere(occlusionPt, radiusSphere / order);
                    }
                }
            }
        }
    }