Gazebo Common

API Reference

4.7.0
gz/common/Mesh.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef IGNITION_COMMON_MESH_HH_
18 #define IGNITION_COMMON_MESH_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include <gz/math/Vector3.hh>
25 #include <gz/math/Vector2.hh>
26 
27 #include <ignition/utils/ImplPtr.hh>
28 
29 #include <gz/common/config.hh>
31 #include <gz/common/graphics/Export.hh>
32 
33 namespace ignition
34 {
35  namespace common
36  {
37  class Material;
38  class Skeleton;
39 
42  class IGNITION_COMMON_GRAPHICS_VISIBLE Mesh
43  {
45  public: Mesh();
46 
48  public: virtual ~Mesh();
49 
52  public: void SetPath(const std::string &_path);
53 
56  public: std::string Path() const;
57 
60  public: void SetName(const std::string &_name);
61 
64  public: std::string Name() const;
65 
68  public: ignition::math::Vector3d Max() const;
69 
72  public: ignition::math::Vector3d Min() const;
73 
76  public: unsigned int VertexCount() const;
77 
80  public: unsigned int NormalCount() const;
81 
84  public: unsigned int IndexCount() const;
85 
88  public: unsigned int TexCoordCount() const;
89 
95  public: std::weak_ptr<SubMesh> AddSubMesh(const SubMesh &_child);
96 
101  public: std::weak_ptr<SubMesh> AddSubMesh(
102  std::unique_ptr<SubMesh> _child);
103 
106  public: unsigned int SubMeshCount() const;
107 
111  public: int AddMaterial(const MaterialPtr &_mat);
112 
115  public: unsigned int MaterialCount() const;
116 
120  public: MaterialPtr MaterialByIndex(const unsigned int _index) const;
121 
126  public: int IndexOfMaterial(const Material *_mat) const;
127 
131  public: std::weak_ptr<SubMesh> SubMeshByIndex(
132  const unsigned int _index) const;
133 
137  public: std::weak_ptr<SubMesh> SubMeshByName(
138  const std::string &_name) const;
139 
143  public: void FillArrays(double **_vertArr, int **_indArr) const;
144 
147  public: void RecalculateNormals();
148 
153  public: void AABB(ignition::math::Vector3d &_center,
154  ignition::math::Vector3d &_minXYZ,
155  ignition::math::Vector3d &_maxXYZ) const;
156 
160  public: void GenSphericalTexCoord(
161  const ignition::math::Vector3d &_center);
162 
165  public: SkeletonPtr MeshSkeleton() const;
166 
169  public: void SetSkeleton(const SkeletonPtr &_skel);
170 
173  public: bool HasSkeleton() const;
174 
177  public: void Scale(const ignition::math::Vector3d &_factor);
178 
181  public: void SetScale(const ignition::math::Vector3d &_factor);
182 
186  public: void Center(const ignition::math::Vector3d &_center =
188 
191  public: void Translate(const ignition::math::Vector3d &_vec);
192 
205  public: double Volume() const;
206 
208  IGN_UTILS_UNIQUE_IMPL_PTR(dataPtr)
209  };
210  }
211 }
212 
213 #endif
Forward declarations for the common classes.
STL class.
STL class.
Encapsulates description of a material.
Definition: gz/common/Material.hh:38
static const Vector3 Zero
STL class.
STL class.
A 3D mesh.
Definition: gz/common/Mesh.hh:42
A child mesh.
Definition: gz/common/SubMesh.hh:42