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_MESH_TEXTURE_H 17 #define SCENE_SRC_MESH_TEXTURE_H 18 19 #include <scene/ext/component.h> 20 #include <scene/ext/ecs_lazy_property.h> 21 #include <scene/ext/intf_create_entity.h> 22 #include <scene/interface/intf_texture.h> 23 24 #include <meta/ext/implementation_macros.h> 25 #include <meta/ext/object.h> 26 27 #include "util_interfaces.h" 28 29 SCENE_BEGIN_NAMESPACE() 30 31 META_REGISTER_CLASS(Texture, "07e6dc19-57ca-4a3a-aa71-a53db9bf2e58", META_NS::ObjectCategoryBits::NO_CATEGORY) 32 33 class Texture : public META_NS::IntroduceInterfaces<EcsLazyProperty, ArrayElementIndex, META_NS::INamed, ITexture> { 34 META_OBJECT(Texture, ClassId::Texture, IntroduceInterfaces) 35 36 public: 37 META_BEGIN_STATIC_DATA() 38 META_STATIC_PROPERTY_DATA(META_NS::INamed, BASE_NS::string, Name) 39 SCENE_STATIC_DYNINIT_PROPERTY_DATA(ITexture, ISampler::Ptr, Sampler, "sampler") 40 SCENE_STATIC_DYNINIT_PROPERTY_DATA(ITexture, IImage::Ptr, Image, "image") 41 SCENE_STATIC_DYNINIT_PROPERTY_DATA(ITexture, BASE_NS::Math::Vec4, Factor, "factor") 42 SCENE_STATIC_DYNINIT_PROPERTY_DATA(ITexture, BASE_NS::Math::Vec2, Translation, "transform.translation") 43 SCENE_STATIC_DYNINIT_PROPERTY_DATA(ITexture, float, Rotation, "transform.rotation") 44 SCENE_STATIC_DYNINIT_PROPERTY_DATA(ITexture, BASE_NS::Math::Vec2, Scale, "transform.scale") 45 META_END_STATIC_DATA() 46 47 META_IMPLEMENT_PROPERTY(BASE_NS::string, Name) 48 META_IMPLEMENT_READONLY_PROPERTY(ISampler::Ptr, Sampler) 49 META_IMPLEMENT_PROPERTY(IImage::Ptr, Image) 50 META_IMPLEMENT_PROPERTY(BASE_NS::Math::Vec4, Factor) 51 META_IMPLEMENT_PROPERTY(BASE_NS::Math::Vec2, Translation) 52 META_IMPLEMENT_PROPERTY(float, Rotation) 53 META_IMPLEMENT_PROPERTY(BASE_NS::Math::Vec2, Scale) 54 55 bool InitDynamicProperty(const META_NS::IProperty::Ptr& p, BASE_NS::string_view path) override; 56 GetName()57 BASE_NS::string GetName() const override 58 { 59 return META_NS::GetValue(Name()); 60 } 61 }; 62 63 SCENE_END_NAMESPACE() 64 65 #endif 66