예제 #1
0
 public static extern DirectSoundPath iplGetDirectSoundPath(IntPtr environment,
                                                            Vector3 listenerPosition,
                                                            Vector3 listenerAhead,
                                                            Vector3 listenerUp,
                                                            Source source,
                                                            float sourceRadius,
                                                            OcclusionMode occlusionMode,
                                                            OcclusionMethod occlusionMethod);
예제 #2
0
        public void AudioFrameUpdate(float[] data, int channels, bool physicsBasedAttenuation, float directMixFraction,
                                     bool directBinauralEnabled, bool applyAirAbsorption, HRTFInterpolation hrtfInterpolation,
                                     OcclusionMode directOcclusionMode, OcclusionMethod directOcclusionMethod)
        {
            DirectSoundEffectOptions directSoundEffectOptions;

            directSoundEffectOptions.applyDistanceAttenuation = physicsBasedAttenuation ? Bool.True : Bool.False;
            directSoundEffectOptions.applyAirAbsorption       = applyAirAbsorption ? Bool.True : Bool.False;
            directSoundEffectOptions.occlusionMode            = directOcclusionMode;

            AudioBuffer inputBuffer;

            inputBuffer.audioFormat         = inputFormat;
            inputBuffer.numSamples          = data.Length / channels;
            inputBuffer.deInterleavedBuffer = null;
            inputBuffer.interleavedBuffer   = data;

            AudioBuffer outputBuffer;

            outputBuffer.audioFormat         = outputFormat;
            outputBuffer.numSamples          = data.Length / channels;
            outputBuffer.deInterleavedBuffer = null;
            outputBuffer.interleavedBuffer   = data;

            for (int i = 0; i < data.Length; i++)
            {
                data[i] *= directMixFraction;
            }

            PhononCore.iplApplyDirectSoundEffect(directSoundEffect, inputBuffer, directSoundPath,
                                                 directSoundEffectOptions, outputBuffer);

            Vector3 directDirection = directSoundPath.direction;

            if ((outputFormat.channelLayout == ChannelLayout.Stereo) && directBinauralEnabled)
            {
                // Apply binaural audio to direct sound.
                PhononCore.iplApplyBinauralEffect(directBinauralEffect, outputBuffer, directDirection,
                                                  hrtfInterpolation, outputBuffer);
            }
            else if (outputFormat.channelLayout == ChannelLayout.Custom)
            {
                // Apply panning fo custom speaker layout.
                PhononCore.iplApplyPanningEffect(directCustomPanningEffect, outputBuffer, directDirection,
                                                 outputBuffer);
            }
        }
예제 #3
0
 public static extern DirectSoundPath iplGetDirectSoundPath(IntPtr renderer, Vector3 listenerPosition, Vector3 listenerAhead, Vector3 listenerUp, Vector3 sourcePosition, float sourceRadius, OcclusionMode occlusionMode, OcclusionMethod occlusionMethod);
예제 #4
0
 public void FrameUpdate(IntPtr envRenderer, Vector3 sourcePosition, Vector3 listenerPosition,
                         Vector3 listenerAhead, Vector3 listenerUp, float partialOcclusionRadius, OcclusionMode directOcclusionMode,
                         OcclusionMethod directOcclusionMethod)
 {
     directSoundPath = PhononCore.iplGetDirectSoundPath(envRenderer, listenerPosition, listenerAhead, listenerUp,
                                                        sourcePosition, partialOcclusionRadius, directOcclusionMode, directOcclusionMethod);
 }
