Skip to content

File Room.h

File List > Amplitude > Core > Room.h

Go to the documentation of this file

// Copyright (c) 2021-present Sparky Studios. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#ifndef _AM_CORE_ROOM_H
#define _AM_CORE_ROOM_H

#include <SparkyStudios/Audio/Amplitude/Core/Common.h>
#include <SparkyStudios/Audio/Amplitude/Core/Entity.h>
#include <SparkyStudios/Audio/Amplitude/Math/Shape.h>

namespace SparkyStudios::Audio::Amplitude
{
    class RoomInternalState;

    enum eRoomWallMaterialType : AmUInt8
    {
        eRoomWallMaterialType_Transparent = 0,
        eRoomWallMaterialType_AcousticTile,
        eRoomWallMaterialType_CarpetOnConcrete,
        eRoomWallMaterialType_HeavyDrapes,
        eRoomWallMaterialType_GypsumBoard,
        eRoomWallMaterialType_ConcreteUnpainted,
        eRoomWallMaterialType_Wood,
        eRoomWallMaterialType_BrickPainted,
        eRoomWallMaterialType_FoamPanel,
        eRoomWallMaterialType_Glass,
        eRoomWallMaterialType_PlasterSmooth,
        eRoomWallMaterialType_Metal,
        eRoomWallMaterialType_Marble,
        eRoomWallMaterialType_WaterSurface,
        eRoomWallMaterialType_IceSurface,
        eRoomWallMaterialType_Custom
    };

    enum eRoomWall : AmUInt8
    {
        eRoomWall_Left = 0,

        eRoomWall_Right,

        eRoomWall_Floor,
        eRoomWall_Bottom = eRoomWall_Floor,

        eRoomWall_Ceiling,
        eRoomWall_Top = eRoomWall_Ceiling,

        eRoomWall_Front,

        eRoomWall_Back,

        eRoomWall_Invalid
    };

    struct AM_API_PUBLIC RoomWallMaterial
    {
        RoomWallMaterial();

        explicit RoomWallMaterial(eRoomWallMaterialType type);

        eRoomWallMaterialType m_type;

        AmReal32 m_absorptionCoefficients[9];

        bool operator==(const RoomWallMaterial& other) const;

        bool operator!=(const RoomWallMaterial& other) const;
    };

    class AM_API_PUBLIC Room
    {
    public:
        Room();

        explicit Room(RoomInternalState* state);

        void Clear();

        [[nodiscard]] bool Valid() const;

        [[nodiscard]] AmRoomID GetId() const;

        void SetLocation(const AmVector3& location) const;

        [[nodiscard]] const AmVector3& GetLocation() const;

        void SetOrientation(const Orientation& orientation) const;

        [[nodiscard]] const Orientation& GetOrientation() const;

        [[nodiscard]] AmVector3 GetDirection() const;

        [[nodiscard]] AmVector3 GetUp() const;

        void SetDimensions(AmVector3 dimensions) const;

        void SetShape(const BoxShape& shape) const;

        [[nodiscard]] const BoxShape& GetShape() const;

        void SetWallMaterial(eRoomWall wall, const RoomWallMaterial& material) const;

        void SetAllWallMaterials(const RoomWallMaterial& material) const;

        void SetWallMaterials(
            const RoomWallMaterial& leftWallMaterial,
            const RoomWallMaterial& rightWallMaterial,
            const RoomWallMaterial& floorMaterial,
            const RoomWallMaterial& ceilingMaterial,
            const RoomWallMaterial& frontWallMaterial,
            const RoomWallMaterial& backWallMaterial) const;

        [[nodiscard]] const RoomWallMaterial& GetWallMaterial(eRoomWall wall) const;

        void SetGain(AmReal32 gain) const;

        [[nodiscard]] AmReal32 GetGain() const;

        [[nodiscard]] AmReal32 GetVolume() const;

        [[nodiscard]] AmVector3 GetDimensions() const;

        [[nodiscard]] AmReal32 GetSurfaceArea(eRoomWall wall) const;

        void Update() const;

        [[nodiscard]] RoomInternalState* GetState() const;

    private:
        RoomInternalState* _state;
    };
} // namespace SparkyStudios::Audio::Amplitude

#endif // _AM_CORE_ROOM_H