1 /* 2 * Copyright (C) 2023 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 OHOS_RENDER_3D_LIGHT_H 17 #define OHOS_RENDER_3D_LIGHT_H 18 19 #include "data_type/constants.h" 20 #include "data_type/position.h" 21 #include "data_type/quaternion.h" 22 #include "data_type/vec3.h" 23 24 namespace OHOS::Render3D { 25 class Light { 26 public: Light(LightType type,const Vec3 & color,float intensity,bool shadow,const Position & position,const Quaternion & rotation)27 Light(LightType type, const Vec3& color, float intensity, bool shadow, const Position& position, 28 const Quaternion& rotation) 29 : type_(type), color_(color), intensity_(intensity), shadow_(shadow), position_(position), rotation_(rotation) 30 { 31 } 32 SetLightType(LightType type)33 void SetLightType(LightType type) 34 { 35 type_ = type; 36 } 37 SetColor(const OHOS::Render3D::Vec3 & color)38 void SetColor(const OHOS::Render3D::Vec3& color) 39 { 40 color_ = color; 41 } 42 SetIntensity(float intensity)43 void SetIntensity(float intensity) 44 { 45 intensity_ = intensity; 46 } 47 SetLightShadow(bool shadow)48 void SetLightShadow(bool shadow) 49 { 50 shadow_ = shadow; 51 } 52 SetPosition(const OHOS::Render3D::Position & position)53 void SetPosition(const OHOS::Render3D::Position& position) 54 { 55 position_.SetPosition(position.GetPosition()); 56 position_.SetDistance(position.GetDistance()); 57 position_.SetIsAngular(position.GetIsAngular()); 58 } 59 SetRotation(const OHOS::Render3D::Quaternion & rotation)60 void SetRotation(const OHOS::Render3D::Quaternion& rotation) 61 { 62 rotation_ = rotation; 63 } 64 GetLightType()65 LightType GetLightType() const 66 { 67 return type_; 68 } 69 GetLightColor()70 const Vec3& GetLightColor() const 71 { 72 return color_; 73 } 74 GetLightIntensity()75 float GetLightIntensity() const 76 { 77 return intensity_; 78 } 79 GetLightShadow()80 bool GetLightShadow() const 81 { 82 return shadow_; 83 } 84 GetPosition()85 const Position& GetPosition() const 86 { 87 return position_; 88 } 89 GetRotation()90 const Quaternion& GetRotation() const 91 { 92 return rotation_; 93 } 94 95 private: 96 LightType type_ = LightType::DIRECTIONAL; 97 OHOS::Render3D::Vec3 color_ { 1.0f, 1.0f, 1.0f }; 98 float intensity_ { 10.0f }; 99 bool shadow_ = false; 100 OHOS::Render3D::Position position_; 101 OHOS::Render3D::Quaternion rotation_ { -999999.0f, -999999.0f, -999999.0f, -999999.0f }; 102 }; 103 104 } // namespace OHOS::Render3D 105 #endif // OHOS_RENDER_3D_LIGHT_H 106