// Room
 public static void CreateRoom(Vive3DSPAudioRoom room)
 {
     room.RoomObject = vive_3dsp_room_create_object_plugin();
     vive_3dsp_room_enable_plugin(room.RoomObject, true);
     roomList.Add(room);
     CheckIfListenerInRoom(room);
 }
        public static void CheckIfListenerInRoom(Vive3DSPAudioRoom room)
        {
            if (IsObjectInsideRoom(MainListener.transform.position, room))
            {
                vive_3dsp_listener_set_current_room_plugin(room.RoomObject);
                MainListener.CurrentRoom = room;
                MainListener.RoomList.Add(room);
            }
            else // the listener is outside the room
            {
                MainListener.RoomList.Remove(room);
                if (MainListener.CurrentRoom == room)
                {
                    MainListener.CurrentRoom = null;
                }

                if (MainListener.RoomList.Count > 0)
                {
                    // Set another room
                    foreach (var anotherRoom in MainListener.RoomList)
                    {
                        vive_3dsp_listener_set_current_room_plugin(anotherRoom.RoomObject);
                        if (MainListener.CurrentRoom == null)
                        {
                            MainListener.CurrentRoom = anotherRoom;
                        }
                        break;
                    }
                }
            }
            if (MainListener.RoomList.Count == 0)
            {
                vive_3dsp_listener_leave_room_plugin();
            }
        }
 public static void UpdateRoomRotationCallback(Vive3DSPAudioRoom roomComponent)
 {
     if (roomComponent.RoomObject == IntPtr.Zero)
     {
         return;
     }
     vive_3dsp_room_set_rotation_plugin(roomComponent.RoomObject, roomComponent.transform.rotation);
     CheckIfListenerInRoom(roomComponent);
 }
        public static bool IsObjectInsideRoom(Vector3 object_pos, Vive3DSPAudioRoom room)
        {
            bool isInside = false;

            Vector3    relativePosition = object_pos - room.transform.position;
            Quaternion rotationInverse  = Quaternion.Inverse(room.transform.rotation);

            bounds.size = Vector3.Scale(room.transform.lossyScale, room.Size);
            isInside    = bounds.Contains(rotationInverse * relativePosition);

            return(isInside);
        }
        public static void DestroyRoom(Vive3DSPAudioRoom room)
        {
            vive_3dsp_room_destroy_object_plugin(room.RoomObject);

            foreach (var src in srcList)
            {
                src.RoomList.Remove(room);
            }

            MainListener.RoomList.Remove(room);
            roomList.Remove(room);
        }
        public static void UpdateRoom(Vive3DSPAudioRoom roomComponent)
        {
            if (roomComponent.RoomEffect)
            {
                vive_3dsp_room_enable_plugin(roomComponent.RoomObject, true);
            }
            else
            {
                vive_3dsp_room_enable_plugin(roomComponent.RoomObject, false);
            }

            vive_3dsp_room_set_size_plugin(roomComponent.RoomObject, roomComponent.transform.lossyScale);

            if (roomComponent.Ceiling == RoomPlateMaterial.UserDefine)
            {
                vive_3dsp_room_set_reflection_rate_plugin(roomComponent.RoomObject, RoomPlane.Ceiling, roomComponent.CeilingReflectionRate);
            }
            else
            {
                vive_3dsp_room_set_material_plugin(roomComponent.RoomObject, RoomPlane.Ceiling, roomComponent.Ceiling);
            }


            if (roomComponent.FrontWall == RoomPlateMaterial.UserDefine)
            {
                vive_3dsp_room_set_reflection_rate_plugin(roomComponent.RoomObject, RoomPlane.FrontWall, roomComponent.FrontWallReflectionRate);
            }
            else
            {
                vive_3dsp_room_set_material_plugin(roomComponent.RoomObject, RoomPlane.FrontWall, roomComponent.FrontWall);
            }

            if (roomComponent.BackWall == RoomPlateMaterial.UserDefine)
            {
                vive_3dsp_room_set_reflection_rate_plugin(roomComponent.RoomObject, RoomPlane.BackWall, roomComponent.BackWallReflectionRate);
            }
            else
            {
                vive_3dsp_room_set_material_plugin(roomComponent.RoomObject, RoomPlane.BackWall, roomComponent.BackWall);
            }

            if (roomComponent.RightWall == RoomPlateMaterial.UserDefine)
            {
                vive_3dsp_room_set_reflection_rate_plugin(roomComponent.RoomObject, RoomPlane.RightWall, roomComponent.RightWallReflectionRate);
            }
            else
            {
                vive_3dsp_room_set_material_plugin(roomComponent.RoomObject, RoomPlane.RightWall, roomComponent.RightWall);
            }

            if (roomComponent.LeftWall == RoomPlateMaterial.UserDefine)
            {
                vive_3dsp_room_set_reflection_rate_plugin(roomComponent.RoomObject, RoomPlane.LeftWall, roomComponent.LeftWallReflectionRate);
            }
            else
            {
                vive_3dsp_room_set_material_plugin(roomComponent.RoomObject, RoomPlane.LeftWall, roomComponent.LeftWall);
            }

            if (roomComponent.Floor == RoomPlateMaterial.UserDefine)
            {
                vive_3dsp_room_set_reflection_rate_plugin(roomComponent.RoomObject, RoomPlane.Floor, roomComponent.FloorReflectionRate);
            }
            else
            {
                vive_3dsp_room_set_material_plugin(roomComponent.RoomObject, RoomPlane.Floor, roomComponent.Floor);
            }

            vive_3dsp_room_set_reverb_preset_plugin(roomComponent.RoomObject, roomComponent.ReverbPreset);
            vive_3dsp_room_set_size_plugin(roomComponent.RoomObject, Vector3.Scale(roomComponent.transform.lossyScale, roomComponent.Size));
            vive_3dsp_room_setReflectionLevel_plugin(roomComponent.RoomObject, roomComponent.reflectionLevel);
            vive_3dsp_room_setReverbLevel_plugin(roomComponent.RoomObject, roomComponent.reverbLevel);
        }