예제 #5
0
        internal void InitSelection()
        {
            if (unityTerrain != null)
            {
                Object.DestroyImmediate(unityTerrain);
                unityTerrain = null;
                if (defaultChild != null)
                {
                    Selection.activeTransform = defaultChild.transform;
                    vertexInfo = trisInfo = partsOfTerrain = 0;
                    if (nbrTerrainObject == 0)
                    {
                        TerrainObject t = defaultChild.gameObject.GetComponent <TerrainObject>();
                        t.enabledLODSystem = activateLOD;
                        t.enabledBillboard = activateBillboard;
                        t.enabledLayerCul  = activateLayerCul;
                        t.closeView        = closeView;
                        t.normalView       = normalView;
                        t.farView          = farView;
                        t.backgroundView   = backgroundView;
                        t.master           = 1;
                    }
                }
            }

            if (currentSelect != null &&
                currentSelect.GetComponent <TerrainObject>() != null &&
                currentSelect.GetComponent <TerrainObject>().material != null)
            {
                currentSelect.gameObject.layer = LayerType.TERRAIN;
                initMaster = false;
                TerrainObject to = currentSelect.GetComponent <TerrainObject>();
                for (int i = 0, len = layers.Length; i < len; i++)
                {
                    if (to.material.HasProperty(layers[i].name))
                    {
                        layers[i].texture = to.material.GetTexture(layers[i].name);
                        layers[i].tile    = to.material.GetTextureScale(layers[i].name);
                    }
                    else
                    {
                        layers[i].texture = null;
                    }
                    layers[i].bumpTexture = to.material.HasProperty(layers[i].bumpName)
                        ? to.material.GetTexture(layers[i].bumpName)
                        : null;
                    if (to.material.HasProperty("_ShininessL" + i))
                    {
                        layers[i].shiness = to.material.GetFloat("_ShininessL" + i);
                    }
                }
                if (to.material.HasProperty("_SpecColor"))
                {
                    shinessColor = to.material.GetColor("_SpecColor");
                }

                TerrainObject curr = currentSelect.gameObject.GetComponent <TerrainObject>();

                CheckShader();

                activateLOD       = curr.enabledLODSystem;
                activateBillboard = curr.enabledBillboard;
                activateLayerCul  = curr.enabledLayerCul;

                maxViewDist    = curr.maxViewDistance;
                lod2Start      = curr.lod2Start;
                lod3Start      = curr.lod3Start;
                updateInterval = curr.interval;
                playerCamera   = curr.playerCamera;
                billInterval   = curr.billboardInterval;
                billDist       = curr.billmaxViewDistance;
                backgroundView = curr.backgroundView;
                farView        = curr.farView;
                normalView     = curr.normalView;
                closeView      = curr.closeView;

                lodController = curr.mode == 1 ? LodMode.Mass_Control : LodMode.Independent_Control;

                billboardAxis = curr.axis == 0 ? BillBoardAxis.Y_Axis : BillBoardAxis.All_Axis;
                lodOcclusion  = curr.lodBasedOnScript
                    ? OcclusionMode.Max_View_Disance
                    : OcclusionMode.Layer_Cull_Distance;

                billboardOcclusion = curr.billboardBaseOnScript
                    ? OcclusionMode.Max_View_Disance
                    : OcclusionMode.Layer_Cull_Distance;

                billActivate = curr.billboardPosition != null && curr.billboardPosition.Length > 0;
                lodActivate  = curr.objPostion != null && curr.objPostion.Length > 0;

                if (playerCamera == null && Camera.main)
                {
                    playerCamera = Camera.main.transform;
                }
                else if (playerCamera == null && !Camera.main)
                {
                    Camera[] cam = Object.FindObjectsOfType <Camera>();

                    foreach (Camera t in cam)
                    {
                        if (t.GetComponent <AudioListener>())
                        {
                            playerCamera = t.transform;
                        }
                    }
                }


                if (curr.material.HasProperty("_Control2") && curr.material.GetTexture("_Control2"))
                {
                    maskTexture2 = curr.material.GetTexture("_Control2") as Texture2D;
                }
                else
                {
                    maskTexture2 = null;
                }
                if (curr.material.HasProperty("_Control"))
                {
                    maskTextureUV = curr.material.GetTextureScale("_Control").x;
                    maskTexture   = curr.material.GetTexture("_Control") as Texture2D;
                    initialized   = true;
                }
            }
            Projector[] projectorObj = Object.FindObjectsOfType <Projector>();
            if (projectorObj.Length > 0)
            {
                foreach (var p in projectorObj)
                {
                    if (p.gameObject.name == TerrainCenter.PREVIEWER_NAME)
                    {
                        Object.DestroyImmediate(p.gameObject);
                    }
                }
            }
            terrainDat      = null;
            vertexInfo      = 0;
            trisInfo        = 0;
            partsOfTerrain  = 0;
            textures        = null;
            terrainSelectId = Selection.activeInstanceID;
        }