// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. #pragma once #include "Engine/Content/Assets/Texture.h" #include "Engine/Content/AssetReference.h" #include "Engine/Renderer/Lightmaps.h" class SceneLightmapsData; /// /// Shadows Of Mordor static light map /// class Lightmap { private: SceneLightmapsData* _manager; int32 _index; #if USE_EDITOR int32 _size; #endif AssetReference _textures[3]; public: /// /// Initializes a new instance of the class. /// /// The manager. /// The index. /// The information. Lightmap(SceneLightmapsData* manager, int32 index, const SavedLightmapInfo& info); public: /// /// Gets attached texture objects /// /// Lightmap 0 texture /// Lightmap 1 texture /// Lightmap 2 texture void GetTextures(GPUTexture** lightmap0, GPUTexture** lightmap1, GPUTexture** lightmap2) const { *lightmap0 = _textures[0] ? _textures[0]->GetTexture() : nullptr; *lightmap1 = _textures[1] ? _textures[1]->GetTexture() : nullptr; *lightmap2 = _textures[2] ? _textures[2]->GetTexture() : nullptr; } /// /// Gets attached texture objects /// /// Lightmaps textures array void GetTextures(GPUTexture* lightmaps[3]) const { lightmaps[0] = _textures[0] ? _textures[0]->GetTexture() : nullptr; lightmaps[1] = _textures[1] ? _textures[1]->GetTexture() : nullptr; lightmaps[2] = _textures[2] ? _textures[2]->GetTexture() : nullptr; } /// /// Gets attached texture objects /// /// Lightmaps textures array void GetTextures(Texture* lightmaps[3]) const { lightmaps[0] = _textures[0].Get(); lightmaps[1] = _textures[1].Get(); lightmaps[2] = _textures[2].Get(); } /// /// Gets lightmap info /// /// Lightmap info void GetInfo(SavedLightmapInfo& info) const { info.Lightmap0 = _textures[0].GetID(); info.Lightmap1 = _textures[1].GetID(); info.Lightmap2 = _textures[2].GetID(); } /// /// Update texture (change it to another asset) /// /// New lightmap texture asset /// Texture index void UpdateTexture(Texture* texture, int32 index); /// /// Ensure that all textures have that size, if not resizing is performed /// /// Target size per texture void EnsureSize(int32 size); /// /// Determines whether this lightmap is ready (textures can be used by the renderer). /// bool IsReady() const; private: #if USE_EDITOR bool OnInitLightmap(class TextureData& image); #endif };