Example #1
0
 /// Sets the surface material to all sub-meshes. This is particularly useful for assigning surface
 /// materials to terrains, because we model a terrain as a uniform surface.
 public void SetSurfaceMaterialToAllSubMeshes(
     ResonanceAudioRoomManager.SurfaceMaterial surfaceMaterial)
 {
     for (int subMeshIndex = 0; subMeshIndex < surfaceMaterialsFromSubMesh.Length; ++subMeshIndex)
     {
         surfaceMaterialsFromSubMesh[subMeshIndex] = surfaceMaterial;
     }
     SetSubMeshSurfaceMaterials();
 }
    // Applies surface material to (the acoustic meshes) of terrains whose terrain data are
    // identified by |guid|.
    private void ApplySurfaceMaterialToTerrains(
        ResonanceAudioRoomManager.SurfaceMaterial surfaceMaterial, string guid)
    {
        TerrainAcousticMeshData acousticMeshesData = terrainAcousticMeshDataFromGuid[guid];
        var acousticMeshes = acousticMeshesData.acousticMeshes.ToList();

        for (int i = 0; i < acousticMeshes.Count; ++i)
        {
            acousticMeshes[i].SetSurfaceMaterialToAllSubMeshes(surfaceMaterial);
        }
    }
Example #3
0
    /// Sets the surface material to a sub-mesh. This is useful for assigning surface materials to
    /// game objects with a mesh filter. Because in a mesh filter, a sub-mesh contains triangles
    /// sharing a common Unity Material, which will eventually be assigned to the same surface
    /// material.
    public void SetSurfaceMaterialToSubMesh(ResonanceAudioRoomManager.SurfaceMaterial surfaceMaterial,
                                            int subMeshIndex)
    {
        if (subMeshIndex < 0 || subMeshIndex >= triangleRangesFromSubMesh.Length)
        {
            Debug.LogError("subMeshIndex= " + subMeshIndex + " out of range [0, " +
                           triangleRangesFromSubMesh.Length + "]");
            return;
        }

        surfaceMaterialsFromSubMesh[subMeshIndex] = surfaceMaterial;
        SetSubMeshSurfaceMaterials();
    }
Example #4
0
 // Fills the wall materials part of the room properties.
 private static void FillWallMaterialsOfRoomProperties(
     ResonanceAudioRoomManager.SurfaceMaterial leftWall,
     ResonanceAudioRoomManager.SurfaceMaterial rightWall,
     ResonanceAudioRoomManager.SurfaceMaterial floor,
     ResonanceAudioRoomManager.SurfaceMaterial ceiling,
     ResonanceAudioRoomManager.SurfaceMaterial frontWall,
     ResonanceAudioRoomManager.SurfaceMaterial backWall)
 {
     roomProperties.materialLeft   = leftWall;
     roomProperties.materialRight  = rightWall;
     roomProperties.materialBottom = floor;
     roomProperties.materialTop    = ceiling;
     roomProperties.materialFront  = frontWall;
     roomProperties.materialBack   = backWall;
 }
 // Applies the material mapping (stored in |surfaceMaterialFromGuid|) to |guids| and pass the
 // information to the acoustic meshes, of game objects sharing the Unity Material identified
 // by GUID, or of terrain objects using the terrain data identified by GUID.
 private void ApplyMaterialMappingToGuids(List <string> guids)
 {
     for (int i = 0; i < guids.Count; ++i)
     {
         var guid = guids[i];
         ResonanceAudioRoomManager.SurfaceMaterial surfaceMaterial = surfaceMaterialFromGuid[guid];
         if (unityMaterialAcousticMeshDataFromGuid.ContainsKey(guid))
         {
             ApplySurfaceMaterialToGameObjects(surfaceMaterial, guid);
         }
         else if (terrainAcousticMeshDataFromGuid.ContainsKey(guid))
         {
             ApplySurfaceMaterialToTerrains(surfaceMaterial, guid);
         }
     }
 }
Example #6
0
 /// Set proxy room properties. Proxy rooms are estimated by the ray-tracing engine and passed
 /// back to be used in real-time early reflections.
 public void SetProxyRoomProperties(ResonanceAudio.RoomProperties proxyRoomProperties)
 {
     proxyRoomPosition = new Vector3(proxyRoomProperties.positionX,
                                     proxyRoomProperties.positionY,
                                     proxyRoomProperties.positionZ);
     proxyRoomRotation = new Quaternion(proxyRoomProperties.rotationX,
                                        proxyRoomProperties.rotationY,
                                        proxyRoomProperties.rotationZ,
                                        proxyRoomProperties.rotationW);
     proxyRoomSize = new Vector3(proxyRoomProperties.dimensionsX,
                                 proxyRoomProperties.dimensionsY,
                                 proxyRoomProperties.dimensionsZ);
     proxyRoomLeftWall  = proxyRoomProperties.materialLeft;
     proxyRoomRightWall = proxyRoomProperties.materialRight;
     proxyRoomFloor     = proxyRoomProperties.materialBottom;
     proxyRoomCeiling   = proxyRoomProperties.materialTop;
     proxyRoomBackWall  = proxyRoomProperties.materialBack;
     proxyRoomFrontWall = proxyRoomProperties.materialFront;
 }
    // Applies surface material to (the acoustic meshes) of the game objects whose Unity Materials
    // are identified by |guid|.
    private void ApplySurfaceMaterialToGameObjects(
        ResonanceAudioRoomManager.SurfaceMaterial surfaceMaterial, string guid)
    {
        UnityMaterialAcousticMeshData acosuticMeshesData = unityMaterialAcousticMeshDataFromGuid[guid];

        if (acosuticMeshesData.acousticMeshes.Count != acosuticMeshesData.subMeshIndices.Count)
        {
            Debug.LogError("Number of acoustic meshes (" + acosuticMeshesData.acousticMeshes.Count +
                           ") != number of sub-mesh indices (" +
                           acosuticMeshesData.subMeshIndices.Count + ")");
        }

        var acousticMeshes = acosuticMeshesData.acousticMeshes;
        var subMeshIndices = acosuticMeshesData.subMeshIndices;

        for (int i = 0; i < acousticMeshes.Count; ++i)
        {
            acousticMeshes[i].SetSurfaceMaterialToSubMesh(surfaceMaterial, subMeshIndices[i]);
        }
    }