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_GEOMETRY_H 17 #define OHOS_RENDER_3D_GEOMETRY_H 18 19 #include "../vec3.h" 20 #include <string> 21 22 namespace OHOS::Render3D { 23 class Geometry { 24 public: 25 Geometry(std::string name, Vec3& position, bool castShadows = false, bool receiveShadows = false) : name_(name), 26 position_(position), castShadows_(castShadows), receiveShadows_(receiveShadows) {}; 27 ~Geometry() = default; 28 29 virtual int32_t GetType() const = 0; Equals(const Geometry & obj)30 virtual bool Equals(const Geometry& obj) const 31 { 32 return GetType() == obj.GetType() 33 && GetName() == obj.GetName() 34 && CastShadows() == obj.CastShadows() 35 && ReceiveShadows() == obj.ReceiveShadows() 36 && IsEqual(obj); 37 } 38 PositionEquals(const Geometry & obj)39 bool PositionEquals(const Geometry& obj) 40 { 41 return GetPosition().GetX() == obj.GetPosition().GetX() 42 && GetPosition().GetY() == obj.GetPosition().GetY() 43 && GetPosition().GetZ() == obj.GetPosition().GetZ(); 44 } 45 GetName()46 std::string GetName() const 47 { 48 return name_; 49 } 50 GetPosition()51 const Vec3& GetPosition() const 52 { 53 return position_; 54 } 55 CastShadows()56 bool CastShadows() const 57 { 58 return castShadows_; 59 } 60 ReceiveShadows()61 bool ReceiveShadows() const 62 { 63 return receiveShadows_; 64 } 65 66 protected: 67 virtual bool IsEqual(const Geometry& obj) const = 0; 68 69 private: 70 std::string name_; 71 Vec3 position_; 72 bool castShadows_ { false }; 73 bool receiveShadows_ { false }; 74 }; 75 76 enum GeometryType { 77 CUBE, 78 SPHARE, 79 CONE, 80 }; 81 } // namespace OHOS::Render3D 82 #endif // OHOS_RENDER_3D_GEOMETRY_H 83