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