1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef SCENE_SRC_COMPONENT_ENVIRONMENT_COMPONENT_H 17 #define SCENE_SRC_COMPONENT_ENVIRONMENT_COMPONENT_H 18 19 #include <scene/ext/component.h> 20 #include <scene/interface/intf_environment.h> 21 22 #include <meta/ext/object.h> 23 24 SCENE_BEGIN_NAMESPACE() 25 26 META_REGISTER_CLASS( 27 EnvironmentComponent, "0dc6c2ca-ed0e-4ee5-bdde-91eeb7a67b91", META_NS::ObjectCategoryBits::NO_CATEGORY) 28 29 class EnvironmentComponent : public META_NS::IntroduceInterfaces<Component, IEnvironment> { 30 META_OBJECT(EnvironmentComponent, ClassId::EnvironmentComponent, IntroduceInterfaces) 31 32 public: 33 META_BEGIN_STATIC_DATA() 34 SCENE_STATIC_PROPERTY_DATA(IEnvironment, EnvBackgroundType, Background, "EnvironmentComponent.background") 35 SCENE_STATIC_PROPERTY_DATA( 36 IEnvironment, BASE_NS::Math::Vec4, IndirectDiffuseFactor, "EnvironmentComponent.indirectDiffuseFactor") 37 SCENE_STATIC_PROPERTY_DATA( 38 IEnvironment, BASE_NS::Math::Vec4, IndirectSpecularFactor, "EnvironmentComponent.indirectSpecularFactor") 39 SCENE_STATIC_PROPERTY_DATA(IEnvironment, BASE_NS::Math::Vec4, EnvMapFactor, "EnvironmentComponent.envMapFactor") 40 SCENE_STATIC_PROPERTY_DATA( 41 IEnvironment, uint32_t, RadianceCubemapMipCount, "EnvironmentComponent.radianceCubemapMipCount") 42 SCENE_STATIC_PROPERTY_DATA(IEnvironment, float, EnvironmentMapLodLevel, "EnvironmentComponent.envMapLodLevel") 43 SCENE_STATIC_PROPERTY_DATA( 44 IEnvironment, BASE_NS::Math::Quat, EnvironmentRotation, "EnvironmentComponent.environmentRotation") 45 SCENE_STATIC_ARRAY_PROPERTY_DATA( 46 IEnvironment, BASE_NS::Math::Vec3, IrradianceCoefficients, "EnvironmentComponent.irradianceCoefficients") 47 SCENE_STATIC_DYNINIT_PROPERTY_DATA(IEnvironment, IImage::Ptr, RadianceImage, "EnvironmentComponent.radianceCubemap") 48 SCENE_STATIC_DYNINIT_PROPERTY_DATA(IEnvironment, IImage::Ptr, EnvironmentImage, "EnvironmentComponent.envMap") 49 META_END_STATIC_DATA() 50 51 META_IMPLEMENT_PROPERTY(EnvBackgroundType, Background) 52 META_IMPLEMENT_PROPERTY(BASE_NS::Math::Vec4, IndirectDiffuseFactor) 53 META_IMPLEMENT_PROPERTY(BASE_NS::Math::Vec4, IndirectSpecularFactor) 54 META_IMPLEMENT_PROPERTY(BASE_NS::Math::Vec4, EnvMapFactor) 55 META_IMPLEMENT_PROPERTY(uint32_t, RadianceCubemapMipCount) 56 META_IMPLEMENT_PROPERTY(float, EnvironmentMapLodLevel) 57 META_IMPLEMENT_PROPERTY(BASE_NS::Math::Quat, EnvironmentRotation) 58 META_IMPLEMENT_ARRAY_PROPERTY(BASE_NS::Math::Vec3, IrradianceCoefficients) 59 META_IMPLEMENT_PROPERTY(IImage::Ptr, RadianceImage) 60 META_IMPLEMENT_PROPERTY(IImage::Ptr, EnvironmentImage) 61 62 bool InitDynamicProperty(const META_NS::IProperty::Ptr& p, BASE_NS::string_view path) override; 63 64 public: 65 BASE_NS::string GetName() const override; 66 }; 67 68 SCENE_END_NAMESPACE() 69 70 #endif 71