• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_MODEL_MODEL_VIEW_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_MODEL_MODEL_VIEW_H
18 
19 #include <mutex>
20 
21 #include "base/geometry/animatable_float.h"
22 #include "base/geometry/quaternion.h"
23 #include "base/geometry/vec3.h"
24 #include "base/memory/referenced.h"
25 #include "base/utils/utils.h"
26 #include "foundation/graphic/graphic_3d/3d_widget_adapter/include/custom/custom_render_descriptor.h"
27 #include "foundation/graphic/graphic_3d/3d_widget_adapter/include/data_type/constants.h"
28 #include "foundation/graphic/graphic_3d/3d_widget_adapter/include/data_type/geometry/geometry.h"
29 #include "foundation/graphic/graphic_3d/3d_widget_adapter/include/data_type/gltf_animation.h"
30 #include "foundation/graphic/graphic_3d/3d_widget_adapter/include/data_type/light.h"
31 #include "foundation/graphic/graphic_3d/3d_widget_adapter/include/data_type/position.h"
32 #include "foundation/graphic/graphic_3d/3d_widget_adapter/include/data_type/shader_input_buffer.h"
33 
34 namespace OHOS::Ace {
35 
36 class ModelView {
37 public:
38     static ModelView* GetInstance();
39     virtual ~ModelView() = default;
40     virtual void Create(const std::string& src) = 0;
41     virtual void SetBackground(const std::string& src) = 0;
42     virtual void SetHandleCameraMove(bool value) = 0;
43     virtual void SetTransparent(bool value) = 0;
44     virtual void SetCameraPosition(AnimatableFloat x, AnimatableFloat y, AnimatableFloat z,
45         AnimatableFloat distance, bool isAngular) = 0;
46     virtual void SetCameraRotation(Quaternion quat) = 0;
47     virtual void SetCameraFrustum(float zNear, float zFar, float fovDegrees) = 0;
48     virtual void SetCameraLookAt(Vec3 lookAtVec) = 0;
49     virtual void SetCameraUp(Vec3 upVec) = 0;
50     virtual void AddLight(const RefPtr<OHOS::Render3D::SVLight>& light) = 0;
51     virtual void AddGeometry(const RefPtr<OHOS::Render3D::SVGeometry>& shape) = 0;
52     virtual void AddGLTFAnimation(const RefPtr<OHOS::Render3D::GLTFAnimation>& animation) = 0;
53     virtual void AddCustomRender(const RefPtr<OHOS::Render3D::SVCustomRenderDescriptor>& customRender) = 0;
54     virtual void SetWidth(Dimension& width) = 0;
55     virtual void SetHeight(Dimension& height) = 0;
56     virtual void SetShader(const std::string& path) = 0;
57     virtual void AddShaderImageTexture(const std::string& path) = 0;
58     virtual void AddShaderInputBuffer(const RefPtr<OHOS::Render3D::ShaderInputBuffer>& buffer) = 0;
59 
60 private:
61     static std::unique_ptr<ModelView> instance_;
62     static std::mutex mutex_;
63 };
64 
65 } // namespace OHOS::Ace
66 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_MODEL_MODEL_VIEW_H
67