ColladaLoader.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 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 
18 #ifndef _GAZEBO_COLLADALOADER_HH_
19 #define _GAZEBO_COLLADALOADER_HH_
20 
21 #include <string>
22 #include <vector>
23 #include <map>
24 
25 #include <ignition/math/Matrix4.hh>
26 #include <ignition/math/Vector3.hh>
27 #include <ignition/math/Vector2.hh>
28 
30 #include "gazebo/util/system.hh"
31 
32 class TiXmlElement;
33 
34 namespace gazebo
35 {
36  namespace common
37  {
38  class Material;
39  class ColladaLoaderPrivate;
40 
43 
47  {
49  public: ColladaLoader();
50 
52  public: virtual ~ColladaLoader();
53 
57  public: virtual Mesh *Load(const std::string &_filename);
58 
64  private: void LoadController(TiXmlElement *_contrXml,
65  TiXmlElement *_skelXml,
66  const ignition::math::Matrix4d &_transform, Mesh *_mesh);
67 
71  private: void LoadAnimations(TiXmlElement *_xml, Skeleton *_skel);
72 
76  private: void LoadAnimationSet(TiXmlElement *_xml, Skeleton *_skel);
77 
81  private: SkeletonNode* LoadSkeletonNodes(TiXmlElement *_xml,
82  SkeletonNode *_parent);
83 
87  private: void SetSkeletonNodeTransform(TiXmlElement *_elem,
88  SkeletonNode *_node);
89 
94  private: void LoadGeometry(TiXmlElement *_xml,
95  const ignition::math::Matrix4d &_transform, Mesh *_mesh);
96 
101  private: TiXmlElement *GetElementId(TiXmlElement *_parent,
102  const std::string &_name,
103  const std::string &_id);
104 
108  private: TiXmlElement *GetElementId(const std::string &_name,
109  const std::string &_id);
110 
115  private: void LoadNode(TiXmlElement *_elem, Mesh *_mesh,
116  const ignition::math::Matrix4d &_transform);
117 
121  private: ignition::math::Matrix4d LoadNodeTransform(TiXmlElement *_elem);
122 
128  private: void LoadVertices(const std::string &_id,
129  const ignition::math::Matrix4d &_transform,
130  std::vector<ignition::math::Vector3d> &_verts,
131  std::vector<ignition::math::Vector3d> &_norms);
132 
140  private: void LoadVertices(const std::string &_id,
141  const ignition::math::Matrix4d &_transform,
142  std::vector<ignition::math::Vector3d> &_verts,
143  std::vector<ignition::math::Vector3d> &_norms,
144  std::map<unsigned int, unsigned int> &_vertDup,
145  std::map<unsigned int, unsigned int> &_normDup);
146 
152  private: void LoadPositions(const std::string &_id,
153  const ignition::math::Matrix4d &_transform,
154  std::vector<ignition::math::Vector3d> &_values,
155  std::map<unsigned int, unsigned int> &_duplicates);
156 
162  private: void LoadNormals(const std::string &_id,
163  const ignition::math::Matrix4d &_transform,
164  std::vector<ignition::math::Vector3d> &_values,
165  std::map<unsigned int, unsigned int> &_duplicates);
166 
171  private: void LoadTexCoords(const std::string &_id,
172  std::vector<ignition::math::Vector2d> &_values,
173  std::map<unsigned int, unsigned int> &_duplicates);
174 
178  private: Material *LoadMaterial(const std::string &_name);
179 
184  private: void LoadColorOrTexture(TiXmlElement *_elem,
185  const std::string &_type,
186  Material *_mat);
187 
192  private: void LoadTriangles(TiXmlElement *_trianglesXml,
193  const ignition::math::Matrix4d &_transform,
194  Mesh *_mesh);
195 
200  private: void LoadPolylist(TiXmlElement *_polylistXml,
201  const ignition::math::Matrix4d &_transform,
202  Mesh *_mesh);
203 
208  private: void LoadLines(TiXmlElement *_xml,
209  const ignition::math::Matrix4d &_transform,
210  Mesh *_mesh);
211 
214  private: void LoadScene(Mesh *_mesh);
215 
219  private: float LoadFloat(TiXmlElement *_elem);
220 
224  private: void LoadTransparent(TiXmlElement *_elem, Material *_mat);
225 
228  private: ColladaLoaderPrivate *dataPtr;
229  };
231  }
232 }
233 #endif
A 3D mesh.
Definition: Mesh.hh:44
Base class for loading meshes.
Definition: MeshLoader.hh:36
A skeleton.
Definition: Skeleton.hh:53
Encapsulates description of a material.
Definition: common/Material.hh:34
Private data for the ColladaLoader class.
Definition: ColladaLoaderPrivate.hh:35
#define GZ_COMMON_VISIBLE
Definition: system.hh:91
Class used to load Collada mesh files.
Definition: ColladaLoader.hh:46
A skeleton node.
Definition: Skeleton.hh:187