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_LIGHT_COMPONENT_H 17 #define SCENE_SRC_COMPONENT_LIGHT_COMPONENT_H 18 19 #include <scene/ext/component.h> 20 #include <scene/interface/intf_light.h> 21 22 #include <meta/ext/object.h> 23 24 SCENE_BEGIN_NAMESPACE() 25 26 META_REGISTER_CLASS(LightComponent, "1e25f1c9-723d-4a5a-9cc1-770b0eade707", META_NS::ObjectCategoryBits::NO_CATEGORY) 27 28 class LightComponent : public META_NS::IntroduceInterfaces<Component, ILight> { 29 META_OBJECT(LightComponent, ClassId::LightComponent, IntroduceInterfaces) 30 31 public: 32 META_BEGIN_STATIC_DATA() 33 SCENE_STATIC_DYNINIT_PROPERTY_DATA(ILight, BASE_NS::Color, Color, "LightComponent.color") 34 SCENE_STATIC_PROPERTY_DATA(ILight, float, Intensity, "LightComponent.intensity") 35 SCENE_STATIC_PROPERTY_DATA(ILight, float, NearPlane, "LightComponent.nearPlane") 36 SCENE_STATIC_PROPERTY_DATA(ILight, bool, ShadowEnabled, "LightComponent.shadowEnabled") 37 SCENE_STATIC_PROPERTY_DATA(ILight, float, ShadowStrength, "LightComponent.shadowStrength") 38 SCENE_STATIC_PROPERTY_DATA(ILight, float, ShadowDepthBias, "LightComponent.shadowDepthBias") 39 SCENE_STATIC_PROPERTY_DATA(ILight, float, ShadowNormalBias, "LightComponent.shadowNormalBias") 40 SCENE_STATIC_PROPERTY_DATA(ILight, float, SpotInnerAngle, "LightComponent.spotInnerAngle") 41 SCENE_STATIC_PROPERTY_DATA(ILight, float, SpotOuterAngle, "LightComponent.spotOuterAngle") 42 SCENE_STATIC_PROPERTY_DATA(ILight, LightType, Type, "LightComponent.type") 43 SCENE_STATIC_PROPERTY_DATA(ILight, BASE_NS::Math::Vec4, AdditionalFactor, "LightComponent.additionalFactor") 44 SCENE_STATIC_PROPERTY_DATA(ILight, uint64_t, LightLayerMask, "LightComponent.lightLayerMask") 45 SCENE_STATIC_PROPERTY_DATA(ILight, uint64_t, ShadowLayerMask, "LightComponent.shadowLayerMask") 46 META_END_STATIC_DATA() 47 48 META_IMPLEMENT_PROPERTY(BASE_NS::Color, Color) 49 META_IMPLEMENT_PROPERTY(float, Intensity) 50 META_IMPLEMENT_PROPERTY(float, NearPlane) 51 META_IMPLEMENT_PROPERTY(bool, ShadowEnabled) 52 META_IMPLEMENT_PROPERTY(float, ShadowStrength) 53 META_IMPLEMENT_PROPERTY(float, ShadowDepthBias) 54 META_IMPLEMENT_PROPERTY(float, ShadowNormalBias) 55 META_IMPLEMENT_PROPERTY(float, SpotInnerAngle) 56 META_IMPLEMENT_PROPERTY(float, SpotOuterAngle) 57 META_IMPLEMENT_PROPERTY(LightType, Type) 58 META_IMPLEMENT_PROPERTY(BASE_NS::Math::Vec4, AdditionalFactor) 59 META_IMPLEMENT_PROPERTY(uint64_t, LightLayerMask) 60 META_IMPLEMENT_PROPERTY(uint64_t, ShadowLayerMask) 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